[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Unable to get email address from Exchange 2007 powershell

I am preparing a report for getting the complete mailboxes in organization

I  need a report in the below format:

Server SG DB Recipienttype emailaddress
--------------------------------------------------------------------


Get-MailboxServer | Get-MailboxStatistics | select ServerName,StorageGroupName,DatabaseName,emailaddress*

Open in new window


Using the code i am getting only server,SG,DB,  email is blank

Can u help me with the powershell logic to get the output in the required format.
0
AhmedAliShaik
Asked:
AhmedAliShaik
  • 4
  • 3
  • 2
  • +2
4 Solutions
 
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
Get-Mailbox "UserName | FL
will give you output and then you can select the attributes you want

Get-Mailbox| Ft Database, StorageGroupName, Name, email*

- Rancy
0
 
AhmedAliShaikAuthor Commented:
Thanks Rancy,

I have tried it , but in Get-mailbox we dont have storagegroup also when i am giving emailaddress it is displaying all secondary addresses as well.

Thanks why i have checked with get-mailboxstatistics | fl and found server,sg,db

but email address is not in mailboxstatistics.

Plz suggest
0
 
Nagendra Pratap SinghCommented:
Try PrimarySmtpAddress to not show the secondary address
0
A Cyber Security RX to Protect Your Organization

Join us on December 13th for a webinar to learn how medical providers can defend against malware with a cyber security "Rx" that supports a healthy technology adoption plan for every healthcare organization.

 
AhmedAliShaikAuthor Commented:
Thanks npsingh,

I tried using PrimarySMTPaddress and getting the email.
The actual output i need is :

Server SG DB Recipienttype emailaddress

I am getting the ouput when i run the below command without using -autosize, but the emailaddrersses are getting ... in the end which is difficult for me to identify all addresses.

Any thing needs to be added. Please suggest.

Get-MailboxServer | get-mailbox | ft -autosize PrimarySMTPAddress,RecipientTypeDetails,customattribute6,@{label="Server";expression={(get-mailboxstatistics $_).serverName}},@{label="SG";expression={(get-mailboxstatistics $_).StorageGroupName}}

Open in new window

0
 
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
Firstly if you run the command for something like below ... does it gives you the Output as required if so its good :)

Get-Mailbox "UserName" | ft -autosize PrimarySMTPAddress,RecipientTypeDetails,customattribute6,@{label="Server";expression={(get-mailboxstatistics $_).serverName}},@{label="SG";expression={(get-mailboxstatistics $_).StorageGroupName}}

- Rancy
0
 
AhmedAliShaikAuthor Commented:
Thanks Rancy,

The -Autosize for this Cmdlet is not giving the result instantly, also getting warning to add result-size unlimited as i am running for the entire MB servers using Get-mailboxserver.

But finally after giving -Resultsize unlimited after 40 mins got a result using your Cmdlet.
0
 
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
WOW .... its a treat eyes closing after 19+ hrs :)

- Rancy
0
 
Rajitha ChimmaniCommented:
You can get the SG with get-mailbox cmdlet.

Just used some trick...the database name attribute gives the output as server\SG\Databasename, so we can get the SG from Databasename attribute itself.

Hope this helps with fast output

Get-MailboxServer | Get-Mailbox  -Resultsize unlimited| ft -autosize ServerName,@{label="SG";exp={$_.database.parent}},Database,recipienttypedetails,PrimarySmtpAddress
0
 
QlemoC++ DeveloperCommented:
Since the SG and DB contain full paths, I would rather shorten them to only display the names:
Get-MailboxServer | Get-Mailbox  -Resultsize unlimited |
  ft -autosize ServerName,
     @{label="SG"      ; exp={$_.Database.Parent.name}},
     @{label="Database"; exp={$_.Database.Name}},
     recipienttypedetails,
     PrimarySmtpAddress}},recipienttypedetails,PrimarySmtpAddress

Open in new window

0
 
AhmedAliShaikAuthor Commented:
I am a layman in powershell. Getting your expert comments are helping a lot to me. Right now i am not in a position to judge, as all the commands are working fine as expected.

Rajitha's & Qlemo's  commands are executing fast.

Thanks all.

As you are the experts please suggest me where to start learning powershell.
Any online trainings,CD's,Institutions,Books any thing. I am very eager to learn.

Please help me with your suggestions, i will never be a competitor to you all in my life .
0
 
QlemoC++ DeveloperCommented:
You can look here on EE for articles regardings PowerShell (there are some basic ones, like http://www.experts-exchange.com/A_3296-The-Absolute-Beginner's-Guide-to-Powershell.html ).
Mastering PowerShell is a free (PS1 based) eBook.
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

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