Skip to content

Instantly share code, notes, and snippets.

@jacksoneyton
Created October 12, 2016 23:11
Show Gist options
  • Save jacksoneyton/9cd187c67e50f8642c193668dc4a1f9c to your computer and use it in GitHub Desktop.
Save jacksoneyton/9cd187c67e50f8642c193668dc4a1f9c to your computer and use it in GitHub Desktop.
Update Skype User with New Email Address *Remove the "-whatif" tags to let the actions actually perform.
Import-Module MSOnline
Write-host "Please enter your Microsoft Office365 Administrative credentials:" -ForegroundColor Cyan
Connect-MsolService -Credential (Get-Credential)
$username = Read-Host "Please enter the users domain username"
$oldemail = Read-Host "please enter the users OLD email address"
$msoluser = get-msoluser -UserPrincipalName $oldemail
$user = get-aduser -identity $username -Properties mail,proxyAddresses
$samaccountname = $user.SamAccountName
$email = $user.mail
$userProxyAddresses = $user.proxyAddresses
$userStatus = $user.Enabled
if ($userStatus -eq "False")
{
Write-Host "The user specified is currently disabled, exiting script." -ForegroundColor Red
exit
}
Set-ADUser $user -replace @{'msRTCSIP-PrimaryUserAddress' = "SIP:$email"} -whatif
foreach ($proxyaddress in $userProxyAddresses)
{
if (($proxyaddress -like "*sip:*") -or ($proxyaddress -like "*SIP:*"))
{
Set-ADUser $user -remove @{proxyAddresses="$proxyaddress"} -whatif
}
}
Set-ADUser $user -Add @{proxyAddresses="SIP:$email"} -whatif
Set-MsolUserPrincipalName -NewUserPrincipalName "SMTP:$email" -UserPrincipalName $($msoluser.UserPrincipalName) -whatif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment