powershell get-wmiobject wildcards - Batch File
I´m struggling with on batch file here.. The idea is to get the version of the applications installed on a remote pc, but instead of writing the full application name ( that can be a bit different from client to client) i want to use a Wildcard for it..
Unfortunantly GET-WmiObject operator, does not work the the parameter ( -like) as SQL..
The powershell command below works like i want , but when i add it the the batch file, it does not work...
Power Shell command that work :
[tag:Get-WmiObject -ComputerName ##PCNAMEHERE## -Query "Select * From Win32_Product Where name Like 'McAfee%'" | select Name, Version]
Line on the batch program
\[tag:get specific app with Wildcards !!!!! Need corrections !!!
Powershell.exe Get-WmiObject -ComputerName %CN% -Query Select \* From Win32_Product Where name Like ''McAfee%'' | select Name, Version \>\>%LOG%\]
Error that i get on the batch execution... Already try to play with " and ' but without success ...
Get-WmiObject : A positional parameter cannot be found that accepts argument '*'. At line:1 char:1
- Get-WmiObject -ComputerName W1865C28 -Query Select * From Win32_Produ ...
-
+ CategoryInfo : InvalidArgument: (:) [Get-WmiObject], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.GetWmiObjectCommand
This way would avoid a lot of quoting issues:
Even better, since win32_product is so slow, and >> might mix encodings, but uses remote powershell: