Differences
This shows you the differences between two versions of the page.
— | windows:ad:getadinfo [2019/10/31 09:06] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Powershell get AD info ====== | ||
+ | The system requirements for Exchange Server 2013 include the following for Active Directory: | ||
+ | * Forest and domain functional level of Windows Server 2003 or higher (up to Windows Server 2012 R2 is supported with Exchange Server 2013 SP1 or later) | ||
+ | * Schema Master running Windows Server 2003 SP2 or later | ||
+ | * At least one global catalog server in each Active Directory site where Exchange 2013 will be installed that runs Windows Server 2003 SP2 or higher | ||
+ | Using PowerShell we can retrieve all of this information quickly. | ||
+ | |||
+ | Here is a script that breaks a whole lot of PowerShell “rules” but gets the job done. | ||
+ | |||
+ | The script requires the ActiveDirectory PowerShell module, and in a multi-domain forest should be run in the forest root domain with an admin account that can access each domain. | ||
+ | <code powershell Get-ADInfo.ps1> | ||
+ | <# | ||
+ | .SYNOPSIS | ||
+ | Get-ADInfo.ps1 - PowerShell script to collect Active Directory information | ||
+ | .DESCRIPTION | ||
+ | This PowerShell Script collects some basic information about an Active Directory | ||
+ | environment that is useful for verifying the pre-requisites for an Exchange | ||
+ | Server deployment or upgrade. | ||
+ | .OUTPUTS | ||
+ | Results are output to the console and to a HTML file. | ||
+ | .EXAMPLE | ||
+ | .\Get-ADInfo.ps1 | ||
+ | Runs the script and generates the output. | ||
+ | .NOTES | ||
+ | Written by: Paul Cunningham | ||
+ | Find me on: | ||
+ | * My Blog: | ||
+ | * Twitter: | ||
+ | * LinkedIn: | ||
+ | * Github: | ||
+ | For more Exchange Server tips, tricks and news | ||
+ | check out Exchange Server Pro. | ||
+ | * Website: | ||
+ | * Twitter: | ||
+ | Change Log | ||
+ | V1.00, 26/06/2015 - Initial version | ||
+ | #> | ||
+ | |||
+ | #requires -version 2 | ||
+ | |||
+ | $htmlreport = $null | ||
+ | $htmlbody = $null | ||
+ | $htmlfile = " | ||
+ | $spacer = "< | ||
+ | |||
+ | Import-Module ActiveDirectory | ||
+ | |||
+ | # | ||
+ | # Collect AD Forest information and convert to HTML fragment | ||
+ | # | ||
+ | |||
+ | $forest = Get-ADForest | ||
+ | |||
+ | $htmlbody += "< | ||
+ | |||
+ | $forestinfo = New-Object PSObject | ||
+ | |||
+ | Write-Host -ForeGroundColor Yellow "*** Forest: $($forest.RootDomain) ***" | ||
+ | Write-Host "" | ||
+ | $forestinfo | ||
+ | |||
+ | Write-Host " | ||
+ | $forestinfo | ||
+ | |||
+ | Write-Host " | ||
+ | $forestinfo | ||
+ | |||
+ | Write-Host " | ||
+ | $forestinfo | ||
+ | |||
+ | Write-Host " | ||
+ | $forestinfo | ||
+ | |||
+ | $htmlbody += $forestinfo | ConvertTo-Html -Fragment | ||
+ | $htmlbody += $spacer | ||
+ | |||
+ | # | ||
+ | # Collect AD Domain information and convert to HTML fragment | ||
+ | # | ||
+ | |||
+ | $htmlbody += "< | ||
+ | |||
+ | $domains = @($forest | Select -ExpandProperty: | ||
+ | |||
+ | Foreach ($domain in $domains) | ||
+ | { | ||
+ | Write-Host "" | ||
+ | Write-Host -ForeGroundColor Yellow "*** Domain: $domain ***" | ||
+ | Write-Host "" | ||
+ | |||
+ | $domaindetails = Get-ADDomain $domain | ||
+ | |||
+ | $domaininfo = New-Object PSObject | ||
+ | | ||
+ | $domaininfo | Add-Member NoteProperty -Name " | ||
+ | | ||
+ | Write-Host " | ||
+ | $domaininfo | Add-Member NoteProperty -Name " | ||
+ | |||
+ | Write-Host " | ||
+ | $domaininfo | Add-Member NoteProperty -Name " | ||
+ | | ||
+ | Write-Host "PDC Emulator: $($domaindetails.PDCEmulator)" | ||
+ | $domaininfo | Add-Member NoteProperty -Name "PDC Emulator" | ||
+ | | ||
+ | Write-Host " | ||
+ | $domaininfo | Add-Member NoteProperty -Name " | ||
+ | | ||
+ | Write-Host "RID Master: $($domaindetails.RIDMaster)" | ||
+ | $domaininfo | Add-Member NoteProperty -Name "RID Master" | ||
+ | |||
+ | $htmlbody += $domaininfo | ConvertTo-Html -Fragment | ||
+ | $htmlbody += $spacer | ||
+ | |||
+ | } | ||
+ | |||
+ | $htmlbody += "< | ||
+ | |||
+ | $domaincontrollers = @(Get-ADDomainController -Filter {IsGlobalCatalog -eq $true}) | ||
+ | |||
+ | $gcs = @($domaincontrollers | Group-Object -Property: | ||
+ | |||
+ | Write-Host "" | ||
+ | Write-Host -ForeGroundColor Yellow "*** Global Catalogs by Site/OS ***" | ||
+ | |||
+ | $gcs = $gcs | Sort "Site, OS" | ||
+ | $gcs | ft -auto | ||
+ | |||
+ | $htmlbody += $gcs | ConvertTo-Html -Fragment | ||
+ | |||
+ | |||
+ | Write-Verbose " | ||
+ | | ||
+ | $reportime = Get-Date | ||
+ | |||
+ | #Common HTML head and styles | ||
+ | $htmlhead="< | ||
+ | < | ||
+ | BODY{font-family: | ||
+ | H1{font-size: | ||
+ | H2{font-size: | ||
+ | H3{font-size: | ||
+ | TABLE{border: | ||
+ | TH{border: | ||
+ | TD{border: | ||
+ | td.pass{background: | ||
+ | td.warn{background: | ||
+ | td.fail{background: | ||
+ | td.info{background: | ||
+ | </ | ||
+ | < | ||
+ | <h1 align="" | ||
+ | <h3 align="" | ||
+ | |||
+ | $htmltail = "</ | ||
+ | </ | ||
+ | |||
+ | $htmlreport = $htmlhead + $htmlbody + $htmltail | ||
+ | |||
+ | $htmlreport | Out-File $htmlfile -Encoding Utf8 | ||
+ | </ |