Hello,
Thank you for the provided details. We encountered the issue before. It is a bug in Skype for Business. We've already reported it to Microsoft, together with a couple of other users, but have not received any relevant response for them. The issue can occur from time to time, we didn't find any regular pattern. As we found during our tests, when the issue occurs, an attempt to enable the user for Skype once more should succeed.
We have updated your script to work around the issue:
$lyncServer = "csfe01.anon.com" # TODO: Modify me
$connectAttemptCount = 3 # TODO: Modify me
$sessionOptions = New-PSSessionOption -SkipRevocationCheck -SkipCACheck -SkipCNCheck
for ($i = 0; $i -lt $connectAttemptCount; $i++)
{
try
{
$session = New-PSSession -ConnectionUri https://$lyncServer/ocspowershell `
-SessionOption $sessionOptions -Authentication NegotiateWithImplicitCredential -ErrorAction Stop
$errorMessage = $NULL
}
catch
{
$errorMessage = $_.Exception.Message
continue
}
}
if ($errorMessage)
{
$Context.LogMessage("An error occured when creating remote PowerShell session to server '$lyncServer'. Error: $errorMessage", "Error")
return
}
Import-PSSession -session $session
Grant-CsConferencingPolicy -identity "%username%" -PolicyName "Conferencing Enabled" # Assign a Conferencing Policy
#Grant-CsPinPolicy -Identity "%userPrincipalName%" -PolicyName MyPinPolicy # Assign a PIN Policy
#Grant-CsExternalAccessPolicy -Identity "%userPrincipalName%" -PolicyName MyAccessPolicy # Assign an External Access Policy
#Grant-CsArchivingPolicy -Identity "%userPrincipalName%" -PolicyName MyArchivingPolicy # Assign an Archiving Policy
#Grant-CsMobilityPolicy -Identity "%userPrincipalName%" -PolicyName MyMobilityPolicy # Assign a Mobility Policy
#Grant-CsPersistentChatPolicy -Identity "%userPrincipalName%" -PolicyName MyPersistentChatPolicy # Assign a Persistent Chat Policy
Remove-PSSession -Session $session