Forum Discussion
Teams PowerShell no longer works on MacOS - Windows only dependency after 7.9.0
Since MicrosoftTeams 7.9.0, Connect-MicrosoftTeams with the default interactive sign-in fails on macOS before any sign-in prompt appears. It throws System.DllNotFoundException: Unable to load shared library 'kernel32.dll'. Version 7.8.0 connects without error on the same machine. The current release, 8.0.0, has the same problem.
Environment
- macOS 27.0.1 on Apple silicon (Arm64)
- PowerShell 7.6.2 on .NET 10.0.8
- MicrosoftTeams 7.9.0 and 8.0.0 fail; 7.8.0 works
Steps to reproduce
Install-Module MicrosoftTeams -RequiredVersion 8.0.0 -Scope CurrentUser Import-Module MicrosoftTeams -RequiredVersion 8.0.0 Connect-MicrosoftTeams
Expected result
A browser sign-in opens and the session connects, as it does with 7.8.0.
Actual result
No sign-in prompt appears. The command fails straight away:
System.DllNotFoundException: Unable to load shared library 'kernel32.dll' or one of its dependencies. at Microsoft.TeamsCmdlets.Powershell.Connect.TeamsPowerShellSession.GetConsoleWindow() at Microsoft.TeamsCmdlets.Powershell.Connect.TeamsPowerShellSession.GetConsoleWindow() at Microsoft.TeamsCmdlets.Powershell.Connect.TeamsPowerShellSession.GetConsoleOrTerminalWindow() at Microsoft.Identity.Client.PublicClientApplicationBuilder.<>c__DisplayClass12_0.<WithParentActivityOrWindow>b__0() at Microsoft.Identity.Client.AcquireTokenInteractiveParameterBuilder.WithParentActivityOrWindowFunc(Func`1 parentActivityOrWindowFunc) at Microsoft.Identity.Client.PublicClientApplication.AcquireTokenInteractive(IEnumerable`1 scopes) at Microsoft.TeamsCmdlets.Powershell.Connect.TokenProvider.MsalTokenProvider.GetAccessTokenInteractive(ModuleConfiguration config, AzureAccount azAccount, IEnumerable`1 scopes) at Microsoft.TeamsCmdlets.Powershell.Connect.AuthenticationFactory.Authenticate(AzureAccount account, AzureEnvironment environment, String tenantId, SecureString password, AuthenticationFlow authFlow, String resource, IEnumerable`1 scopes, String clientAppId) at Microsoft.TeamsCmdlets.Powershell.Connect.RMProfileClient.AcquireAccessToken(AzureAccount account, AzureEnvironment environment, String tenantId, SecureString password, AuthenticationFlow authFlow) at Microsoft.TeamsCmdlets.Powershell.Connect.RMProfileClient.Login(AzureAccount account, AzureEnvironment environment, String tenantId, SecureString password, AuthenticationFlow authFlow) at Microsoft.TeamsCmdlets.Powershell.Connect.ConnectMicrosoftTeams.ProcessRecord()
The full exception message also lists every path .NET tried for kernel32.dll.dylib, libkernel32.dll and so on, all "no such file".
Cause
TeamsPowerShellSession.GetConsoleOrTerminalWindow() calls the Windows GetConsoleWindow function through [DllImport("kernel32.dll")]. The module passes it to MSAL as the parent-window callback (PublicClientApplicationBuilder.WithParentActivityOrWindow), and MSAL calls that callback inside AcquireTokenInteractive. macOS has no kernel32.dll, so the call throws before sign-in starts.
Comparing Microsoft.TeamsCmdlets.PowerShell.Connect.dll across versions:
- 7.8.0: only the Integrated Windows Authentication path, which runs only on Windows, sets this callback.
- 7.9.0 and 8.0.0: AzureSessionProvider also sets it when it builds the client application, and that client is used for interactive sign-in on every platform.
A fix would be to set the callback only on Windows, or have GetConsoleOrTerminalWindow() return IntPtr.Zero on other platforms. Linux has no kernel32.dll either, so I'd expect interactive sign-in to fail there too, but I haven't tested it.
Workarounds
- Stay on 7.8.0:
Install-Module MicrosoftTeams -RequiredVersion 7.8.0 -Scope CurrentUser Import-Module MicrosoftTeams -RequiredVersion 7.8.0
- Use device code sign-in. Connect-MicrosoftTeams -UseDeviceAuthentication doesn't call GetConsoleWindow, and on 8.0.0 it gets to the device code prompt without this error.
I found this while testing Maester (maester.dev), which calls Connect-MicrosoftTeams from Connect-Maester -Service Teams and -Service All.