[英]Powershell "'get-error' is not recognized as the name of a cmdlet
Get-Error should be one of the basic PS commands, but it doesn't work for me. Get-Error 应该是基本的 PS 命令之一,但它对我不起作用。 I get an error:
我得到一个错误:
get-error : The term 'get-error' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
I updated the module Microsoft.PowerShell.Utility.我更新了模块 Microsoft.PowerShell.Utility。 I've checked the list of commands in it with:
我已经检查了其中的命令列表:
Get-Command -Module Microsoft.PowerShell.Utility
And it is still not there.它仍然不存在。
Does anyone know how to fix it or how to get detailed error info without it?有谁知道如何修复它或如何在没有它的情况下获取详细的错误信息?
Thanks!谢谢!
Powershell errors are objects, just like everything else. Powershell 错误是对象,就像其他所有错误一样。 As such, you can interrogate their properties and invoke their methods.
因此,您可以询问它们的属性并调用它们的方法。 They're documented on MSDocs as System.Management.Automation.ErrorRecord .
它们在 MSDocs 上记录为System.Management.Automation.ErrorRecord 。
When I forced an error, and looked at the object with Get-Member
, I saw当我强制出错并使用
Get-Member
查看 object 时,我看到了
PS D:\Scripts> $error[0] | Get-Member
TypeName: System.Management.Automation.ErrorRecord
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetObjectData Method void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System....
GetType Method type GetType()
ToString Method string ToString()
CategoryInfo Property System.Management.Automation.ErrorCategoryInfo CategoryInfo {get;}
ErrorDetails Property System.Management.Automation.ErrorDetails ErrorDetails {get;set;}
Exception Property System.Exception Exception {get;}
FullyQualifiedErrorId Property string FullyQualifiedErrorId {get;}
InvocationInfo Property System.Management.Automation.InvocationInfo InvocationInfo {get;}
PipelineIterationInfo Property System.Collections.ObjectModel.ReadOnlyCollection[int] PipelineIterationInfo {g...
ScriptStackTrace Property string ScriptStackTrace {get;}
TargetObject Property System.Object TargetObject {get;}
PSMessageDetails ScriptProperty System.Object PSMessageDetails {get=& { Set-StrictMode -Version 1; $this.Except...
PS D:\Scripts>
but using the MSDocs will give you more useful information.但是使用 MSDocs 会给你更多有用的信息。
I installed Powershell core from https://github.com/powershell/powershell It seems to be available in Powershell core.我从https://github.com/powershell/powershell安装了 Powershell 内核,它似乎在 Powershell 内核中可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.