Skip to content

Instantly share code, notes, and snippets.

@Laim

Laim/versions.ps1

Last active May 7, 2021
Embed
What would you like to do?
PowerShell, .NET and SQL Instance Versions in PowerShell
# START : Get SQL Instance Version #
cls # prevents the script itself from echoing out into ISE
"---------------------------------------------------------------------"
$inst = (get-itemproperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server').InstalledInstances # Gets the installed SQL instances
$sqlInstanceCount = 0; # loop for the foreach
foreach ($i in $inst)
{
$sqlInstanceCount = $sqlInstanceCount + 1;
$p = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL').$i
"Instance " + $sqlInstanceCount + " SQL Edition: " + (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$p\Setup").Edition
"Instance " + $sqlInstanceCount + " SQL Version: " + (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft SQL Server\$p\Setup").Version
}
# END : Get SQL Instance Versions #
"---------------------------------------------------------------------"
# START : Powershell Version #
"Highest PS Ver. Installed: " + (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine -Name 'PowerShellVersion').PowerShellVersion
# END : PowerShell Version #
"---------------------------------------------------------------------"
# START : .NET Framework Version #
"Highest .NET Fwrk Ver. Installed: " + ([Runtime.InteropServices.RuntimeInformation]::FrameworkDescription -replace '^.[^\d.]*','')
# END : .NET Framework Version #
"---------------------------------------------------------------------"
# START : This can be removed #
"Script Version: 1.1"
"Script Date: 07-May-2021"
"Script Location: https://gist.github.com/Laim/a14c90257d74f6a0678aac59e66ea470"
"---------------------------------------------------------------------"
""
# END : This can be removed #
@Laim

This comment has been minimized.

Copy link
Owner Author

@Laim Laim commented May 7, 2021

Example output

Example Output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment