Exclude smtp word

Get-ADUser -Filter * -SearchBase '<OU-Location>' -Properties proxyaddresses | Select-Object Name, @{ L = "ProxyAddresses"; E = { $_.ProxyAddresses -join ";" | Where-Object { ProxyAddresses -eq "*smtp:*" } } } | Export-Csv -Path "<Path>" –NoTypeInformation

Hello all,

I am new to powershell and i was working on extracting user proxy addresses values from AD without smtp populated. i.e., with above code, i can get the smtp addresses removing x400 and x509 values. however, i would also need to remove SMPT/smtp word and would require only user@xyc.com;user2@abc.com,....

Any help on this would be highly appreciated.



Parents Reply
  • , Hello..!! 

    I am working on developing a script that actually sucks ProxyAddresses data attribute from AD and then transform it into a value.( lets call it "A"). Now, on the same script, by using for loop, can i update a custom attribute called emailAlias with "A" value? If so, please help me with building a logic. 

    Since, i am new, i achieved above requirement by using 2 PS scripts, one to transform/export into CSV file. Second, Import same CSV file and update attributes. However, i am looking both transforming attribute value and populating same to custom attribute "emailAlias" should be done parallel within same script. with that being said, Get ADUser and Set ADUser on same source of code. 

    Thanks in advance...!! 

    Here is the code for Get AD User :

    Get-ADUser <User ID> -Properties ProxyAddresses | select Name,@{L="ProxyAddresses";E={($_.ProxyAddresses | Where {$_ -like "*smtp:*"}) -join ";" -ireplace "smtp:",""}}



No Data