Forum Discussion
Robert Bollinger
Jul 18, 2018Iron Contributor
Script to select users from specific OUs and with Specific Department codes.
Hey Team, I would like to do the following: 1) Search 5 separate OUs 2) Select All users from those OUs with a specific Department code - DepartmnetCode looks like 123456 (4-7 numbers, all i...
Jul 22, 2018
What you need to look at is Where-Object.
You could do something like this:
Get-ADUser -SearchBase -Filter * -SearchBase $ous | Where-Object {$departmentcode -contains $_.department -and $Cities -contains $_.City}