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

Announcements

News and Announcements icon
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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 248 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 160 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 142 Super User 2026 Season 2

Last 30 days Overall leaderboard