PowerShell 错误管理与性能分析全解析
1. PowerShell 错误管理基础
PowerShell 中的 $error 变量在当前 shell 会话中会持续记录所产生的错误列表,这个列表包含终止性和非终止性错误。当遇到错误时,PowerShell 会显示较为详细的信息。例如:
PS > Stop-Process -name IDoNotExist
Stop-Process : Cannot find a process with the name "IDoNotExist". Verify
the process name and call the cmdlet again.
At line:1 char:13
+ Stop-Process <<<< -name IDoNotExist
+ CategoryInfo : ObjectNotFound: (IDoNotExist:String) [Stop-
Process], ProcessCommandException
+ FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.Power
Shell.Commands.StopProcessCommand
这些错误的一个独特特性是,它们受益于多元化的 PowerShell 用户社区。 FullyQualifiedErrorId 这一行的错误标识符无论错误发生时使用何种语言都是相
超级会员免费看
订阅专栏 解锁全文
1702

被折叠的 条评论
为什么被折叠?



