Zoo*_*ing 29 powershell powershell-2.0
是否有PowerShell命令列出所有以前加载的变量?
我在Visual Studio中运行一些PowerShell脚本,并希望列出当前PowerShell会话中可用的所有变量.
我试过这个命令:
ls variable:*;
Run Code Online (Sandbox Code Playgroud)
但它返回以下内容:
System.Management.Automation.PSVariable
System.Management.Automation.PSVariable
System.Management.Automation.PSVariable
System.Management.Automation.PSVariable
System.Management.Automation.PSVariable
System.Management.Automation.PSVariable
System.Management.Automation.PSVariable
System.Management.Automation.PSVariable
System.Management.Automation.PSVariable
System.Management.Automation.PSVariable
Run Code Online (Sandbox Code Playgroud)
lat*_*kin 50
ls variable:*应该工作,或Get-Variable.如果这些导致输出不良,则是由于主机实现不佳,而不是PowerShell本身.如果您打开标准控制台主机(运行powershell.exe),您将看到这些工作正常.
如果你需要解决一个糟糕的主机,你可能会更好地将所有内容转储到显式字符串:
Get-Variable | Out-String
Run Code Online (Sandbox Code Playgroud)
要么
Get-Variable |%{ "Name : {0}`r`nValue: {1}`r`n" -f $_.Name,$_.Value }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
54423 次 |
| 最近记录: |