Solved

Powershell Script to export AD user to a CSV file?

Posted on 2014-02-05
6
59,906 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 125 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 125 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 125 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 2

Assisted Solution

by:allen_rich
allen_rich earned 125 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

738 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