Menu
CCMEXEC.COM – Enterprise Mobility
  • Home
  • General
  • Configuration Manager
  • Windows 10
  • Windows 11
  • Intune
  • GitHub
  • About
CCMEXEC.COM – Enterprise Mobility

PowerShell script to keep Personal Teams away in Windows 11

Posted on September 13, 2023September 15, 2023 by Jörgen Nilsson

Finally time to blog during these busy times, removing Personal Teams in Windows 11 by setting the ConfigureChatAutoInstall registry value to prevent from installing.

The challenge is that the permissions on that registry key, HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications is set to TrustedInstaller so it is hard to create the necessary value. There are solutions out there that uses Remediations to uninstall it or use SetACL.exe to set the permissions. That is why we wrote it in PowerShell natively instead, my co-worker Sassan made it look better than mine 😉, it can be downloaded from here:

CodeDump/Set-ConfigureChatAutoInstall.ps1 at main · suazione/CodeDump · GitHub

The script does the following:

  • Takes ownership of then registry key
  • Creates and sets the registry value
  • Sets the ownership back to TrustedInstaller
  • Uninstalls Personal Teams if it is already installed

I deploy this as a Win32App in Intune and add it as a blocking app in the Enrollment Status Page so the value is set the first time the user logs on. Works great! Now that Windows 11 23H2 will be delivered as an eKB (Enablement Package) and hopefully not put it back as Windows 11 21H2 – Windows 11 22H2 did. If that is the case, we can easily use success.cmd as I wrote about here to keep it away. https://ccmexec.com/2023/03/windows-servicing-personal-teams-and-success-cmd/

Deploy it as a Win32App

To be able to use it as a blocking app I wrap it and use the following:

Install Command: %WINDIR%\sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File RemoveConsumerTeams.ps1

Uninstall Command: %WINDIR%\sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File RemoveConsumerTeams.ps1

Detection Rule: Registry

Key Path: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications

Value Name: ConfigureChatAutoInstall

As shown in the picture below.

I hope this will be of value so we can remove personal Teams and move on!

7 thoughts on “PowerShell script to keep Personal Teams away in Windows 11”

  1. torgeir says:
    September 19, 2023 at 8:50 am

    Denne har jeg letet etter, takk for den.

    Reply
  2. Pingback: Intune Newsletter - 15th September 2023 - Andrew Taylor
  3. ang says:
    October 17, 2023 at 12:30 pm

    Hi
    I tried to test the Script with PS (admin) but it was giving me this error….

    VERBOSE: Setting ACL permission [FullControl] for user [NT AUTHORITY\System] @ [HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications]
    Exception calling “OpenSubKey” with “3” argument(s): “Requested registry access is not allowed.”
    At C:\temp\RemoveConsumerTeams.ps1:65 char:9
    + $Item = $rootKey.OpenSubKey($Key,[Microsoft.Win32.RegistryKey …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SecurityException

    Exception calling “SetAccessControl” with “1” argument(s): “Cannot write to the registry key.”
    At C:\temp\RemoveConsumerTeams.ps1:69 char:9
    + $Item.SetAccessControl($acl)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : UnauthorizedAccessException

    New-ItemProperty : Requested registry access is not allowed.

    Reply
    1. Jörgen Nilsson says:
      January 31, 2024 at 2:15 pm

      Yes, you need to run it in System context

      Reply
  4. Menesh says:
    November 21, 2023 at 2:31 pm

    Manually testing the script i get the following error

    Exception calling “OpenSubKey” with “3” argument(s): “Requested registry access is not allowed.”
    At C:\source-code\teams.ps1:70 char:9
    + $Item = $rootKey.OpenSubKey($Key,[Microsoft.Win32.RegistryKey …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SecurityException

    Exception calling “SetAccessControl” with “1” argument(s): “Cannot write to the registry key.”
    At C:\source-code\teams.ps1:74 char:9
    + $Item.SetAccessControl($acl)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : UnauthorizedAccessException

    Reply
    1. Jörgen Nilsson says:
      November 21, 2023 at 4:38 pm

      Hi, You need to run the script as System otherwise it will not work.
      Regards,
      Jörgen

      Reply
      1. Menesh says:
        November 22, 2023 at 5:18 pm

        As i will be adding this in OSD TS in SCCM so i will check if it works

        Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

My name is Jörgen Nilsson and I work as a Senior Consultant at Onevinn in Malmö, Sweden. This is my blog where I will share tips and stuff for my own and everyone elses use on Enterprise Mobility and Windows related topics.
All code is provided "AS-IS" with no warranties.

Recent Posts

  • New settings in Intune Security Baseline Windows 11 24H2 -2504
  • Managing extensions in Visual Studio Code
  • Reinstall a required Win32app using remediation on demand
  • Administrator protection in Windows 11 – First look
  • Remediation on demand script – ResetWindowsUpdate
©2025 CCMEXEC.COM – Enterprise Mobility | WordPress Theme by Superb Themes
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Reject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT