[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Need export a list of users and emailadress within a DB on exchange 2010

Posted on 2012-03-22
Medium Priority
Last Modified: 2012-08-14
We run Exchange 2010 SP1 on Windows 2008 R2 server. We have 3 hub/cas and 3 db servers with exchange 2010. No other exchange servers in our system. The users in the database Im working on is linked to a user acocunts in another domain in another tree.

I need to make a list of all the users in a database with their displayname, alias, primarysmtpaddress and all their other mailaddresses.

I have tried several command without success.

Here is an example of what I have tried:

   Get-Mailbox -Database "dbname" | Select-Object alias, displayname, primarysmtpaddress

This command will list all the room mailboxes, and no users! Why will this not list the users?

I also tried what is mentioned in this article: http://unlockpowershell.wordpress.com/2010/01/27/powershell-get-mailbox-display-smtp-addresses/

Still no luck. Does anyone have a good string of command that wil list my users?
Question by:NAF-Data
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
  • 3

Expert Comment

ID: 37753203

You could use the script below :
1/ save it to a file name ExchangeReporting.ps1
2/ install PowerShell 2.0 on your mailbox server
3/ install ActiveRoles Management Shell for Active Directory from PowerQuest from here :
4/ start an Exchange Management Shell and run ./ExchangeReporting.ps1

# Requires :
# - PowerShell 2.0
# - ActiveRoles Management Shell for Active Directory (http://www.quest.com/powershell/activeroles-server.asp)

# Load ActiveRoles Management Shell for Active Directory
Add-PSSnapin Quest.ActiveRoles.ADManagement

# ***********************************
# *** Variables *********************

$strEOL = "`r`n"
$charCSVSep = ";"
$strCSVHeader = "COMPANY" + $charCSVSep + "NAME Firstname" + $charCSVSep + "Mail" + $charCSVSep + "Size (MB)"

# *** /Variables ********************
# ***********************************

# ***********************************
# *** Main **************************

$colMailboxStatistics = Get-MailboxStatistics

write-host $strCSVHeader

# Get user infos for each mailbox and store them in $colReporting
$colMailboxStatistics | ForEach-Object { 
	# Get user from AD
	$objUser = Get-QADUser -Identity $_.LegacyDN
	If ($objUser.samAccountName) {
		# Find if the mailbox is over limit
		$intMailboxSize = $_.TotalItemSize.Value.ToMB()
		If (!$objUser.Company) {
			$strCompany = "_NOT_SET_"
		} else {
			$strCompany = $objUser.Company
		# Prepare user info to store in hash $colReporting
		write-host $strCompany $charCSVSep $objUser.SN $objUser.givenName $charCSVSep $objUser.mail $charCSVSep $intMailboxSize

# *** /Main *************************
# ***********************************

Open in new window

Hope this helps !


Author Comment

ID: 37756175
Is there really no code within Exchange Management Shell that can export a list of the users with their email address?????

I tried this script you posted, I have installed ActiveRoles Management Shell. But I get these error messages:

[PS] C:\>.\ExchangeReporting.ps1
Add-PSSnapin : Cannot add Windows PowerShell snap-in Quest.ActiveRoles.ADManagement because it is already added. Verify
 the name of the snap-in and try again.
At C:\ExchangeReporting.ps1:6 char:13
+ Add-PSSnapin <<<<  Quest.ActiveRoles.ADManagement
    + CategoryInfo          : InvalidArgument: (Quest.ActiveRoles.ADManagement:String) [Add-PSSnapin], PSArgumentExcep
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand

The term 'Get-MailboxStatistics' is not recognized as the name of a cmdlet, function, script file, or operable program.
 Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\ExchangeReporting.ps1:22 char:46
+ $colMailboxStatistics = Get-MailboxStatistics <<<<
    + CategoryInfo          : ObjectNotFound: (Get-MailboxStatistics:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

COMPANY;NAME Firstname;Mail;Size (MB)
Get-QADUser : Cannot validate argument on parameter 'Identity'. The argument is null or empty. Supply an argument that
is not null or empty and then try the command again.
At C:\ExchangeReporting.ps1:29 char:34
+     $objUser = Get-QADUser -Identity <<<<  $_.LegacyDN
    + CategoryInfo          : InvalidData: (:) [Get-QADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlet

Accepted Solution

NAF-Data earned 0 total points
ID: 37756248
I just found that I could use EMC, I added another column, called "E-Mail Addresses". Then I used the export link on the right side of the EMC. Then I imported the txt file into Excel and sorted the list based on OU, and then removed all the users I didnt need.

I find it strange that I could not do this with a simple command in the EMS. But now I got the information I wanted.

Author Closing Comment

ID: 37775634

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

One-stop solution for Exchange Administrators to address all MS Exchange Server issues, which is known by the name of Stellar Exchange Toolkit.
Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
In this video we show how to create a Shared Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Sha…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

649 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