Last active
May 7, 2021 17:52
-
-
Save Laim/a14c90257d74f6a0678aac59e66ea470 to your computer and use it in GitHub Desktop.
PowerShell, .NET and SQL Instance Versions in PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 # |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output