In Active Directory, I have "Ex Domain Users" folder including a bunch of folders. There are four folders having "Terminated" keyword that I need to retrieve the users from them.
In my powershell script, I do it like below:
$users = Get-ADUser -Filter * -SearchBase “OU=Terminated,OU=Ex Domain Users,DC=xxx,DC=local”;
$users += Get-ADUser -Filter * -SearchBase “OU=Terminated (ESA),OU=Ex Domain Users,DC=xxx,DC=local”;
$users += Get-ADUser -Filter * -SearchBase “OU=Terminated (Last week),OU=Ex Domain Users,DC=xxx,DC=local”;
$users += Get-ADUser -Filter * -SearchBase “OU=Terminated (Last month),OU=Ex Domain Users,DC=xxx,DC=local”;
I am looking for a way to say ... -Searchbase "OU in ('%Terminated%'), ...")
but I couldn't find the correct syntax or approach for it. Any help would be appreciated.
Regards.