Get version details of multiple SQL server's

  • In powershell you really don't exactly have to run the query against the server, since you have those properties available in different ways.

    For instance, this script will go find your sql servers (all on the network...even workstations which you may not care about at all) and then return the name and version of each of them.

    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null;

    $smoObj = [Microsoft.SqlServer.Management.Smo.SmoApplication];

    # This gets the sql servers available

    $sql = $smoObj::EnumAvailableSqlServers($false)

    foreach($sqlserver in $sql)

    {

    $sqlserver.Name; $sqlserver.Version;

    }

    You could pipe these kinds of results out to whatever format you wanted to, whether it be to a text file, excel spreadsheet, load into a database etc...

Viewing post 1 (of 2 total)

You must be logged in to reply to this topic. Login to reply