Need help with Exchange Shell command modification
I have an exchange shell command that I use to export the user name and email address of all of my users (who have a mailbox) to a CSV file. I am wondering if someone will help me modify it so that it excludes specific mailboxes. For example
if I wanted to exclude administrator, journal, webmaster, john, chuck, and bob, how would I do that? here is the command I use currently:
Get-Mailbox -resultsize unlimited | Select-Object displayname -expandproperty emailaddresses| Where-Object {$_.smtpaddress -like "*MyDomain.com*"}| Select-Object displayName,SmtpAddress| export-csv -path c:\UserEmails.csv -NoType
Also, this is not a big deal but if someone knows how I can modify it so that in the CSV it says Email Address instead of SmtpAddress that would be most helpful as well.
August 18th, 2010 10:22pm
On Wed, 18 Aug 2010 15:22:58 +0000, MnM Show wrote:
>
>
>I have an exchange shell command that I use to export the user name and email address of all of my users (who have a mailbox) to a CSV file. I am wondering if someone will help me modify it so that it excludes specific mailboxes. For example if I wanted
to exclude administrator, journal, webmaster, john, chuck, and bob, how would I do that? here is the command I use currently:
>
>Get-Mailbox -resultsize unlimited | Select-Object displayname -expandproperty emailaddresses| Where-Object {$_.smtpaddress -like "*MyDomain.com*"}| Select-Object displayName,SmtpAddress| export-csv -path c:\UserEmails.csv -NoType
Add "-filter {name -ne 'administrator' -and name -ne 'journal' -and
name -ne 'webmaster' etc.}" to the get-mailbox cmdlet.
>Also, this is not a big deal but if someone knows how I can modify it so that in the CSV it says Email Address instead of SmtpAddress that would be most helpful as well.
Replace "SmtpAddress" with this:
@{n='Email Address';e={$_.SmtpAddress}}
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
Free Windows Admin Tool Kit Click here and download it now
August 19th, 2010 3:37am
Hi MnM,
Any updates on your issue?Frank Wang
August 20th, 2010 3:44pm