Link to home
Start Free TrialLog in
Avatar of Ron Shorts
Ron ShortsFlag for United States of America

asked on

Need help with Powershell Syntax for clearing proxyaddresses array

Need help with getting syntax to work... this works without "Line 6", where I'm clearing out all SIP entries from the proxyaddresses array before setting the next line.  Is this a syntax issue, or would I need to use in a separate function?


        Set-ADUser -Identity $User `
        -UserPrincipalName $SmtpAddres `
        -EmailAddress $SmtpAddress `
        -clear msRTCSIP-PrimaryHomeServer `
        -replace @{'msRTCSIP-PrimaryUserAddress'="SIP:$SmtpAddress";'msRTCSIP-UserEnabled'=$true"} `
        &{Get-ADUser $User -pr proxyaddresses | select -ExpandProperty proxyaddresses |? {$_ -cmatch '^SIP'}} | % {Set-ADUser -Identity $User -Remove @{proxyaddresses="$($_)"}}  `
        -Add @{proxyAddresses="SIP:$SmtpAddress"}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ron Shorts

ASKER

Fantastic!  Thank you!