Set Primary and Failover Management Servers for Agent Managed Computers with Powershell


 

Here’s an easy script to set the primary and secondary management servers for all agent managed computers in your management group. Just run this on any management server:

$primaryMS = (Get-SCOMManagementServer | Sort-Object DisplayName )[0]
$failoverMS = (Get-SCOMManagementServer | Sort-Object DisplayName )[1]
Get-SCOMAgent | % { Set-SCOMParentManagementServer -Agent $_ -PrimaryServer $primaryMS; `
Set-SCOMParentManagementServer -Agent $_ -FailoverServer $failoverMS}
Get-SCOMAgent | Select @{Label="Agent"; Expression={$_.Displayname}}, @{Label="Primary MS"; `
Expression={$_.PrimaryManagementServerName}}, @{Label="Failover MS Server(s)"; `
Expression={$_.GetFailoverManagementServers().DisplayName}} | Format-Table -Autosize

 

Enjoy.
 


Comments (7)

  1. Jonathan Almquist says:

    lol – good seeing you blog Tyson! Even if it is old news 😉

  2. Tyson.Paul says:

    Ha! Jerk.  😉

  3. HKRV says:

    Hi tyson

    I have two management servers, May you please tell me in which line do i have to provide the primary and failover server details.

    Sorry Im totally new to Powershell. Thanks in advance.

    Regards

    HRKV

  4. Tyson.Paul says:

    This script automatically selects the first two management servers alphabetically.

  5. HKRV says:

    Hi

    Thanks for the Swift Response.. So if I ran this Script on my primary management  server.. it will communicate the fail over server details to all agents?

    Sorry for asking many questions. Thanks in advance.

    Regards

    HKRV

  6. Tyson.Paul says:

    Yes. You will see the updated assignments in the Agents view in the Administration workspace of the Console.

  7. HKRV says:

    Sorry, Tyson .. I have not seen any agent carrying that information.. Could please tell me how to confirm.

    Thanks in advance.