Using Get-ADObject to query subnets and sites

29 Nov

Okay, I did not develop the scripts myself; I modified them from this site, I needed this for quick and easy queries

#List all subnets for a site (okay its a onliner, but you can always use a variable to replace the site name)

foreach ( $SubnetDN in (Get-ADObject -Identity
 -properties *).siteObjectBL) 
{Get-ADObject -Identity $SubnetDN -properties * | % {$} }

#List all subnets (long process)
Get-ADObject -Filter 'ObjectClass -eq "subnet"'
 -SearchBase 'CN=Configuration,DC=fabrika,DC=com'

#List all sites (long process)
Get-ADObject -Filter 'ObjectClass -eq "site"'
 -SearchBase 'CN=Configuration,DC=fabrika,DC=com'

 #List the site associated with a particular subnet" 
Get-ADObject -Filter 'ObjectClass -eq "subnet" 
-and name -like "*"' -SearchBase 
'CN=Configuration,DC=fabrika,DC=com' -properties siteobject
Leave a comment

Posted by on November 29, 2012 in Scripts, VBScripts, Windows



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: