Remove SIP address

Welcome Forums General PowerShell Q&A Remove SIP address

This topic contains 9 replies, has 2 voices, and was last updated by

 
Participant
1 year, 3 months ago.

  • Author
    Posts
  • #77362
    Jon

    Participant
    Points: 36
    Rank: Member

    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

    Participant
    Points: 34
    Rank: Member
    • #77367
      Jon

      Participant
      Points: 36
      Rank: Member

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

  • #77370
    Jon

    Participant
    Points: 36
    Rank: Member

    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

    Participant
    Points: 34
    Rank: Member
    • #77376
      Jon

      Participant
      Points: 36
      Rank: Member

      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
    Points: 36
    Rank: Member
    $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

    Participant
    Points: 34
    Rank: Member

    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
    Points: 36
    Rank: Member

    Thank you so much, that worked!!

    I never thought clearing this would be so difficult.

  • #77455

    Participant
    Points: 34
    Rank: Member

    Glad that worked 🙂

The topic ‘Remove SIP address’ is closed to new replies.