简体   繁体   English

Powershell “'get-error' 未被识别为 cmdlet 的名称

[英]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.

相关问题 Powershell错误“术语'Get-SPWeb'未被识别为cmdlet的名称,函数......” - Powershell Error “The term 'Get-SPWeb' is not recognized as the name of a cmdlet, function…” Powershell - 术语“=”未被识别为 cmdlet 的名称 - Powershell - The term '=' is not recognized as the name of a cmdlet Powershell Runbook - 术语“Get-AzureRMWebAppSlot”未被识别为 cmdlet 的名称 - Powershell Runbook - The term 'Get-AzureRMWebAppSlot' is not recognized as the name of a cmdlet Powershell 任务中的错误设置 $var 'The term 'keyVaultName' is not known as the name of a cmdlet" - Error in Powershell Task with setting $var 'The term 'keyVaultName' is not recognized as the name of a cmdlet" Appfabric Powershell错误“术语'Get-CacheStatistics'不被识别为cmdlet的名称。” - Appfabric Powershell error “The term 'Get-CacheStatistics' is not recognized as the name of a cmdlet..” PowerShell 6.2.4:Get-Clipboard' 未被识别为 cmdlet 的名称 - PowerShell 6.2.4 : Get-Clipboard' is not recognized as the name of a cmdlet 术语“Get-SqlErrorLog”未被识别为 cmdlet [Powershell] [SQL Server] 的名称 - The term 'Get-SqlErrorLog' is not recognized as the name of a cmdlet [Powershell] [SQL Server] 错误:“%_。LastWriteTime无法识别为cmdlet的名称” - Error: “%_.LastWriteTime is not recognized as the name of a cmdlet” 我可以在Powershell中自定义“未识别为cmdlet的名称”错误吗? - Can I customise the 'not recognized as the name of a cmdlet' error in Powershell? 尝试在 vscode powershell 终端中使用命令 git init 但出现错误:git: The term 'git' is not Recognized as the name of a cmdlet - Trying to use the command git init within vscode powershell terminal but get an error: git : The term 'git' is not recognized as the name of a cmdlet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM