RSS

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

http://blogs.msdn.com/b/adpowershell/archive/2009/08/18/active-directory-powershell-to-manage-sites-and-subnets-part-3-getting-site-and-subnets.aspx

#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
"CN=yousite,CN=Sites,CN=Configuration,DC=fabrika,DC=com"
 -properties *).siteObjectBL) 
{Get-ADObject -Identity $SubnetDN -properties * | % {$_.name} }

#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 10.190.2.3" 
Get-ADObject -Filter 'ObjectClass -eq "subnet" 
-and name -like "10.190.2.3*"' -SearchBase 
'CN=Configuration,DC=fabrika,DC=com' -properties siteobject
Advertisements
 
Leave a comment

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

 

Tags:

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: