Reputation: 465
I need to run a powershell command via CMD
my command is
(Get-WmiObject -Class win32_pnpEntity -Filter 'Name like "ACPI Thermal Zone"')
[1].GetDeviceProperties().DeviceProperties |
Select-Object -Property keyName, data
However, when i try to run the same command with cmd, I getting exception in the query execution. it looks like something with the quote marks in the command.
Cmd command
powershell -command "(Get-WmiObject -Class win32_pnpEntity -Filter 'Name like "ACPI Thermal
Zone"')"
Please help, what do i miss?
I tried double quotes and escape char with no luck
Upvotes: 1
Views: 1092
Reputation: 23663
You might resolve this at a CMD level by escaping the double quotes with a backslash (\"
):
PowerShell -command "Get-WmiObject -Class win32_pnpEntity -Filter 'Name like \"ACPI Thermal Zone\"'"
... or as WMI queries also accepts single quotes for names in filters.
You might also simply avoid the double quotes in the WMI query and resolve this with (escaped) single quotes (''
) at a PowerShell level:
PowerShell -command "(Get-WmiObject -Class win32_pnpEntity -Filter 'Name like ''ACPI Thermal Zone''')"
Upvotes: 2