[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 27886
  • Last Modified:

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.
0
CiscoAzn
Asked:
CiscoAzn
  • 5
  • 3
  • 2
  • +1
1 Solution
 
imkotteesCommented:
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
 
imkotteesCommented:
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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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
 
imkotteesCommented:
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
 
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

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now