Help with counting the total number of servers objects from mutliple AD OU's
hello
i'm using following in script search servers. i'd total number of server objects finds. below number each ou....so how total?
thanks
add-pssnapin quest.activeroles.admanagement $sites = [ordered]@{ "site1" = "onelevel" "site2" = "onelevel" "domain controllers" = "subtree" } $sites.getenumerator() | foreach { $root = $_.key $scope = $_.value $ous = get-qadobject -type "organizationalunit" -searchroot "ou=$root,dc=my,dc=domain,dc=com" -searchscope $scope foreach ($ou in $ous) { $servers = get-qadcomputer -dontusedefaultincludedproperties -sizelimit 0 -searchroot $ou.dn -searchscope subtree | ?{$_.osname -like "*server*"} | measure-object -sum ($servers).count } }
$totalcount = 0 $sites.getenumerator() | foreach { $root = $_.key $scope = $_.value $ous = get-qadobject -type "organizationalunit" -searchroot "ou=$root,dc=my,dc=domain,dc=com" -searchscope $scope foreach ($ou in $ous) { $servers = get-qadcomputer -dontusedefaultincludedproperties -sizelimit 0 -searchroot $ou.dn -searchscope subtree | ?{$_.osname -like "*server*"} $totalcount += $servers.count } } $totalcount
Windows Server > Windows PowerShell
Comments
Post a Comment