Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

powershell script help

Posted on 2016-09-13
5
Medium Priority
?
123 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 85

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 71

Expert Comment

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

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 85

Accepted Solution

by:
oBdA earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Loops Section Overview
Suggested Courses

782 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