-1

There are about 20 OU in AD. 6 of the OU has space in it. for example, "Department Heads", "Operation Managers". The following works all 15 OU where there are no space but doesn't work when there is a space in the OU description.

Any idea. I tried putting the string into "" but nothing helps.

$LdapServer = "FLEX01AD.COLGATE.FILA"
$SearchBase = "OU=Department Heads,DC=COLGATE,DC=FILA"
$LDAPResult = Get-ADUser -SearchBase $searchbase -SearchScope 'subtree' -Server $ldapserver -filter "employeeID="U99YBTTXR" -Properties * | Select -Property userAccountControl, whenChanged
Green Code
  • 189
  • 3
  • 14

1 Answers1

0

Actually, spaces in the OU is not the issue. I found the solution here

https://community.spiceworks.com/topic/2054880-powershell-count-unique-users-in-group-and-nested-group

this code worked for me

$LDAPResultCount = ($LDAPResult.userAccountControl | select -Unique).count
Green Code
  • 189
  • 3
  • 14