Transferring FSMO roles using Windows PowerShell

To transfer FSMO roles using the Move-ADDirectoryServerOperationMasterRole PowerShell cmdlet from the Active Directory Module for Windows PowerShell, use (pieces of) the following script:

Import-Module ActiveDirectory

Move-ADDirectoryServerOperationMasterRole -Identity "DC01"
-OperationMasterRole SchemaMaster


Move-ADDirectoryServerOperationMasterRole -Identity "DC01"
-OperationMasterRole DomainNamingMaster


Move-ADDirectoryServerOperationMasterRole -Identity "DC01"
-OperationMasterRole PDCEmulator


Move-ADDirectoryServerOperationMasterRole -Identity "DC01"
-OperationMasterRole RIDMaster


Move-ADDirectoryServerOperationMasterRole -Identity "DC01"
-OperationMasterRole InfrastructureMaster