我试图在cmd上运行此powershell命令。当我直接从powershell运行它时,它起作用了。但是当我尝试从cmd运行时,我得到了错误
Powershell命令:
(Get-Wmiobject -Class Win32_Product -Filter "Name='Symantec Endpoint Protection'" -ComputerName localhost. ).Uninstall()
我如何运行它(cmd):
powershell.exe -Command (Get-Wmiobject -Class Win32_Product -Filter Name='Symantec Endpoint Protection' -ComputerName localhost. ).Uninstall()
输出:
Get-Wmiobject : Invalid query "select * from Win32_Product where Name=Symantec
Endpoint Protection"
At line:1 char:2
+ (Get-Wmiobject -Class Win32_Product -Filter Name='Symantec Endpoint P ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Wmiobject],Management
Exception
+ FullyQualifiedErrorId : GetWMIManagementException,microsoft.PowerShell.C
ommands.GetWmiobjectCommand
You cannot call a method on a null-valued expression.
At line:1 char:1
+ (Get-Wmiobject -Class Win32_Product -Filter Name='Symantec Endpoint P ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [],RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull