jbla9028
asked on
Powershell question on Get-ADUser
I am modifying a script and running into an issue. I have to run get-aduser and query two seperate OUs. I can't seem to get the script to pass the info the my variable right for further processing. This is what I have thus far.
when I run, I get an error that states I am passing a string to the -searchbase arguement which is not allowed. How can I get the variable $results to have the query's filters above for 2 seperate OUs?
Thank you for the help!
#Declare Variables
$HitachiGroupDN = "CN=Hitachi-ID Exclude,OU=Security,OU=Groups,DC=company,DC=com"
$TestAccountsGroupDN= "CN= Test Accounts,OU=Security,OU=Groups,DC=company,DC=com"
$ServiceAccountsGroupDN= "CN= Service Accounts,OU=Security,OU=Groups,DC=company,DC=com"
$WombatExemptionGroupDN= "CN=Wombat Report Exemption,OU=Security,OU=Groups,DC=company,DC=com"
#Search Locations
$ou = "OU=San Diego,OU=company,DC=company,DC=com","OU=boston,OU=company,DC=company,DC=com"
$results = Get-ADUser -SearchBase $ou -Filter { memberof -ne $HitachiGroupDN -and memberof -ne $TestAccountsGroupDN -and memberof -ne $ServiceAccountsGroupDN -and memberof -ne $WombatExemptionGroupDN -and enabled -eq 'True'} -Properties mail,GivenName,sn,Department,WhenCreated
when I run, I get an error that states I am passing a string to the -searchbase arguement which is not allowed. How can I get the variable $results to have the query's filters above for 2 seperate OUs?
Thank you for the help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER