Forum Discussion

DarusDP's avatar
DarusDP
Copper Contributor
Aug 09, 2021
Solved

Using Powershell Microsoft Teams module in a GUI app will not shutdown the process when form closed

I have a GUI app written in Powershell that works correctly except when I connect to MicrosoftTeams (and even disconnect) then the GUI app process will not end. If I remove the connection to MSTeams the process ends correctly (not in task mgr process list anymore). So I'm confident I've narrowed the issue down to the MSTeams connect/disconnect.

 

Here is code snipet for connect/disconnect.

$script:msteamsSession = Connect-MicrosoftTeams -Credential $script:O365CredDefault

Disconnect-MicrosoftTeams -Confirm:$false

 

It does seem to be an issue in non-GUI scripts also.

When I run PS ISE and do MSTeams connect then close PS ISE, the process is still running. Yes I gave it time to shutdown.

 

 

  • DarusDP 

    Not ideal or elegant but

    Stop-Process -Id $PID 

    seems to work

     

    Hopefully Microsoft Teams module developers will discover the real problem and fix it.

     

3 Replies

    • DarusDP's avatar
      DarusDP
      Copper Contributor
      Unfortunately remove-module -Name MicrosoftTeams didn't work
      • DarusDP's avatar
        DarusDP
        Copper Contributor

        DarusDP 

        Not ideal or elegant but

        Stop-Process -Id $PID 

        seems to work

         

        Hopefully Microsoft Teams module developers will discover the real problem and fix it.

         

Resources