Posts

Showing posts from April, 2014

PowerShell script to get details of SQL Server instances

Following is the PowerShell script to list details of SQL Instances installed on a host. It gets details of even 32 bit installed on 64 bit host. Following is the script: $ComputerName=get-content env:computername $sqlInstLst = @() echo $ComputerName $RegPath = 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL' if (Test-Path $RegPath){      try{          Get-ItemProperty -Path $RegPath      }     catch{           Write-Error $_.Exception.Message           return $false     } } else{      echo $ComputerName+'does not have SQL Server installed' } $RegPath = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\Instance Names\SQL' if (Test-Path $RegPath){      echo '32 bit instances on'+$ComputerName      try{           Get-ItemProperty -Path $RegPath      }     catch{           Write-Error $_.Exception.Message           return $false      } } else{      echo $ComputerName' does not have 32 bit SQL Server installed' }

Make Money from Surveys