Techibee.com

How to get FSMO roles of a active directory domain using powershell

I feel this post doesn’t require much explanation. We all know FSMO roles and their important. This little powershell script helps you query active directory FSMO roles from your domain/forest.

I have seen some more examples about the same topic in internet but all of them are using dotnet objects to get this information or running the command lines and parsing the information to generate the data. I feel this is not necessary as the built-in activedirectory module is providing this information in a very straight forward way.

function Get-AdFSMORoles {            
[cmdletbinding()]            
param()            

$AdFSMORoles = New-Object -TypeName PSobject            

import-module activedirectory            
$DomainRoles = Get-ADDomain            
$ForestRoles = Get-ADForest            

$AdFSMORoles | Add-Member -MemberType NoteProperty -Name InfraStructureMaster -Value $DomainRoles.InfraStructureMaster            
$AdFSMORoles | Add-Member -MemberType NoteProperty -Name RIDMaster -Value $DomainRoles.RIDMaster            
$AdFSMORoles | Add-Member -MemberType NoteProperty -Name PDCEmulator -Value $DomainRoles.PDCEmulator            
$AdFSMORoles | Add-Member -MemberType NoteProperty -Name SchemaMaster -Value $ForestRoles.SchemaMaster            
$AdFSMORoles | Add-Member -MemberType NoteProperty -Name DomainNamingMaster -Value $ForestRoles.DomainNamingMaster            

$ADFSMORoles | fl            
}

Hope this helps…

 

Exit mobile version