Solved

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

Posted on 2012-03-22
4
485 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
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…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now