我尝试从cmd运行此命令:
powershell -command "& {&'get-wmiobject Win32_Product | Format-Table Name, LocalPackage}"
...它在Windows 7上工作但在我的Windows服务器2008 R2 x64-bitIi上遇到了这个错误:
The string starting:
At line:1 char:5
+ & {& <<<< 'get-wmiobject Win32_Product | Format-Table Name, LocalPackage}
is missing the terminator: '.
At line:1 char:68
+ & {&'get-wmiobject Win32_Product | Format-Table Name, LocalPackage} <<<<
+ CategoryInfo : ParserError: (get-wmiobject W..., LocalPackage}:
String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
如何解决此错误?我需要它从cmd运行!!
答案 0 :(得分:1)
两种变体都在这里工作:
powershell -command "get-wmiobject Win32_Product | Format-Table Name, LocalPackage"
powershell -command "&{get-wmiobject Win32_Product | Format-Table Name, LocalPackage}"