
Announcements
I have inherited a flow that invokes a runbook with Connect-MicrosoftTeams, and then uses three Grant-CsTeamsXXXX commandlets to assign policies to a user account. The runbook jobs have been failing for at least the past 3 months. To investigate, I created a simple test runbook and ran it in the Runbook Test pane. The code is:
$VerbosePreference = "Continue"
Write-Verbose -Message 'connecting to Microsoft Teams'
$login = Get-AutomationPSCredential -Name 'xxxxxxxxxxxxxxxxxxxx'
Connect-MicrosoftTeams -Credential $login
Write-Verbose -Message 'disconnecting from Microsoft Teams'
Disconnect-MicrosoftTeams
When I start this, it runs for about 10 minutes (lots of periods get displayed) and then the output is:
connecting to Microsoft Teams
Loading module from path 'C:\Modules\User\MicrosoftTeams\net472\Microsoft.TeamsCmdlets.PowerShell.Connect.dll'.
<imports some cmdlets>
Loading module from path 'C:\Modules\User\MicrosoftTeams\Microsoft.Teams.PowerShell.TeamsCmdlets.psd1'.
Cannot verify the Microsoft .NET Framework version 4.7.2 because it is not included in the list of permitted versions.
Loading 'FormatsToProcess' from path 'C:\Modules\User\MicrosoftTeams\GetTeamSettings.format.ps1xml'.
Loading module from path 'C:\Modules\User\MicrosoftTeams\./Microsoft.Teams.PowerShell.TeamsCmdlets.psm1'.
Loading module from path 'C:\Modules\User\MicrosoftTeams\net472\Microsoft.Teams.PowerShell.TeamsCmdlets.dll'.
<imports and exports many cmdlets>
Loading module from path 'C:\Modules\User\MicrosoftTeams\net472\Microsoft.Teams.PowerShell.Module.dll'.
Loading module from path 'C:\Modules\User\MicrosoftTeams\Microsoft.Teams.Policy.Administration.psd1'.
Cannot verify the Microsoft .NET Framework version 4.7.2 because it is not included in the list of permitted versions.
Loading module from path 'C:\Modules\User\MicrosoftTeams\./Microsoft.Teams.Policy.Administration.psm1'.
Loading module from path 'C:\Modules\User\MicrosoftTeams\Microsoft.Teams.Policy.Administration.Cmdlets.Core.psd1'.
Cannot verify the Microsoft .NET Framework version 4.7.2 because it is not included in the list of permitted versions.
Loading module from path 'C:\Modules\User\MicrosoftTeams\./Microsoft.Teams.Policy.Administration.Cmdlets.Core.psm1'.
Loading module from path 'C:\Modules\User\MicrosoftTeams\net472\Microsoft.Teams.Policy.Administration.Cmdlets.Core.dll'.
<imports and exports many cmdlets>
Loading module from path 'C:\Modules\User\MicrosoftTeams\Microsoft.Teams.ConfigAPI.Cmdlets.psd1'.
Cannot verify the Microsoft .NET Framework version 4.7.2 because it is not included in the list of permitted versions.
Loading 'FormatsToProcess' from path 'C:\Modules\User\MicrosoftTeams\Microsoft.Teams.ConfigAPI.Cmdlets.custom.format.ps1xml'.
Loading 'FormatsToProcess' from path 'C:\Modules\User\MicrosoftTeams\Microsoft.Teams.ConfigAPI.Cmdlets.format.ps1xml'.
Loading 'FormatsToProcess' from path 'C:\Modules\User\MicrosoftTeams\SfbRpsModule.format.ps1xml'.
Loading module from path 'C:\Modules\User\MicrosoftTeams\./Microsoft.Teams.ConfigAPI.Cmdlets.psm1'.
Loading module from path 'C:\Modules\User\MicrosoftTeams\bin\Microsoft.Teams.ConfigAPI.Cmdlets.private.dll'.
<imports many cmdlets then output just stops>
The second Write-Verbose statement doesn't appear to execute, and there is no time-out error message. I don't understand why Connect-MicrosoftTeams is trying to import modules, the Automation account has version 4.9.1 of the MicrosoftTeams module loaded. I have used the same $login = Get-AutomationPSCredential approach to run Connect-MsolService and Connect-AzureAD with no problems.
The flow uses an Automation RunAs account, and Powershell version 5.1. I have tried uninstalling and reinstalling the MicrosoftTeams module with no obvious effect.
Can anyone suggest a way to deal with this? I should mention that updating to a more recent version of Powershell, or using Microsoft Graph versions is not an option at the moment.