# encoding: ascii
# api: powershell
# title: Forest FSMO
# description: Display the FSMO role holders of each domain in your forest.
# version: 0.1
# type: script
# author: Geoff Guynn
# license: CC0
# x-poshcode-id: 6031
# x-archived: 2016-05-17T13:07:31
# x-published: 2016-09-26T00:51:00
#
#
#Script Author Information
$script:ProgramName = "Forest FSMO"
$script:ProgramDate = "11 Dec 2013"
$script:ProgramAuthor = "Geoffrey Guynn"
$script:ProgramAuthorEmail = [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String("Z2VvZmZyZXlAZ3V5bm4ub3Jn"))

$Forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()
$ChildDomains = $Forest.Domains
$SchemaRole = $Forest.SchemaRoleOwner
$NamingRole = $Forest.NamingRoleOwner

$DomainObjects = @()

$ChildDomains | % {

    $CurrentDomain = $_
    
    $objDomain = $CurrentDomain | Select Name, Forest, PDCRoleOwner, RidRoleOwner, InfrastructureRoleOwner
    $objDomain | Add-Member -MemberType NoteProperty -Name SchemaRole -Value $SchemaRole
    $objDomain | Add-Member -MemberType NoteProperty -Name NamingRole -Value $NamingRole
    
    $DomainObjects += $objDomain
}

$DomainObjects
