Hello,
I’m trying to put subexpressions inside WMI query and it refuses to work. If I put result of my subexpression as plain string then it works just fine. What am I doing wrong?
PS C:\Users\a> Get-WmiObject -ComputerName Computer1 -Query “SELECT * FROM CIM_DataFile WHERE Drive =‘E:’ and path=‘\logfiles\W3SVC1395239964\’ AND extension=‘zip’ and Creationdate>‘{(Get-Date).AddDays(-30).ToShortDateString().toString()}’”
Get-WmiObject : Invalid query “SELECT * FROM CIM_DataFile WHERE Drive =‘E:’ and path=‘\logfiles\W3SVC1395239964\’ AND extension=‘zip’ and
Creationdate>‘{(Get-Date).AddDays(-30).ToShortDateString().toString()}’”
At line:1 char:1
- Get-WmiObject -ComputerName DALWEBEXTESVC1 -Query "SELECT * FROM CIM_DataFile WH …
-
+ CategoryInfo : InvalidArgument: (:) [Get-WmiObject], ManagementException + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand