Solved

powershell script help

Posted on 2016-09-13
5
95 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
[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
  • 3
5 Comments
 
LVL 84

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 70

Expert Comment

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

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 84

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LDAP Setup 6 57
script to trace the email in Office365 4 40
DNS Record Manupluation 11 33
Office 365 Group Expiration using PowerShell 3 9
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
A hard and fast method for reducing Active Directory Administrators members.
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)
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…

738 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