From running the following I can see that there are 4 MSSQL instances running on this machine:
$Hostname = (Get-WmiObject Win32_OperatingSystem).CSName
$GetSQLInstance = Get-Service -ComputerName $Hostname | Where-Object { ($_.Name -eq 'mssqlserver' -or $_.Name -like 'mssql$*') -and $_.DisplayName -like 'SQL Server*'}
$GetSQLInstance
Status Name DisplayName
------ ---- -----------
Running MSSQL$INSTANCE01 SQL Server (INSTANCE01)
Running MSSQL$INSTANCE02 SQL Server (INSTANCE02)
Running MSSQL$INSTANCE03 SQL Server (INSTANCE03)
Running MSSQL$INSTANCE04 SQL Server (INSTANCE04)
I am trying to ascertain the MSSQL version of these instances, what would be the best way to do so? I thought to use Get-SqlInstance
, but it doesn't seem to be installed on this machine:
Get-SqlInstance
Get-SqlInstance : The term 'Get-SqlInstance' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-SqlInstance
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-SqlInstance:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException