Author Posts

August 16, 2017 at 12:18 pm

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.

August 16, 2017 at 1:02 pm

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

August 16, 2017 at 1:05 pm

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:*"}

August 16, 2017 at 1:30 pm

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.

August 16, 2017 at 1:57 pm

$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

August 16, 2017 at 2:08 pm

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

August 17, 2017 at 11:45 am

Thank you so much, that worked!!

I never thought clearing this would be so difficult.

August 17, 2017 at 11:54 am

Glad that worked 🙂