Payton Flint's Tech Blog
Menu
  • Home
  • Blog
  • Categories
  • Resources
  • About
  • Contact
Menu

ConfigMan – Teams – Disable Teams Autorun with PowerShell

Posted on December 12, 2023December 12, 2023 by paytonflint

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.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

About The Author

Author's Portrait

In my journey as a technologist and 11 years of experience as an IT professional, I have found my niche as Director of Infrastructure Services; developing my skillsets in management, scripting, cloud infrastructure, identity management, and networking.

I have experience as a Systems Administrator and Engineer for large enterprises including the DoD, government agencies, and a nuclear-generation site.

I've been blessed to collaborate with engineers at esteemed Fortune 50 corporations, and one of Africa's largest, to ensure successful implementation of my work.

GitHub Button

Credentials

M365 Endpoint Administrator Associate
M365 Fundamentals
Microsoft AZ-900
CompTIA CSIS
CompTIA CIOS
CompTIA Security+
CompTIA Network+
CompTIA A+
  • April 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
© 2022 Payton Flint | The views and opinions expressed on this website belong solely to the author/owner and do not represent the perspectives of any individuals, institutions, or organizations, whether affiliated personally or professionally, unless explicitly stated otherwise. The content and products on this website are provided as-is with no warranties or guaranties, are for informational/demonstrative purposes only, do not constitute professional advice, and are not to be used maliciously. The author/owner is not responsible for any consequences arising from actions taken based on information provided on this website, nor from the use/misuse of products from this site. All trademarks are the property of their respective owners.