Skip to main content

Posts

Showing posts from February, 2011

Powershell script to list the binary paths of SQL Instances

You can use Powershell with WMI to find out the paths where the binary files of SQL instances reside. The following code will display the path to the binaries for each instance installed in a server (replace yourservername with your server name): SQL Server 2005: Get-WmiObject -ComputerName YOURSERVERNAME -namespace 'root\Microsoft\SqlServer\ComputerManagement' -query "SELECT ServiceName, BinaryPath FROM SqlService WHERE SQLServiceType = 1 and ServiceName like '%SQL%'" | ft -property ServiceName, BinaryPath SQL Server 2008 or SQL Server 2008 R2 : Get-WmiObject -ComputerName YOURSERVERNAME -namespace 'root\Microsoft\SqlServer\ComputerManagement10' -query "SELECT ServiceName, BinaryPath FROM SqlService WHERE SQLServiceType = 1 and ServiceName like '%SQL%'" | ft -property ServiceName, BinaryPath