Hi,
I am trying to create a script for our HR Dept that will pull up a list of -properties and display them them for all users in a OU minus disabled accounts. (the disabled accounts is not required as we usually move disabled users to another OU but would be nice to add if its simple and does not cause issues with the script).
So far I have the following:
-------------------------------------------
Get-ADUser -Properties DisplayName,EmailAddress,department,manager -Filter 'name -like "*"' -searchbase "ou=canada,ou=americas,OU=main,dc=test,dc=net,dc=int"
Department : Sales
DisplayName : john doe
DistinguishedName : CN=john.doe,OU=Users,OU=woodsville,OU=Canada,OU=AMERICAS,OU=MAIN,DC=test,DC=NET,DC=INT
EmailAddress : john.doe@test.com
Enabled : True
GivenName : john
Manager : CN=jane doe,OU=Users,OU=smallville,OU=USA,OU=AMERICAS,OU=MAIN,DC=test,DC=NET,DC=INT
Name : john.doe
ObjectClass : user
ObjectGUID : xxxxxxxxxxxxxxxxxxxxxxx
SamAccountName : john.doe
SID : xxxxxxxxxxxxxxxx
Surname : doe
UserPrincipalName : john.doe@test.com
-------------------------------------------
Issues I am having:
1. I cannot get job title, country/region to work and I get error when I add those. I tried qoutes but maybe in the wrong place? I need those added to the script.
2. is there a way to get rid of the other fields so it only shows the fields I am asking for?
3. can I add a line that will exclude disabled users should any accidentally be in the OU I am running this against?
4. right now I am writing this to run on one OU, then I would change the OU to the next OU and run it. Is there a way I can put all the OU in the same script so that I run this script once and it will pull the users from say 10 different OU and
output that info?
any help would be appreciated as I am still learning PS and a babe in this field compared to many.
Thanks,