Created
October 12, 2016 23:11
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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