This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Change/replace SIP address from the edsvaOffice365-UserID field

Ill start off by saying I am a complete novice

I would like to change user SIP address with the field edsvaOffice365-UserID

Id also like to be able to update this by OU if possible

I am using Quest Commandlet to pull this information. Get-QADUser -SearchRoot "OU=Path” -SizeLimit 0 -IncludedProperties edsvaOffice365-UserID

How would I script this to take the information in edsvaOffice365-UserID and update the SIP with it?

 

Thanks,

Manny

  • You are talking about the SIP address in the proxy address list?

    If yes,

    Get-QADUser -SearchRoot "OU=Path” -SizeLimit 0 -IncludedProperties edsvaOffice365-UserID | %{

    # Clean out the old SIP

    Remove-QADProxyAddress -Pattern "SIP*" -DirObject $_


    $NewSIP = "SIP:" + $($_.edsvaOffice365-UserID)

    # Put in the new one

    Add-QADProxyAddress -DirObject $_ -Address $NewSIP

    }

  • Hey Johnny, I appreciate the response. I am going to give this a shot. Thanks!
  • Hi Johnny, I am getting this error when i try and run the script.



    At line:8 char:30
    + $NewSIP = $($_.edsvaOffice365-UserID)
    + ~~~~~~~
    Unexpected token '-UserID' in expression or statement.
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken
  • Ah yes, the dreaded '-' (dash).

    You need to put single quotes around the attribute name because it has the dash in it.

    Example:

    $NewSIP = $($_.'edsvaOffice365-UserID')
  • Hey Johnny, Your awesome.. that worked like a champ but it didnt change the live communications SIP like i thought it would. So i also wanted to change the msRTCSIP-PrimaryUserAddress to also have the edsvaOffice365-UserID. How would i go about doing this? im guessing i use the same Set-ADUser Instead? Im sorry to keep bugging you. i appreciate the help
  • Yep.

    Just before the last }, add:

    Set-QADUser -identity $_ -objectattributes @{'msRTCSIP-PrimaryUserAddress'=$($_.'edsvaOffice365-UserID')}

    If you already ran the original, you can just remove the Remove.. and Add... lines I suppose.

    Question: Does the new SIP entry in the proxy addresses have the SIP prefix? If you look above in the thread you will note that I edited my original reply after and modified the "$NewSIP = ..." line to include this.
  • Hey Johnny, Thanks again for the help... the script completed successfully but i noticed the field msRTCSIP-PrimaryUserAddress is now empty for the test users i ran this on. Its like it removed the previous info but did not populate from edsvaOffice365-UserID as it should of. Not sure if this is what i was suppose to run but here is what i ran.


    Get-QADUser -SearchRoot "OU=Path” -SizeLimit 0 -IncludedProperties edsvaOffice365-UserID | %{

    # Clean out the old SIP
    Remove-QADProxyAddress -Pattern "SIP*" -DirObject $_


    $NewSIP = "SIP:" + $($_.'edsvaOffice365-UserID')

    # Put in the new one
    Add-QADProxyAddress -DirObject $_ -Address $NewSIP

    Set-QADUser -identity $_ -objectattributes @{'msRTCSIP-PrimaryUserAddress'=$($_.'edsvaOffice365-UserID')}
    }
  • Unless you are using the "Connect-QADService -proxy" command elsewhere and have not shown it, this script is targeting native Active Directory and there is no edsvaOffice365-UserID attribute.

    Try this:

    Connect-QADService -proxy

    Get-QADUser -SearchRoot "OU=Path” -SizeLimit 0 -IncludedProperties 'edsvaOffice365-UserID' | %{

    # Clean out the old SIP

    Remove-QADProxyAddress -Pattern "SIP*" -DirObject $_

    $NewSIP = "SIP:" + $($_.'edsvaOffice365-UserID')

    # Put in the new one

    Add-QADProxyAddress -DirObject $_ -Address $NewSIP

    Set-QADUser -identity $_ -objectattributes @{'msRTCSIP-PrimaryUserAddress'=$($_.'edsvaOffice365-UserID')}

    }

     

    Also, this type of simple search-and-replace operation could be performed in an Automation Workflow.

  • Terrance, that was it! Thank you very much Sir! Everything is now working as it should. I really appreciate the help. I will look into the search and replace also. I was handed off this project so i am still learning ARS and Powershell.
  • I'm glad to hear that it is now working as expected, but I feel bad. JohnnyQuest did all of the heavy lifting, I just swooped in and stole the credit...

    Sorry about that, JohnnyQuest!

    This is a good scripting learning opportunity, as well. It's good practice to confirm that you have data to replace something with before you destroy the original data.

    You should use something like this:

    Connect-QADService -proxy
    
    Get-QADUser -SearchRoot "OU=Path” -SizeLimit 0 -IncludedProperties 'edsvaOffice365-UserID' | %{
    
    # Clean out the old SIP
    
    if($_.'edsvaOffice365-UserID') #checks to see if some value exists in the attribute retrieved
    {
    Remove-QADProxyAddress -Pattern "SIP*" -DirObject $_
    
    $NewSIP = "SIP:" + $($_.'edsvaOffice365-UserID')
    
    # Put in the new one
    
    Add-QADProxyAddress -DirObject $_ -Address $NewSIP
    
    Set-QADUser -identity $_ -objectattributes @{'msRTCSIP-PrimaryUserAddress'=$($_.'edsvaOffice365-UserID')}
    
    else{
    #Log an error somewhere
    }
    
    }
    




    }