Forum Discussion

xoxidein's avatar
xoxidein
Iron Contributor
Jul 15, 2022

Output AD User Details as List

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

 

  • 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

  • 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

Resources