Public/Clear-SkypeAttributes.ps1

Function Clear-SkypeAttributes {
    $AttributesToClear = @(
        'msRTCSIP-UserRoutingGroupId',
        'msRTCSIP-InternetAccessEnabled',
        'msRTCSIP-Line',
        'msRTCSIP-PrimaryHomeServer',
        'msRTCSIP-UserRoutingGroupId',
        'msRTCSIP-UserPolicies',
        'msRTCSIP-OwnerUrn',
        'msRTCSIP-PrimaryUserAddress',
        'msRTCSIP-GroupingID',
        'msRTCSIP-LineServer',
        'msRTCSIP-UserEnabled',
        'msRTCSIP-OptionFlags'
    )
    
    # Get all users & all
    $AllUsers = Get-ADUser -Filter * -Properties 'msRTCSIP-UserRoutingGroupId',
        'msRTCSIP-InternetAccessEnabled',
        'msRTCSIP-Line',
        'msRTCSIP-PrimaryHomeServer',
        'msRTCSIP-UserRoutingGroupId',
        'msRTCSIP-UserPolicies',
        'msRTCSIP-OwnerUrn',
        'msRTCSIP-PrimaryUserAddress',
        'msRTCSIP-GroupingID',
        'msRTCSIP-LineServer',
        'msRTCSIP-UserEnabled',
        'msRTCSIP-OptionFlags'

    # Clear all attributes except for msRTCSIP-DeploymentLocator
    Write-Output "======= Clear all attributes except for msRTCSIP-DeploymentLocator ======="
    $PreviousValues = @()
    $AllUsers |
        ForEach-Object {
            Write-Output "== $($_.SamAccountName) =="
            $PreviousValues += $User | Select-Object SamAccountName,DistinguishedName,"msRTCSIP*"
            Set-ADUser -Identity $_.SamAccountName -Clear $AttributesToClear -Verbose
        }

    # Set msRTCSIP-DeploymentLocator to sipfed.online.lync.com
    Write-Output "`n==== Set msRTCSIP-DeploymentLocator to sipfed.online.lync.com ====`n"
    $AllUsers | Where-Object {$_.'msRTCSIP-DeploymentLocator'} | Set-ADUser -Replace @{'msRTCSIP-DeploymentLocator' = "sipfed.online.lync.com"} -Verbose
}