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


*Note: this script works well for agents that have never been assigned parent/failover with PowerShell. Once you use PowerShell to assign parents, it becomes problematic to assign new parents especially if you only have 2 management servers. You cannot set the parent the same as failover, and you cannot set failover the same as parent so the cmdlet “Set-SCOMParentManagementServer”  won’t work a second time. You cannot have duplicate assignments.  You have to use a more complicated approach to reassign the parent/failover(s) from that point forward (with PowerShell). Example: here

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.



  4. Tyson.Paul says:

    This script automatically selects the first two management servers alphabetically.

  5. HKRV says:


    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.



  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.

Skip to main content