Created
July 3, 2012 11:43
-
-
Save truekonrads/3039251 to your computer and use it in GitHub Desktop.
Counts the number of sites in each AD site link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$dEntry = New-Object DirectoryServices.DirectoryEntry("LDAP://xyz.com/cn=sites,cn=configuration,dc=xyz,dc=com","user1","Pass1"); | |
$searcher=New-Object DirectoryServices.DirectorySearcher($dEntry); | |
$searcher.Filter="(objectClass=siteLink)"; | |
$searcher.PropertiesToLoad.Add("siteList"); | |
$searcher.PropertiesToLoad.Add("cost"); | |
$searcher.PropertiesToLoad.Add("replInterval"); | |
$searcher.PropertiesToLoad.Add("cn"); | |
$searcher.FindAll() |%{ | |
$count=$_.Properties.sitelist.Count; | |
$p=@{"cn"=[string]$_.Properties.cn; "sites"=$count;}; | |
if ($count>2) { | |
$p["mesh"]=$count; | |
}else{ | |
$p["mesh"]=$count*$count; | |
} | |
New-Object psobject -Property $p | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment