Active Directory Sites and Services Script

I am looking for a way to complete a inventory of all properties in Active Directory Sites and Services and Export to Excel

Essentially I want the following data

SiteName,  Subnet, Server, Name of Server and IP address - Some sites have more than 1 server, and more than 1 subnet.

Also would like to get Site-Link for appropriate Site, and partner. with replication cost and interval

I have windows 2003 and Windows 2008 domain controllers.
Don't appear to have AD DS Web

I found a dsquery command, but it doesn't appear to work

dsquery site -o rdn -limit 0 > c:\folder\all.sites.txt
for /F %A in (c:\folder\all.sites.txt) do For /F %X in (‘dsquery subnet -site %A -o rdn’) do echo %A,%X >> c:\folder\sites.subnets.csv
for /F %A in (c:\folder\all.sites.txt) do For /F %X in (‘dsquery server -site %A -o rdn’) do echo %A,%X >> c:\folder\sites.Servers.csv
LVL 5
IndyrbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

becraigCommented:
Here is an example of what I think you need:
[cmdletbinding()]
param()

$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 'sites.csv' -NoType

Open in new window


Reprinted from:
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/c0e203ed-e146-4d0f-9c57-1ec263284ace/exporting-active-directory-sites-and-services-information-to-csv-file

If you need help to modify let me know.
0
Life1430Sr EngineerCommented:
If you are intrested in good tool then here it is ...

Microsoft Active Directory Topology Diagrammer  
http://www.microsoft.com/en-in/download/details.aspx?id=13380
0
becraigCommented:
This should do exactly what you need, simply plug in your text file value and go.

[cmdletbinding()]
param()
$sitelist = (gc sites.txt)
if (Test-path 'sites.csv')
{remove-item sites.csv -Force}
foreach ($site in $sitelist)
{
$Sites = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().Sites | where {$_.Name -eq $site}
$obj = @()
foreach ($Site in $Sites) {
$Sitename = $site.name 
$Subnets = $site.subnets
$server = $Site.servers
foreach($subnet in $subnets)
{
$obj +=
@"
$sitename, $server, $subnet
"@
}
$obj | out-file 'sites.csv'  -Append
}
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.