With this script, you will be able to get a status on your Microsoft SQL Server version and patch level. This script uses a csv table I have created and that contains the version and patch level for each SQL
Get server hostnames on which MSSQLServer service is installed
Query a SQL database
This script can be used to query an SQL database Script : $SqlConnection = New-Object System.Data.SqlClient.SqlConnection $SqlConnection.ConnectionString = “Server=DBServerHostname;Database=master;Integrated Security=True” $SqlConnection.Open() $SqlCmd = New-Object System.Data.SqlClient.SqlCommand $SqlCmd.CommandText = “select * from DatabaseName” $SqlCmd.Connection = $SqlConnection $reader = $SqlCmd.ExecuteReader() $Counter = $Reader.FieldCount