Janice Valencia
asked on
Active Directory Powershell Script
Powershell Script to import to a csv file users -> Lastname, Firstname, Windows logon ID, PhoneID from a specific OU (Customer Service)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Im getting this error: I am a newbie in AD powershell. Im sorry.
Get-ADUser : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'SearchBase'. \
Specified method is not supported
Get-ADUser : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'SearchBase'. \
Specified method is not supported
Then you have more than one "Customer Services" OU.
You could set $Searchbase directly to the DistinguishedName of the one you want, or do you want all of them?
You could set $Searchbase directly to the DistinguishedName of the one you want, or do you want all of them?
EXPERT CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello, still gets object error. I am sure there is only one PSR OU and it exists.
domain name=abc.net
OU is like this: Windows7 > Windows7 Users > PSR
Please help. Thank you.
domain name=abc.net
OU is like this: Windows7 > Windows7 Users > PSR
Please help. Thank you.
ASKER
@ Shaun:
I tried Get-ADUser -filter * -Searchbase "OU=Customer Services,DC=Domain,DC=COM" -Properties Telephonenumber|Select sn, givenName,sAMAccountName, telephonenumber|Export-CSV -NoTypeInformation -Path C:\Temp\Export.csv
Changing the domain to ours dc=net and OU to PSR. But giving Directory object not found :(
I tried Get-ADUser -filter * -Searchbase "OU=Customer Services,DC=Domain,DC=COM"
Changing the domain to ours dc=net and OU to PSR. But giving Directory object not found :(
ASKER
Hello. I get it right this time :) Thank you all for the support.
I used: Shaun Vermaak's script:
Get-ADUser -filter * -Searchbase "OU=Customer Services,DC=Domain,DC=COM" -Properties Telephonenumber|Select sn, givenName,sAMAccountName, telephonenumber|Export-CSV -NoTypeInformation -Path C:\Temp\Export.csv
I did this to get th correct OU: 1. open Active Directory Users and Computers, enable Advanced Features in the menu, open the OU properties, go to Attribute Editor and open distinguishedName property and Select the OU distinguished name, copy/paste it to the above Get-ADUser command.
All good. Thank you all.
I used: Shaun Vermaak's script:
Get-ADUser -filter * -Searchbase "OU=Customer Services,DC=Domain,DC=COM"
I did this to get th correct OU: 1. open Active Directory Users and Computers, enable Advanced Features in the menu, open the OU properties, go to Attribute Editor and open distinguishedName property and Select the OU distinguished name, copy/paste it to the above Get-ADUser command.
All good. Thank you all.
ASKER
Thank you
Open in new window