Command Shell Examples
Useful SQL Queries
Get Primary and Failover MS List for Agent - Jonathan Almquist on Operations Manager - Site Home - TechNet Blogs

Get Primary and Failover MS List for Agent

Get Primary and Failover MS List for Agent

  • Comments 2
  • Likes

get-agent | where {$_.name -match "[computer name]"} | select @{name="Primary";expression={$_.getPrimaryManagementServer().name}}, @{name="FailoverList";expression={$_.getFailoverManagementServers() | foreach-object {$_.name}}} | fl

 

command shell main menu

I do not moderate this blog anymore. If you have a question regarding this post, send me a message.

Comments
  • Great post,

    Very interesting to the PowerShell newbie!

    Question: Why is it that I get the following output:

    Primary      : @{Name=mtl-hq-m30.<domain>}

    FailoverList : {mtl-hq-m25.<domain>, mtl-hq-m24.<domain>}

    Notice the extra "@{Name=" at the beginning of the Primary output, whereas it should be "{"?

    Also, I would recommend using the full name for cmdlets (& parameters) and not their aliases/shortcuts when posting examples (or scripting), as they are typically self-documenting.

    Thanks,

    Larry

  • @Larry - I modified the script slightly to take "Name" out of the Primary results.  I probably got lazy on that one.  Thanks for pointing it out.

    -Jonathan