Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Powershell Script to export AD user to a CSV file?

Posted on 2014-02-05
6
Medium Priority
?
62,460 Views
3 Endorsements
Last Modified: 2015-12-28
Hi Experts,

Our service desk deleted a windows user 3 months ago. Now we need to restore the mailbox and I have no idea which database the mailbox was as the user is gone and we have no logs with AD user info.
I would like to find a powershell script that exports AD user account info like useraccount, exchange database, smtp address etc. Does anyone have one?

Things like:  objectClass,cn,displayName,givenName,initials,sn,mailNickname,title,department,physicalDeliveryOfficeName,streetAddress,postalcode,company,co,l,st,telephoneNumber,facsimileTelephoneNumber,mobile,mail,proxyAddresses,memberOf,msExchHomeServer,homemdb
3
Comment
Question by:osagarana
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 10

Assisted Solution

by:Pramod Ubhe
Pramod Ubhe earned 500 total points
ID: 39835295
Import-Module ActiveDirectory

Get-ADUser -filter * -properties employeeType,EmployeeID,GivenName,Surname,CN,Title,Manager,Department,Country,City,EmailAddress,LastLogonDate,Created -SearchBase "DC=domainname,DC=com" | select employeeType,EmployeeID,GivenName,Surname,CN,Title,Manager,Department,Country,City,EmailAddress,LastLogonDate,Created | ConvertTo-Csv | Out-File c:\output.csv


You can edit the values that you want.
0
 
LVL 31

Assisted Solution

by:LeeDerbyshire
LeeDerbyshire earned 500 total points
ID: 39835510
if you don't enjoy typing:

Import-Module ActiveDirectory
get-aduser -filter * -properties * | export-csv c:\whatever.txt

although you will probably get many more properties than you need :-)
0
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 500 total points
ID: 39835915
If you are looking to get AD properties and also Exchange Statistics (database/totyou will not be able to produce this with one command. Use the below commands to get the info you are looking for..

AD Attributes
Get-ADObject -filter 'objectclass -eq "user"' -properties * | select | export-csv -NoTypeInformation "c:\ADUsers.csv"

Open in new window


Exchange Statistics (which will get your other information you require database, mailbox size etc)
Get-Mailbox -Resultsize "Unlimited" | Get-MailboxStatistics | select | export-csv -NoTypeInformation "c:\MailboxStats.csv"

Open in new window


Will.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Assisted Solution

by:allen_rich
allen_rich earned 500 total points
ID: 39838365
The script is given below:

Get-QADUser -SizeLimit 0 `| select-Object SamAccountName,displayname,description `| Export-Csv "c:\folder\export.csv"

or

Get-ADUser -LDAPFilter "(&(!(sAMAccountName=EUR*))(!userAccountControl:1.2.840.113556.1.4.803:=2))" `
    -Properties sAMAccountName, givenName, sn, enabled | Select sAMAccountName, givenName, sn, enabled | `
    Export-Csv -Path c:\Scripts\Users.csv

Please also refer to the given below article to know more about command: get-asuser

http://technet.microsoft.com/en-us/library/ee617241.aspx
0
 
LVL 1

Author Closing Comment

by:osagarana
ID: 39838636
You guys are experts!  :-)
0
 
LVL 1

Expert Comment

by:SquigglyMonkey
ID: 41387522
CSVDE is another method to export all the AD info to a CSV file.
https://technet.microsoft.com/en-us/library/cc732101.aspx
0

Featured Post

Q2 2017 - Latest Malware & Internet Attacks

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out our latest Quarterly Internet Security Report!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
Want to know how to use Exchange Server Eseutil command? Go through this article as it gives you the know-how.
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question