locked
bulk update proxy address, they are in one line RRS feed

  • Question

  • HI Experts,

    Proxy address of all my AD users are blank,  so I want to add proxy address in bulk

    i have a csv like following

    samAccountName userPrincipalName Emailaddress proxyaddresses
    li.er li.er@domain1.com li.er@domain1.com smtp:li.er@domain1.com SMTP:li.er@domain2.global smtp:li.er@domain3.com

    when i use the powershell:   Import-Csv "C:\users\UpdateUserProxyaddress.csv" | foreach {Set-ADUser -Identity $_.samAccountName -Add @{Proxyaddresses=$_.Proxyaddresses}}

    I get the following , the three smtp address are in on line

    but what i want is the following, they should be in three lines

    any ideas? what can i do ?

    thanks,

    jianggai

    Saturday, May 18, 2019 5:12 PM

Answers

  • It looks like the "Proxyaddresses" in your CSV are separated by a space or newline. If that's the case, a little modification to your script is needed:

    Import-Csv "C:\users\UpdateUserProxyaddress.csv" | 
        foreach {
            Set-ADUser -Identity $_.samAccountName -Add @{Proxyaddresses=($_.Proxyaddresses -split "\s+|\n")}
        }


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)



    Saturday, May 18, 2019 6:13 PM

All replies

  • You have to add them as an array and not as a single string.


    \_(ツ)_/

    Saturday, May 18, 2019 5:28 PM
  • It looks like the "Proxyaddresses" in your CSV are separated by a space or newline. If that's the case, a little modification to your script is needed:

    Import-Csv "C:\users\UpdateUserProxyaddress.csv" | 
        foreach {
            Set-ADUser -Identity $_.samAccountName -Add @{Proxyaddresses=($_.Proxyaddresses -split "\s+|\n")}
        }


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)



    Saturday, May 18, 2019 6:13 PM
  • thanks for your help.

    the value is not added manually

    i have a csv as below

    i use the powershell: Import-Csv "C:\users\UpdateUserProxyaddress.csv" | foreach {Set-ADUser -Identity $_.samAccountName -Add @{Proxyaddresses=$_.Proxyaddresses}} to add proxy address. but the three proxy address are in one line

    Saturday, May 18, 2019 6:17 PM
  • It looks like the "Proxyaddresses" in your CSV are separated by a space. If that's the case, a little modification to your script is needed:

    Import-Csv "C:\users\UpdateUserProxyaddress.csv" | 
        foreach {
            Set-ADUser -Identity $_.samAccountName -Add @{Proxyaddresses=($_.Proxyaddresses -split " ")}
        }


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Or a line break.


    \_(ツ)_/

    • Marked as answer by jianggai Saturday, May 18, 2019 6:48 PM
    • Unmarked as answer by jrv Saturday, May 18, 2019 6:56 PM
    Saturday, May 18, 2019 6:37 PM
  • Hard to say from the example. I fixed the -split to work with either space(s) or a newline.

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Saturday, May 18, 2019 6:47 PM
  • it works!!!   many many thanks. you are my rocket

    Regards,

    Sky

    Saturday, May 18, 2019 6:49 PM