top of page
Search
  • Writer's picturesamanthaeasterday

How To Move Users In Bulk From OnPremises Skype To TeamsOnly With Powershell


I've read many blogs on how to move users to TeamsOnly. But I wasn't able to find what I needed. So onto making my own script. I love opportunities like this! A little challenging, a lot of testing and some googling (Bing actually ;).

Environment:

SfB 2015 onprem

Enterprise voice enabled

Teams deployed

Islands mode

Exchange onprem (till next year)


I started with installing the Teams module. You will need this access to complete the steps. You'll also need Skype for Business PowerShell commands, so I started a new PSSession to our Skype server. I put in my admin credentials directly on the script. Not recommended...well in any scenario. However, I made an exception here since it's on a secure server.


In all the blogs I read, I rarely found anyone mention disabling UM in Exchange. Probably because we are the unicorn with Exchange OnPrem and moving to Teams. But that will soon change. So I imported a PSSession for Exchange as well.


Then set your parameters and variables. Pretty basic here.

The next couple of commands are for communication and pauses. I read the pauses help M365 to move along. Can't hurt!


I put my Import-Csv here. Then I disabled the UM first with a simple Get-UMMailbox and piping to Disable-UMMailbox.


The next line is forcing PowerShell to use tls1.2. In our environment, we have an issue with tls1.0 being blocked, so forcing it to use tls1.2 was easy enough.

Then I went into Move-CSUser. There is a lot of documentation on this command.

One thing to note, I did include -BypassAudioConferencingCheck and -BypassEnterpriseVoiceCheck. These are recommended if all your users don't have AC and/or EV.


Then we move onto validation and alerting. These commands create .txt files to give you failures and successes.


You'll want to close the session, once you're done. Best practice.


Then finally send yourself an email letting you know the batch is complete.


Happy Scripting!


Copy and paste starting here:


Measure-Command {

[CmdletBinding()]


#To Connect to Teams. Make sure you have the new Teams Module installed.


Install-Module -Name PowerShellGet -Force -AllowClobber

Install-Module -Name MicrosoftTeams -Force -AllowClobber

Connect-MicrosoftTeams


#To Connect to Skype for Business. Make sure you connect to a New-PSSession


$admin="admin";

$pwd = "adminpwd";

$securepwd = ConvertTo-SecureString $pwd -AsPlainText -Force;

$cred = New-Object Management.Automation.PSCredential ($admin.Replace('sip:', ''), $securepwd);

$UserCredential = $cred

$Session = New-PSSession -Credential $UserCredential -ConnectionUri https://server.domain.com/ocspowershell -AllowRedirection

Import-PSSession -AllowClobber $Session


#To Connect to OnPremises Exchange to disable UM. Make sure you connect New-PSSession


$admin="admin";

$pwd = "adminpwd";

$securepwd = ConvertTo-SecureString $pwd -AsPlainText -Force;

$cred = New-Object Management.Automation.PSCredential ($admin.Replace('sip:', ''), $securepwd);

$UserCredential = $cred

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://server.domain.com/PowerShell/ -Authentication Kerberos -Credential $UserCredential

Import-PSSession -AllowClobber $Session -DisableNameChecking

}


#Initialize parameters and variables.


$sip = $users.SipAddress

$user = $sipaddress

$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


#Initiate Move-CsUser Operation.


$Users = Import-Csv -Path C:\sipaddress.csv

foreach ($user in $users) {

Get-UMMailbox -Identity $user.sipaddress | Disable-UMMailbox -Confirm:$false

}


[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$Users = Import-Csv -Path C:\sipaddress.csv

foreach ($user in $users) {

Move-CsUser -Identity $user.sipaddress -Target sipfed.online.lync.com -UseOAuth -BypassAudioConferencingCheck -BypassEnterpriseVoiceCheck -Confirm:$false

}


#Pause for 10 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.txt -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 "email@domain.com" -To "email@domain.com"-subject "TeamsOnlyMigrationTaskCompleted: No File" -body "Teams Only Migration Batch have been completed" -SmtpServer server.domain.com




467 views1 comment
bottom of page