SOLVED

Output AD User Details as List

Iron Contributor

I'm trying to build a script that will let me list and add proxy addresses for users.

Right now I'm just trying to get it to list (as a list, not a string) the proxy address for a user:

 

#Define Target User
Write-Host ""
Write-Host "Enter the target username: " -ForegroundColor "Yellow" -NoNewLine
$username = Read-Host 

#List existing addresses
Get-ADUser -Identity $username -Properties proxyaddresses | Format-Table proxyaddresses -A

 

When I do this, the output is:

proxyaddresses                                                                          
--------------                                                                          
{SMTP:email address removed for privacy reasons, smtp:email address removed for privacy reasons, smtp:email address removed for privacy reasons}

I'm trying to get it to output like this:

proxyaddresses                                                                          
--------------                                                                          
SMTP:email address removed for privacy reasons
smtp:email address removed for privacy reasons
smtp:email address removed for privacy reasons

 

2 Replies
best response confirmed by xoxidein (Iron Contributor)
Solution

@xoxidein I changed your script a little bit:

 

#Define Target User
Write-Host "`nEnter the target username: " -ForegroundColor "Yellow" -NoNewLine
$username = Read-Host 

#List existing addresses
Get-ADUser -Identity $username -Properties proxyaddresses | Select-Object -ExpandProperty proxyaddresses

The `n does a new-line and instead of format-table I used Select-Object -ExpandProperty. Output is like this:
email address removed for privacy reasons
email address removed for privacy reasons
email address removed for privacy reasons

BINGO! Thank you @Harm_Veenstra
1 best response

Accepted Solutions
best response confirmed by xoxidein (Iron Contributor)
Solution

@xoxidein I changed your script a little bit:

 

#Define Target User
Write-Host "`nEnter the target username: " -ForegroundColor "Yellow" -NoNewLine
$username = Read-Host 

#List existing addresses
Get-ADUser -Identity $username -Properties proxyaddresses | Select-Object -ExpandProperty proxyaddresses

The `n does a new-line and instead of format-table I used Select-Object -ExpandProperty. Output is like this:
email address removed for privacy reasons
email address removed for privacy reasons
email address removed for privacy reasons

View solution in original post