Solved

powershell display output

Posted on 2013-12-11
4
393 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
  • 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

25 Experts available now in Live!

Get 1:1 Help Now