Good Morning ,
I am confused …
There is a ADGroup that has members . (42)
I need to add all the members of specific ou’s (299)
I have a $users with a total of 299 objects
Also a $members with a total of 42 objects
When I compare the $users and $members I expect it to tell me the diference ( who is not a memeber )
To be sure I let powershell tell me the nr of objects of the comparison.
In my opinion that should me 299-42 = 257
Only Powershell tells me it is 261…Huh…
Now I want to know why… of course
Maybe something I forget or need to do on a different matter…?
$Users = @() $Users += Get-ADUser -Filter * -SearchBase $OUpathP01 -Properties MemberOf $Users += Get-ADUser -Filter * -SearchBase $OUpathFuj -Properties MemberOf $Users += Get-ADUser -Filter * -SearchBase $OUpathDel -Properties MemberOf $Samaccount = $users |select -Property SamAccountname #tel de $users Write-Host "Het totaalaantal gevonden accounts =" $Samaccount.count #Wie zijn al lid van de ADGroup , export naar variabele $Members = Get-ADGroupMember $Adgroup | select -Property SamAccountname Write-host $members.count "gebruikers zijn lid van de Adgroup $adgroup" $NonMembers = Compare-Object -ReferenceObject $Samaccount.SamAccountName -DifferenceObject $Members.SamAccountname | Where-Object { $_.Sideindicator -eq "="} | select InputObject Compare-Object -ReferenceObject $Samaccount.SamAccountName -DifferenceObject $Members.SamAccountname | select SideIndicator| Sort-Object SideIndicator -Unique