AD Sites and Services Dump

Posted on by

This week, I was asked to document steps for an AD Migration from 2003 to 2012. Unfortunately I cannot go into too much detail about the project but what I can do is share some of the tools and scripts that I have created to help in the documentation.

One of bits of information I needed was a current state of play for AD Sites and Services. Unfortunately as my Security Clearance was still pending, I didnt have access to the domain so had to create a number of scripts to create the output so that it could be sent to me. Fortunately, I was able to find this gem below which was able to extract the name of each site, all subnets within each site as well as a list of each server!

[sourcecode language=”powershell”]

$Sites = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites
$obj = @()
foreach ($Site in $Sites) {

$obj += New-Object -Type PSObject -Property (
@{
"SiteName"  = $site.Name
"SubNets" = $site.Subnets -Join ";"
"Servers" = $Site.Servers -Join ";"
}
)
}
$obj | Export-Csv ‘C:\Scripts\Output\sites.csv’ -NoType

[/sourcecode]

Save the above code as ADSSDump.PS1, execute and enjoy!

More to come soon.

Comments

Leave a comment

Your email address will not be published.
Required fields are marked *