Remove SIP address

Trying to clear out an old sip address that was left around from an OCS setup we had. I’ve identified the users who have the SIP address with this:

 get-aduser -Properties * -Filter * | where ProxyAddresses -like "sip:*domain.local" | select samaccountname

However I can’t seem to clear the SIP. For example:

Get-ADuser proxytest -Properties proxyAddresses | Set-ADUser -remove @{proxyaddresses="sip:*domain.local"}

Also tried:

Get-ADuser proxytest -Properties proxyAddresses | Set-ADUser -remove @{proxyaddresses="sip:*"}

It never clears sip address.

This may help you

https://technet.microsoft.com/en-us/library/jj662761(v=exchg.150).aspx

I tried that and it doesn’t work. The sip is not always position 0.

Also for whatever reason this doesn’t work either. I can set values to other attributes, but for whatever reason you can’t tab out proxyaddresses like you can office,phone or manager etc

Get-ADuser proxytest -Properties proxyAddresses | Set-ADUser -ProxyAddresses @{Remove="sip:*"}

this may do it

Our email accounts are in O365 so I can’t use the get-mailbox cmdlets, I’m substituting with get-aduser…

$user = get-aduser proxytest -properties proxyaddresses
$proxy = $User.proxyaddresses | sls "sip"
$user.remove($proxy)

returns this error:
Method invocation failed because [Microsoft.ActiveDirectory.Management.ADUser] does not contain a method named ‘remove’.

The where $_.prefixstring in the code he used as an example returns nothing which is why I used sls to get the sip.

$user = get-aduser proxytest -properties proxyaddresses
$proxies = $user.proxyaddresses
$sip = $proxies | sls "sip"
set-aduser $user -Remove @{proxyaddresses=$sip}

Returns:
set-aduser : Invalid type ‘Microsoft.PowerShell.Commands.MatchInfo’.
Parameter name: proxyaddresses
At line:4 char:1

  • set-aduser $user -Remove @{proxyaddresses=$sip}
  •   + CategoryInfo          : InvalidArgument: (CN=proxytest,...,DC=blah,DC=blah:ADUser) [Set-ADUser], ArgumentException
      + FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.ArgumentException,Microsoft.ActiveDirectory.Management.Commands.SetADUse

Similar to what you have but try this

Get-ADUser proxytest -prop proxyaddresses | % {
$pr = $.proxyaddresses -like “SIP*”
Set-ADUser $
-Remove @{proxyaddresses=$pr}
}

It should remove all SIP addresses for the user

Thank you so much, that worked!!

I never thought clearing this would be so difficult.

Glad that worked :slight_smile: