Home Forums Programming Powershell Query local SSMS server group with Powershell? RE: Query local SSMS server group with Powershell?

  • MG-148046 (12/27/2012)


    You could use the stucture available in SQLPS. Set your location to SQLSERVER:\SQLRegistration\Database Engine Server Group\<your group name> then set a variable equal to get-childitem and do a foreach loop over each server in the group.

    A simple example:

    Set-Location SQLSERVER:\SQLRegistration\Database Engine Server Group\<your group name>

    $servers = get-childitem

    foreach ($server in $server) {<do something herer>}

    I like the text file or database table only because it's portable. Here is more info on it. It requires the installation of some add-ons to make sqlps importable into your PoSh sessions.

    Programming SQLRegistration in the SQL Server PowerShell Provider

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato