Exchange powershell script to list Mailbox size, Alias, email, first name, last name and to pull this from an OU location

I have over 20 sites and need to pull data from each individual OU with data such as First Name, Last Name, displayName, email address, Alias, mailbox size, and mailbox count.
CiscoAznAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

imkotteesSenior Messaging EngineerCommented:
Hi,

This should help you

Get-Mailbox -OrganizationalUnit "YourOUName" | Get-MailboxStatistics | ft displayName,TotalItemSize -Autosize
0
CiscoAznAuthor Commented:
The problem is I need the mail "alias" or mailNickName which I cannot seem to pull.
0
imkotteesSenior Messaging EngineerCommented:
Get-MailboxStatistics won't give you the alias details.

You can run a separate command Get-Mailbox -OrganizationalUnit "YourOUName" | FT Alias to get the same

Later you can use excel to put them together.
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

CiscoAznAuthor Commented:
It gives me the half of the data. What would be the command to export to csv with data for the first name, last name, primary smtp as well?
0
imkotteesSenior Messaging EngineerCommented:
here you go...

http://blogs.technet.com/b/evand/archive/2006/10/17/bringing-users-and-mailboxes-together.aspx

If you want to even easier way to do this... open EMC --> Recipient Configuration --> Mailbox --> Go to View and chick on Add/Remove Columns --> Choose whatever field you want --> Ok --> Right click on Mailbox in Recipient Configuration --> Export List --> Save as CSV --> Ok

You can change Maximum number of recipients to display count in action pane.
0
SubsunCommented:
Try following code, it should give the required report.. replace Domain.com/HQ/Users with your OU and run the code from EMS.
$(Foreach ($mailbox in Get-Recipient -ResultSize Unlimited -OrganizationalUnit Domain.com/HQ/Users -RecipientType UserMailbox){
$Stat = $mailbox | Get-MailboxStatistics | Select TotalItemSize,ItemCount
	New-Object PSObject -Property @{
	FirstName = $mailbox.FirstName
	LastName = $mailbox.LastName
	DisplayName = $mailbox.DisplayName
	TotalItemSize = $Stat.TotalItemSize
	ItemCount = $Stat.ItemCount
	PrimarySmtpAddress = $mailbox.PrimarySmtpAddress
	Alias = $mailbox.Alias
	}
}) | Select FirstName,LastName,DisplayName,TotalItemSize,ItemCount,PrimarySmtpAddress,Alias | 
Export-CSV C:\MailboxReport.csv -NTI

Open in new window

3

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CiscoAznAuthor Commented:
I'm getting an error when I replace w/my OU info. Error is below.

Cannot process argument transformation on parameter 'OrganizationalUnit'. Cannot convert the "System.Collections.ArrayL
ist" value of type "System.Collections.ArrayList" to type "Microsoft.Exchange.Configuration.Tasks.OrganizationalUnitIdP
arameter".
    + CategoryInfo          : InvalidData: (:) [Get-Recipient], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-Recipient
0
SubsunCommented:
The syntax may not be correct, what did you type? can you post it?  You can also use the DN of the OU.
-OrganizationalUnit "OU=Sales,DC=Fabrikam,DC=COM"

Open in new window

0
CiscoAznAuthor Commented:
Arrrrgh!! I forgot the quotes around the OU. This works perfectly!
0
CiscoAznAuthor Commented:
This is what I needed. Thank you so much!!
0
Bidyadhar RathCommented:
Hi,
How to get mailbox name ,database name and size of each mail box.(In one command)
I tried the command combination with  Get-MailboxStatistics and Get-Mailbox.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.