Solved

powershell script help

Posted on 2016-09-13
5
56 Views
Last Modified: 2016-09-14
any ideas on the below?

Get-ADUser -filter * -Properties DisplayName, EmailAddress, proxyAddresses, distinguishedName | select DisplayName, EmailAddress, proxyAddresses, distinguishedName | export-csv c:\temp\Email.csv –NoTypeInformation

i get the below in the export it has to do with multivalued attributes

proxyAddresses
Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
0
Comment
Question by:Jorge Ocampo
  • 3
5 Comments
 
LVL 83

Expert Comment

by:oBdA
ID: 41796774
Try it like this:
Get-ADUser -filter * -Properties DisplayName, EmailAddress, proxyAddresses, distinguishedName | select DisplayName, EmailAddress, @{n='proxyAddresses'; e={$_.proxyAddresses -join ', '}}, distinguishedName | export-csv c:\temp\Email.csv –NoTypeInformation

Open in new window

0
 
LVL 68

Expert Comment

by:Qlemo
ID: 41796800
oBdA, your carriage return broken? :p
0
 
LVL 83

Expert Comment

by:oBdA
ID: 41796827
Ah, less than 255 chars, that's barely over two lines in the default PS console ...
Get-ADUser -Filter * -Properties DisplayName, EmailAddress, ProxyAddresses, DistinguishedName |
	Select-Object -Property `
		DisplayName,
		EmailAddress,
		@{Name='ProxyAddresses'; Expression={$_.ProxyAddresses -join ', '}},
		DistinguishedName |
	Export-Csv -Path C:\temp\Email.csv –NoTypeInformation

Open in new window

0
 
LVL 2

Author Comment

by:Jorge Ocampo
ID: 41796858
@oBdA

didnt have any issues but is there a possible way to only get the primarysmtp "SMTP"
0
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 41796903
Sure:
Get-ADUser -Filter * -Properties DisplayName, EmailAddress, ProxyAddresses, DistinguishedName |
	Select-Object -Property `
		DisplayName,
		EmailAddress,
		@{Name='PrimarySmtp'; Expression={(($_.ProxyAddresses | ? {$_ -clike 'SMTP:*'}) -split ':')[1]}},
		DistinguishedName |
	Export-Csv -Path C:\temp\Email.csv –NoTypeInformation 

Open in new window


Edit: renamed calculated property "ProxyAddresses" to "PrimarySmtp" for more clarity.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Set OWA language and time zone in Exchange for individuals, all users or per database.
In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

706 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

12 Experts available now in Live!

Get 1:1 Help Now