Solved

powershell display output

Posted on 2013-12-11
4
392 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
many thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Why would I want to create a function for tracking messages? I am glad you asked. As with most monotonous/routine tasks, human error tends to creep in after doing the same task over and over again. By creating a function, you load the function once…
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

7 Experts available now in Live!

Get 1:1 Help Now