【发布时间】:2012-09-10 01:35:52
【问题描述】:
是否有 PowerShell 命令可以列出所有以前加载的变量?
我正在 Visual Studio 中运行一些 PowerShell 脚本,并希望列出当前 PowerShell 会话中可用的所有变量。
我已经尝试了命令:
ls variable:*;
但它返回以下内容:
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
【问题讨论】:
-
当你说参数的时候,你到底是什么意思?提供给脚本或函数的所有参数?启动此特定 powershell 会话时使用的参数?可用变量?
-
ls variable:*应该可以工作(至少对我有用)。您使用的是哪个主机输出错误? -
主机?我真的是 PS 新手,什么是主机?
-
powershell 是在一个名为 Sitecore Rocks 的 Visual Studio 插件中执行的,如果你想要的话。
-
看起来主机只是在这些 PSVariable 对象上执行
.ToString(),这会吐出类型名称而不是名称/值信息。在 PowerShell 提示符(主机)中,格式化引擎对对象进行格式化以组成有用的字符串以显示给主机。看起来这台主机比完整的六包少了几罐。 :-)