Answered by:
PowerShell for User Information

Question
-
Hello,
Is there a PowerShell Script available that will export to a cvs to display user information like the users name into two different columns example: Firstname in one column and last name in next column and show email address, and office location from Active Directory?
Thanks
- Moved by Bill_Stewart Thursday, April 23, 2015 2:31 PM Unanswerable drive-by question
Friday, March 20, 2015 1:42 PM
Answers
-
Get-ADUser -Filter '*' -Properties givenName,sn,mail,office | select givenName,sn,mail,office | Export-Csv 'C:\export.csv' -NoTypeInformation
Raf Delgado
- Proposed as answer by Raf Delgado Friday, May 22, 2015 3:57 AM
- Marked as answer by Just Karl Friday, May 29, 2015 9:19 PM
Friday, March 20, 2015 7:14 PM -
I really appreciate your help but how would the script look? I'm confused.
Something like this:
Get-ADUser -Filter * -Properties EmailAddress,Office | Select-Object GivenName,Surname,EmailAddress,Office | Export-Csv .\userDetails.csv -NoTypeInformation
You may want to look at the -SearchBase parameter of Get-ADUser to target this to individual OUs.
EDIT: Ah, I see I'm slow on the submit button. See Raf's post above.
Don't retire TechNet! - (Don't give up yet - 13,225+ strong and growing)
- Edited by Mike Laughlin Friday, March 20, 2015 7:24 PM
- Proposed as answer by Just Karl Friday, May 22, 2015 7:47 PM
- Marked as answer by Just Karl Friday, May 29, 2015 9:19 PM
Friday, March 20, 2015 7:24 PM
All replies
-
Hi,
Prewritten scripts can be found in the repository here:
http://gallery.technet.microsoft.com/scriptcenter
If you'd like to try this yourself, you can use Get-ADUser to get your information and Export-Csv to create an output file:
http://ss64.com/ps/get-aduser.html
http://ss64.com/ps/export-csv.html
Let us know if you have any specific questions.
EDIT: You'll also need Select-Object:
http://ss64.com/ps/select-object.html
Don't retire TechNet! - (Don't give up yet - 13,225+ strong and growing)
- Edited by Mike Laughlin Friday, March 20, 2015 1:52 PM
Friday, March 20, 2015 1:51 PM -
But is there one that will show two columns like
Firstname field Lastname field EmailAddress field Location field
Joe Doe EmailAddress Location
Thanks
Friday, March 20, 2015 6:07 PM -
Yes, you can get that output. Firstname is called 'GivenName' and Lastname is called 'Surname'.
Don't retire TechNet! - (Don't give up yet - 13,225+ strong and growing)
Friday, March 20, 2015 6:10 PM -
I really appreciate your help but how would the script look? I'm confused.Friday, March 20, 2015 7:05 PM
-
Get-ADUser -Filter '*' -Properties givenName,sn,mail,office | select givenName,sn,mail,office | Export-Csv 'C:\export.csv' -NoTypeInformation
Raf Delgado
- Proposed as answer by Raf Delgado Friday, May 22, 2015 3:57 AM
- Marked as answer by Just Karl Friday, May 29, 2015 9:19 PM
Friday, March 20, 2015 7:14 PM -
I really appreciate your help but how would the script look? I'm confused.
Something like this:
Get-ADUser -Filter * -Properties EmailAddress,Office | Select-Object GivenName,Surname,EmailAddress,Office | Export-Csv .\userDetails.csv -NoTypeInformation
You may want to look at the -SearchBase parameter of Get-ADUser to target this to individual OUs.
EDIT: Ah, I see I'm slow on the submit button. See Raf's post above.
Don't retire TechNet! - (Don't give up yet - 13,225+ strong and growing)
- Edited by Mike Laughlin Friday, March 20, 2015 7:24 PM
- Proposed as answer by Just Karl Friday, May 22, 2015 7:47 PM
- Marked as answer by Just Karl Friday, May 29, 2015 9:19 PM
Friday, March 20, 2015 7:24 PM