Teams’ default behavior is to launch automatically upon user login. This can be undesirable for a myriad of reasons, and can be managed with Group Policy with a couple of caveats. The first is that this policy is a User configuration policy, and not a Computer configuration policy. The second is that the policy must be set before installation of the application.
I find these limitations restrictive, so I decided to look for alternatives. One is Aaron Guilmette’s Disable-TeamsAutorun script at https://www.powershellgallery.com/packages/Disable-TeamsAutorun/1.1/Content/Disable-TeamsAutorun.ps1. This script is lacking provisions to stop the Teams process before modifying configuration files. I consider this potentially problematic, even if it doesn’t always seem to pose an issue. So, as a matter of course, I modified the script to do so. It can be found here: https://github.com/p8nflnt/SysAdmin-Toolbox/blob/main/Disable-TeamsAutorun/Disable-TeamsAutorun.ps1.
I had some additional considerations for managing this modification. I know I will be reverting to default at some point in the future; so, I wanted to manage it on a per-device basis, and to be able to manage the reversion. Additionally, execution of the program will revert the settings to default. The actual change is managed by the presence of an HKEY_CURRENT_USER registry key, and a .JSON config file within a given user profile’s AppData folder. Notice that these are both tied to the user. So, to manage this on a per device basis, I needed to ensure that the script will execute for each user, preferably with some level of regularity in case the application is run by updates or some other process (which would revert the setting).
This makes a startup script an ideal vehicle for performing this modification. It will execute on each user login, so it has the ability to remain persistent; and, because it runs immediately, it won’t affect a user’s use of the program within a session. I used the ps2exe module to convert the script to an executable so it can be executed directly. Particular switches can be used to handle the behavior of the output executable file. In my case, I wanted to ensure that it would run silently and not throw error codes if encountered. Here is the line I used to perform the conversion.
Invoke-PS2EXE $psFile $exeFile -noConsole -noOutput -ErrorAction SilentlyContinue
So, the executable is actually my modified version of Aaron Guilmette’s Disable-TeamsAutorun PowerShell script (https://github.com/p8nflnt/SysAdmin-Toolbox/blob/main/Disable-TeamsAutorun/Disable-TeamsAutorun.ps1). For deploying the executable, I opted to use ConfigMan. This was because I intended to target specific devices, I wanted reporting, and because I wanted to revert back at some point in the future. ConfigMan is the perfect tool for the job. I wrote a script to simply copy the executable to the startup directory (‘\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup’). This is the installation script that I referenced in ConfigMan, and you can find it here: https://github.com/p8nflnt/SysAdmin-Toolbox/blob/main/Disable-TeamsAutorun/Deploy-DisableTeamsAutorun.ps1.
I also had to write an uninstall script, which removes the executable file from the startup directory and undoes the changes made by the executable file. It can be found here: https://github.com/p8nflnt/SysAdmin-Toolbox/blob/main/Disable-TeamsAutorun/Remove-DisableTeamsAutorun.ps1. I also had to write a simple detection script for ConfigMan to use, and it can be found here: https://github.com/p8nflnt/SysAdmin-Toolbox/blob/main/Disable-TeamsAutorun/CMDetection-TeamsAutorun.ps1.
So, there you have it- a deployable solution to disable Teams’ default autorun behavior that won’t interrupt users and can be managed on a per-device basis. And, it has complete reversion ability. The entire project can be found here on my GitHub: https://github.com/p8nflnt/SysAdmin-Toolbox/tree/main/Disable-TeamsAutorun.