
As an IT consultant I often visit new customers and it is always good practice to just double check which DC’s are available in the organization, which sites they belong etc.
To make it easy for myself I created a script that will get the:
- DC’s in the domain
- Uptime (in Hrs.)
- Site the DC belongs to
- IP address
- OS Version
- GlobalCatalog
- if the DC is a read-only DC
- Who carries which FSMO role
The below script will get this information and display it in your powershell session. You could customize the script to get more information are have the results emailed to yourself.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
$DCs = Get-ADDomainController -Filter * $Results = New-Object -TypeName System.Collections.ArrayList foreach($DC in $DCs){ [string]$OMRoles = "" $OS = $null $OS = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $DC -ErrorAction STOP $timespan = $OS.ConvertToDateTime($OS.LocalDateTime) – $OS.ConvertToDateTime($OS.LastBootUpTime) [int]$uptime = "{0:00}" -f $timespan.TotalHours $ThisResult = New-Object -TypeName System.Object Add-Member -InputObject $ThisResult -MemberType NoteProperty -Name Name -Value $DC.Name Add-Member -InputObject $ThisResult -MemberType NoteProperty -Name Uptime -Value $uptime Add-Member -InputObject $ThisResult -MemberType NoteProperty -Name Site -Value $DC.Site Add-Member -InputObject $ThisResult -MemberType NoteProperty -Name IPv4Address -Value $DC.IPv4Address Add-Member -InputObject $ThisResult -MemberType NoteProperty -Name OperatingSystemVersion -Value $DC.OperatingSystemVersion Add-Member -InputObject $ThisResult -MemberType NoteProperty -Name IsGlobalCatalog -Value $DC.IsGlobalCatalog Add-Member -InputObject $ThisResult -MemberType NoteProperty -Name IsReadOnly -Value $DC.IsReadOnly foreach($OMRole in $DC.OperationMasterRoles){ $OMRoles += ([string]$OMRole+" ") } Add-Member -InputObject $ThisResult -MemberType NoteProperty -Name OperationMasterRoles -Value $OMRoles $Results.Add($ThisResult) | Out-Null } $Results = $Results | Sort-Object -Property Name $Results | Format-Table -AutoSize |
Below is an example of the output:
Comments