26 Jun 2013 @ 9:24 AM 

When you have a whole bunch of SQL Servers with multiple instances and don’t know which version on each instance you’re running on what server, you may want to do a little inventory.
But would you (or tell an intern to) logon to those servers and do it manually? I sure wouldn’t… PowerShell can help you with this :-)

So, how can you find the version of SQL? I’ve chosen to look at the file ‘sqlservr.exe’ and get the version of that file.
This because that would give me a pretty darn accurate answer to that question :-)
So, did you know that you can use the CIM_DATAFILE class to find files on a server?

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

This will give you a version of the file and based on the location of the file you can deduct which instance it belongs to.

Note that I’ve defined the drive where to search. If you don’t, it will search on all drives.
Depending on your target, it may take quite some time….

Posted By: Jeff Wouters
Last Edit: 26 Jun 2013 @ 09:07 AM

EmailPermalink
Tags
Categories: DuPSUG, PowerShell



 Last 50 Posts
 Back
Change Theme...
  • Users » 1
  • Posts/Pages » 328
  • Comments » 470
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.