PowerTip: Use PowerShell to Get List of FSMO Role Holders


Summary: Use Windows PowerShell to get a list of FSMO role holders in Active Directory.

Hey, Scripting Guy! Question I use NETDOM QUERY FSMO to list my domain controllers that hold the FSMO roles, but can I do it with Windows PowerShell?

Hey, Scripting Guy! Answer As usual, there is more than one way to do most things in Windows PowerShell, but here are some syntax examples to meet your needs:

Get-ADDomain | Select-Object InfrastructureMaster, RIDMaster, PDCEmulator

Get-ADForest | Select-Object DomainNamingMaster, SchemaMaster

Get-ADDomainController -Filter * |

     Select-Object Name, Domain, Forest, OperationMasterRoles |

     Where-Object {$_.OperationMasterRoles} |

     Format-Table -AutoSize

 

Comments (2)

  1. s.mcknight says:

    PowerShell…..ROCKS.

  2. Chris says:

    FYI – on latest version of Windows 10 powershell, I had to change line "Select-Object….." to "Select" to work, otherwise it errored out on the Select-Object piece. I have older (2008/2008R2) DCs in there, so I’m assuming it’s the new version of Windows
    (10)/Powershell that has perhaps deprecated that command? Anyway, just FYI if you run into the same error I got…

    At line:2 char:59
    + Select-Object Name, Domain, Forest, OperationMasterRoles |’
    + ~
    Expressions are only allowed as the first element of a pipeline.
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ExpressionsMustBeFirstInPipeline

    I realize this error text isn’t indicative of the solution I found, but based on some other Powershell articles I found that "Select" instead of "Select-Object" was sufficient to make it work for. Hope this helps someone else as well.

    and yes, Powershell rocks!

Skip to main content