Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: What am I doing wrong?

$
0
0

As a tip, a descriptive subject like “Help with subexpression in WMI query” can help make sure the right folks are looking at your post :).

You’re not using a subexpression.


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())’”

Is a subexpression. Subexpressions look like $(), not {}. {} is a script block, and WMI didn’t know what to do with it. Subexpressions get parsed by the shell before the query is sent to WMI.


Viewing all articles
Browse latest Browse all 13067

Trending Articles