Powershell WMIC Datafile Invalid Query?

Question:

I have searched and searched, but cannot figure out why this is returning an Invalid query error:

I’ve tried it with an elevated PS as well, thinking that perhaps it was due to the permissions on the program files folders. I also tried it with case-sensitive path/filename. I’ve tried double quotes as well as single quotes, as well as no quotes. I’ve also tried replacing the double \’s with singles. I’ve even tried different files in different folder locations (like c:\temp); it seems that every time I use datafile where name, I get an invalid query, even if I leave off get version…

What in the world is going on?

Answer:

Use PowerShell’s Get-WmiObject (alias gwmi) native approach:

Source:

Powershell WMIC Datafile Invalid Query? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply