web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Problem using Connect-...
Power Automate
Unanswered

Problem using Connect-MicrosoftTeams in runbook

(0) ShareShare
ReportReport
Posted on by 14

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.

 

Categories:
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard