?
Solved

powershell display output

Posted on 2013-12-11
4
Medium Priority
?
405 Views
Last Modified: 2013-12-12
I am trying to get the email addresses for an exchange 2003 environment. I chose to use quest for this because they do not have powershell for 2010 or 2007.  Please help as I am trying to get this to output per below and the command I am using is fucntional just not providing the output I need, thanks

Get-qadobject -size 0 -searchroot Contoso.local/company |  where {$_.PrimarySMTPAddress -ne $null -and $_.proxyadd
resses -ne $null } | select primarysmtpaddress, @{name="proxyaddresses";expression={$_.proxyaddresses }}

primarysmtpaddress            proxyaddresses
somename@contoso.local            somename@contoso.local, smtp:sname@contoso.local, somen@contoso.local
somename1@contoso.local            somename1@contoso.local, smtp:sname1@contoso.local, somen1@contoso.local
somename2@contoso.local            somename2@contoso.local, smtp:sname2@contoso.local, somen2@contoso.local
somename3@contoso.local            somename3@contoso.local, smtp:sname3@contoso.local, somen3@contoso.local



Here is what I am looking for

primarysmtpaddress
somename@contoso.local
                        smtp:somename@contoso.local
                        smtp:sname@contoso.local
                        smtp:somen@contoso.local
somename1@contoso.local
                        smtp:somename1@contoso.local
                        smtp:sname1@contoso.local
                        smtp:somen1@contoso.local            
            
somename2@contoso.local
                        smtp:somename2@contoso.local
                        smtp:sname2@contoso.local
                        smtp:someno2@contoso.local
0
Comment
Question by:techdrive
[X]
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
  • 2
  • 2
4 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39711615
You just want to display it in PowerShell Console? Or want to save it in in that format in a text file?

You may try the result from following code and see if it works for you.. I think it will be easy for you to sort the list in this way..

Get-qadobject -size 0 -searchroot Contoso.local/company |  
 where {$_.PrimarySMTPAddress -ne $null -and $_.proxyaddresses -ne $null } | % {
 $primarysmtpaddress = $_.primarysmtpaddress
	$_.proxyaddresses | % {
		New-object PSObject -Property @{
		primarysmtpaddress = $primarysmtpaddress
		proxyaddresses = $_
		}
	}
}| Export-Csv C:\report.csv -NTI

Open in new window

0
 

Author Comment

by:techdrive
ID: 39714985
last question what if I wanted to add additional fields. Is there an easy way I tried and it failed.
0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 39715008
Ok..Try this example, you can add additional properties as i shown in this example..

Get-qadobject -size 0 -searchroot Contoso.local/company |  
 where {$_.PrimarySMTPAddress -ne $null -and $_.proxyaddresses -ne $null } | % {
 $user = $_
	$_.proxyaddresses | % {
		New-object PSObject -Property @{
		primarysmtpaddress = $user.primarysmtpaddress
		proxyaddresses = $_
		Displayname = $user.Displayname
		Alias = $user.Displayname
                Samaccountname = $user.samaccountname
		}
	}
}| Export-Csv C:\report.csv -NTI

Open in new window

0
 

Author Comment

by:techdrive
ID: 39715054
many thanks
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

800 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