How do I check for the SQL Server Version using Powershell?
Just an option using the registry, I have found it can be quicker on some of my systems:
$inst = (get-itemproperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstancesforeach ($i in $inst){ $p = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL').$i (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$p\Setup").Edition (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$p\Setup").Version}
Invoke-Sqlcmd -Query "SELECT @@VERSION;" -QueryTimeout 3
[reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | out-null$srv = New-Object "Microsoft.SqlServer.Management.Smo.Server" "."$srv.Version$srv.EngineEdition
Obviously, replace "." with the name of your instance. If you want to see all the methods available, go here.