Filtering Get-ADUser – weird behaviour

I just noticed really weird behaviuor in my script. First I import csv, then I iterate throug every row with foreach. And than I need to check if ou exists, so:

Get-ADOrganizationalUnit -Filter {PostalCode -eq $ou.ID} 

And it doesn’t work (can’t find ID object in “System.Management.Automation.PSCustomObject”). So I need to do something like this:

$code=$ou.ID Get-ADOrganizationalUnit -Filter {PostalCode -eq $code} 

And then it works. My question is simple: WTF?!

submitted by /u/svatevit
[link] [comments]

Leave a Reply