#$ErrorActionPreference = 'SilentlyContinue'
$computers = Get-Content C:\AllServers.txt
Invoke-Command -Computer $computers {
$inst = (get-itemproperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances
foreach ($i in $inst)
{
$p = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL').$i
$Edition = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$p\Setup").Edition
$version = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$p\Setup").Version
}
[pscustomobject] @{
ComputerName = (Get-CimInstance Cim_ComputerSystem).Name
Edition = $Edition
Version = $version
}
} | Export-Csv -NoTypeInformation -Encoding Utf8 -LiteralPath c:\out.csv
Get SQL Installed Servers including SQL Versions
Super User
Hits: 545