The output I would like to see is a specified range (number) of computers that exist within OUs. I have most of my code written and it is working great, but I want to be able to choose what values I want to display. For instance, I don’t want to see 0 values. Perhaps I only want to see the OUs that have between 10 to 20 computers in them.
The reason I am not using Get-ADComputer is because I am not using this script to find JUST computer objects. I am using it to also find Group, Organizational Unit, and User objects as well.
For instance, this code here works perfect, but I simply want to be able to choose a range, or a starting value so I can determine what values I want displayed:
$Object = "Computer"
$BaseOU = "OU=My,DC=test,DC=domain"
$OUProps = Get-ADObject -Filter 'ObjectCategory -eq "OrganizationalUnit"' -SearchBase $BaseOU -Properties CanonicalName, DistinguishedName, Name
$GetCount = Foreach ($OUDN in $OUProps.DistinguishedName)
(Get-ADObject -Filter 'ObjectCategory -eq $Object' -SearchBase $OUDN).Count