PowerShell调试、跟踪及环境信息获取全解析
1. PowerShell调试脚本
PowerShell虽无内置图形化调试界面,但其交互式调试功能能助你快速诊断和解决问题。若想了解 Set-PsDebug cmdlet的更多信息,可输入 Get-Help Set-PsDebug 。
以下是一个调试复杂脚本的示例:
DEBUG: 17+ $dirCount = @(Get-ChildItem $env:WINDIR).Count
DEBUG: 17+ $dirCount = @(Get-ChildItem $env:WINDIR).Count
DEBUG: 19+ Set-PsDebug -Trace 2
DEBUG: 20+ $runningTotal -= 10
DEBUG: ! SET $runningTotal = '1215'.
DEBUG: 21+ $runningTotal /= 2
DEBUG: ! SET $runningTotal = '607.5'.
DEBUG: 23+ Set-PsDebug -Step
Continue with this operation?
24+ $runningTotal *= 3
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):y
DEBUG: 24+ $runningTotal *= 3
DEBUG: ! SET $runnin
超级会员免费看
订阅专栏 解锁全文
186

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



