When we enable Teams for Skype for Business Hybrid users the final stage of action is to move the actual on premise Skype for Business Account to Office 365 to make them to Teams only mode. As more organization are adopting the Microsoft Teams in a full fast track approach the last stage of migration is to move all the local accounts to Teams Only Mode.
This script will help in moving the users on batches to Teams Only Mode from an input csv file. It also provides the time taken to complete the batch on screen once the migration is completed.
Example below:

Measure-Command { [CmdletBinding()] param( [string] $UsersList = $(Read-Host -prompt ` “Input the CSV File with Location”)) $Users = Import-Csv $UsersList -Delimiter ";" #To Connect to Teams, Skype Online Session and Import them. Make sure you have the new Teams Module installed. $mycred= Get-Credential Connect-MicrosoftTeams -Credential $mycred Import-Module MicrosoftTeams $sfbsession = New-CsOnlineSession Import-PSSession $sfbsession #Initialize parameters and variables. $sip= $users.SipAddress $count = $users.count write-host "We have found" $count "Users to Migrate" -foregroundcolor Yellow -backgroundcolor Black $pauseSeconds = 10 $Sleep = 20 Write-Host "Pausing for " $pauseSeconds " seconds to verify your count..." -ForegroundColor Yellow Start-Sleep -s $pauseSeconds #To Enable Logging and store them for failed migration and any errors. $transcriptname = “MoveCSUserStatus” + ` (Get-Date -format s).Replace(“:”,”-“) +”.txt” Start-Transcript $transcriptname #Take export of SFB enabled users before move. $Users | % {get-csuser -Identity $_.SipAddress} | Where-object {$_.Enabled -eq $True} | Select-object SamAccountName,sipaddress,Enabled,EnterpriseVoiceEnabled | Out-File SFBUsersBeforeMove.csv -append $URL= "https://adminof.online.lync.com/HostedMigration/hostedmigrationService.svc" #Initiate Move-CsUser Operation. $NewSession=0 $x=0 foreach ($user in $users) { $x++ Move-CsUser -Identity $user.SipAddress -Target sipfed.online.lync.com -HostedMigrationOverrideUrl $URL -UseOAuth -MoveToTeams -BypassAudioConferencingCheck -BypassEnterpriseVoiceCheck -Verbose -Confirm:$False $NewSession=$x/250 if($NewSession -eq 1) { get-pssession | remove-pssession Disconnect-MicrosoftTeams Connect-MicrosoftTeams -Credential $mycred Import-Module MicrosoftTeams $sfbsession = New-CsOnlineSession Import-PSSession $sfbsession $NewSession=0 $x=0 Write-Host "Refreshing the Skype online Session" -ForegroundColor Green } } #Pause for 20 seconds Start-Sleep -s $sleep #Validate the Move and complete Successfully Moved and Failed Users. $loop = foreach ($user in $users) { Get-CsOnlineUser -Identity $user.sipaddress | Select-object sipaddress,hostingprovider,TeamsUpgradeEffectiveMode,RegistrarPool} $loop| Out-File TeamsOnlyMigrationStatus.csv -append #Validate the meeting Migration status $loop = foreach ($user in $users) { Get-CsMeetingMigrationStatus -Identity $user.sipaddress | Select-Object UserPrincipalName,State,MigrationType,LastMessage,FailedMeetings} $loop| Out-File MeetingMigrationStatus.csv -append Stop-Transcript Write-Host "Migration Script Completed Please Refer Transcript File for any Errors" -ForegroundColor Green #Close the sessions. get-pssession | remove-pssession #Send Email report to Notify the Migration have completed - Mention your SMTP server #Send-MailMessage -from "username@domain.com" -to "admin@domain.com"-subject "TeamsOnlyMigrationTaskCompleted: No File" -body "Teams Only Migration Batch have been completed.Please refer log file Location for further information" -SmtpServer "Mention your SMTP Server" }
Notes:
- Make sure that you whitelist the traffic to office365 services to establish successful connection to the SFBO session.
- If there are multiple number of users recommended to split up the batches and execute them from 2 servers.
- Ensure the SSL traffic inspection, IP connection limits are excluded from Firewall/Proxy from the network side.
- Moving this from a shared bandwidth might be a bit slower and moving this from a temporary dedicated IP address might provide a better performance.
- This script uses -UseOauth switch. Make sure the Onpremise SFB servers are patched to the required version. Else use the legacy option by removing this switch. Recommended to run this first with few users list verify based on your environment and then later run for bulk users.
Regards
Sathish Veerapandian