Forum Discussion
Issue in script
adam deltinger I have that command in my script. And in simple loop script it works.
But I think issue is with
Connect-MsolService
I think that token expires in 1 hour
Which command do you use for migrating the users to Teams? As of CU8 for SfB 2015 and SfB 2019, you can use the following command: Move-CsUser -Identity "someone@domain.com" -Target "sipfed.online.lync.com" -MoveToTeams -Credential $cred
That command doesn't need a connection to msolservice or Skype Online. Therefor you also won't run into the timing issue.
If you still need to use the Skype Online module, you could use something like this:
$StartDate = Get-Date
foreach($user in $users){
$CurrentDate = Get-Date
If ($CurrentDate -ge $StartDate.AddMinutes(45)){
$sfbSession = New-CsOnlineSession -Credential $cred
Import-PSSession $sfbSession -AllowClobber -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
Enable-CsOnlineSessionForReconnection
$StartDate = Get-Date
}
Grant-CsTeamsUpgradePolicy -identity $user.UPN -policyname UpgradeToTeams -confirm:$false
}
To be on the safe side, it will reconnect 45 minutes after the first connection.
- msabatJul 20, 2020Brass Contributor
I use that:
Move-CsUser -Identity $user -Target sipfed.online.lync.com -HostedMigrationOverrideUrl https://admin0a.online.lync.com/HostedMigration/hostedmigrationservice.svc -ProxyPool sx-lyncpool.qg.com -MoveToTeams -BypassAudioConferencingCheck -BypassEnterpriseVoiceCheck -credential $credential -Verbose -Confirm:$false
- RuudGijsbersJul 20, 2020Iron Contributor
msabat That looks fine to me. And in my experience, there's no issue with token lifetimes when using that command.
The error message is regarding the command Get-CsOnlineUser. Perhaps you can work around that command so you won't need it. What are you using that command for?