hello,
i try to search for some users in AD - these users should be found only in some OU's so i make 3 different searches (i couldn't find other way to do this).
the problem is that for every search that didn't return a user "something" is returned and my array of ad users variable gets one more element (that is messing the later cod)
if no user is found in any of these OU's, my $aduser array will still have 3 elements. element type is unknown as gettype() return an error (You cannot call a method on a null-valued expression).
$adusers = @() $adusers += Get-ADUser -Filter {msRTCSIP-UserEnabled -notlike "*" } -SearchBase 'OU=Consultants,DC=local,,DC=intra' -SearchScope onelevel $adusers += Get-ADUser -Filter {msRTCSIP-UserEnabled -notlike "*" } -SearchBase 'OU=OFFICE USERS,DC=local,,DC=intra' -SearchScope onelevel $adusers += Get-ADUser -Filter {msRTCSIP-UserEnabled -notlike "*" } -SearchBase 'OU=Consultants-Extern,DC=local,DC=intra' -SearchScope onelevel
can i do something about this and get rid of those null (?) element ?
thanks,
Marius