I want to put the script listed on this page into Production.
In the commentary, the writer says "You could customize this search many ways. Two examples would be to target a specific organizational unit (OU) or maybe a set of accounts that match a name (such as admin accounts)."
I would like to have this script pull only from the Organizational Unit "Users-Groups/Users".
How can I have this line pull only from the Organizational Unit "Users-Groups/Users"?
Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False ‑and PasswordLastSet -gt 0}
Thanks for your help!
Get-ADUser : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'SearchBase'. Specified method is not supported.
$users = Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False ‑and PasswordLastSet -gt 0} -SearchBase "OU=Users,OU=Users-Groups,OU=*****org,DC=********,DC=org", `
Open in new window
This has examples for the search base:Get-ADUser
https://docs.microsoft.com/en-us/powershell/module/activedirectory/get-aduser?view=windowsserver2016-ps
If in doubt, you can always get the DN by using the ADUC console; enable the Advanced View, open the properties of the object, go to the "Attributes" tab, and check/copy the distinguishedName attribute.