Solved

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

Posted on 2012-03-22
4
488 Views
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?
0
Comment
Question by:NAF-Data
  • 3
4 Comments
 
LVL 1

Expert Comment

by:snoopscratchy
ID: 37753203
Hello,

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 :
 http://www.quest.com/powershell/activeroles-server.asp
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 !

Yoann
0
 

Author Comment

by:NAF-Data
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
   tion
    + 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
   s.GetUserCmdlet
0
 

Accepted Solution

by:
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.
0
 

Author Closing Comment

by:NAF-Data
ID: 37775634
.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exchange 2013 certificate 8 39
Dynamic Distribution Group 4 24
Migrate Databases Exchange server 2013 to 2016 2 23
Exchange 2010 Send Connector 6 13
Read this checklist to learn more about the 15 things you should never include in an email signature.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
In this video we show how to create a User 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 >> Mailb…
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

832 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