Solved

powershell display output

Posted on 2013-12-11
4
398 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

839 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