Remove SIP address

This topic contains 9 replies, has 2 voices, and was last updated by  Simon B 4 months ago.

  • Author
    Posts
  • #77362

    Jon
    Participant

    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.

  • #77365

    Simon B
    Participant
    • #77367

      Jon
      Participant

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

  • #77370

    Jon
    Participant

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

    Simon B
    Participant
    • #77376

      Jon
      Participant

      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.

  • #77382

    Jon
    Participant
    $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

  • #77385

    Simon B
    Participant

    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

  • #77452

    Jon
    Participant

    Thank you so much, that worked!!

    I never thought clearing this would be so difficult.

  • #77455

    Simon B
    Participant

    Glad that worked 🙂

You must be logged in to reply to this topic.