01 Jul 2013 @ 11:37 AM 

Every now and then I need to get or compare the version of a file. Although this is a rather basic task, you’ll need to know the exact location of the file.
If you have a standardized environment, this wouldn’t be much of a problem… the file is at the same location on each server, right? ;-)

But what if you don’t have that luxury? What if you only know the drive where the file is located?
You can use a simple CIM/WMI class for this:

Get-CimInstance -Query "SELECT * FROM CIM_DataFile WHERE Drive='C:' AND FileName='winword' AND Extension='exe'"

And if you don’t know the drive, simply don’t filter on that and the command will search through the entire target… logically this will take a lot more time ;-)

Get-CimInstance -Query "SELECT * FROM CIM_DataFile WHERE FileName='winword' AND Extension='exe'"
Posted By: Jeff Wouters
Last Edit: 27 Jun 2013 @ 06:21 AM

EmailPermalink
Tags



 Last 50 Posts
 Back
Change Theme...
  • Users » 1
  • Posts/Pages » 321
  • Comments » 462
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

About



    No Child Pages.

Contact



    No Child Pages.

Speaking



    No Child Pages.

Health Check



    No Child Pages.