<# .SYNOPSIS This script will get the FSMO roles for the forest and domain. .DESCRIPTION This script will get the FSMO roles for the forest and domain. The script will read the forest and domain and check the FSMO roles for each. The script will then output the PDCEmulator, InfrastructureMaster, RIDMaster, DomainNamingMaster, and SchemaMaster for the forest and domain. The script will display the output in a table format. The script will also handle any errors that occur during the process and continue to the next domain controller. .EXAMPLE Get-FSMORoles This will run the script and get the FSMO roles for the forest and domain. .EXAMPLE Get-FSMORoles -ReferenceDomain "yourdomainname.com" This will run the script and get the FSMO roles for the specified domain. .INPUTS The domain to use as a reference for the forest. The domain should be specified in the script. .OUTPUTS The script will output the PDCEmulator, InfrastructureMaster, RIDMaster, DomainNamingMaster, and SchemaMaster for the forest and domain. The script will display the output in a table format. .NOTES This script is used for getting the FSMO roles for the forest and domain. #> function Get-ForestAndDomainInfo { # Get the FSMO roles for the forest Write-Output "Forest FSMO Roles:" Get-ADForest | Select-Object PDCEmulator, InfrastructureMaster, RIDMaster, DomainNamingMaster, SchemaMaster | Format-Table -AutoSize # Get the FSMO roles for the domain Write-Output "`nDomain FSMO Roles:" Get-ADDomain | Select-Object PDCEmulator, InfrastructureMaster, RIDMaster, DomainNamingMaster, SchemaMaster | Format-Table -AutoSize # Get the domain controllers and their operation master roles Write-Output "`nDomain Controllers with Operation Master Roles:" Get-ADDomainController -Filter * | Select-Object Name, Domain, OperationMasterRoles | Where-Object { $_.OperationMasterRoles } | Format-Table Name, Domain, OperationMasterRoles -AutoSize }