我想输出变量和值电源外壳 http://en.wikipedia.org/wiki/Windows_PowerShell通过设置标志并查看整个脚本中的数据排列来编写脚本。
我该怎么做?
例如,与以下 PHP 代码等效的 PowerShell 是什么?
echo "filesizecounter: " . $filesizecounter
有以下几种方法:
Write-Host https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/write-host:直接写入控制台,不包含在函数/cmdlet 输出中。允许设置前景色和背景色。
Write-Debug https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/write-debug:直接写入控制台,如果$DebugPreference https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables#debugpreference设置为继续或停止。
Write-Verbose https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/write-verbose:直接写入控制台,如果$VerbosePreference https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables#verbosepreference设置为继续或停止。
后者用于额外的可选信息,Write-Debug
用于调试(因此似乎适合这种情况)。
额外的:在 PSH2(至少)中,使用 cmdlet 绑定的脚本将自动获取-Verbose
and -Debug
切换参数,本地使能Write-Verbose
and Write-Debug
(即覆盖首选项变量)与编译的 cmdlet 和提供程序一样。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)