To answer this question I'm going to highlight a couple of points for you to consider.

  1. Until official support has been announced, don't use the non-official PowerShell PackageManagement provider for Chocolatey. It is an unsupported preview subject to bugs and security flaws (it was also not created by the Chocolatey team). Instead use choco.exe, or another official provider.
  2. AutoUninstaller is the resource in official Chocolatey clients that can remove natively installed software from packages that do not contain an uninstall script. It's important to note that you also need to install from those official clients. More information at https://chocolatey.org/docs/commands-uninstall

Why are these packages still present after uninstall-package?

It really depends on what you used to install the packages and whether Chocolatey was able to capture a snapshot for auto uninstaller.

Many packages do not require an uninstall script. Some do. When they are an MSI and are upgraded outside of Chocolatey (like Chrome does automatically), you either need Package Synchronizer or an uninstall script to uninstall the software.

Is there a best-practice way to do this?

If this is for organizational use, and you have a low tolerance for breakages, we recommend you build your own internal packages. Then you can completely control the process and have a repeatable, reliable process. This is how hundreds of organizations that use Chocolatey currently have enhanced their installation processes. They typically already have software installers already present on some internal file share and build packages around them to take advantage of better automation processes (versus old batch files they may have been using, or worse, manually installing from).

If you are curious on why you should build your own, see https://chocolatey.org/docs/community-packages-disclaimer (it attempts to highlight the issues with a public repository and it being subjected to distribution rights, something an internal repository is not subject to).

Is there a best-practice way to script python's re-installation so this won't happen again?

Use a configuration management tool like Puppet, Chef, Ansible, or DSC with the Chocolatey provider. https://chocolatey.org/docs/features-infrastructure-automation

This is how you create automation across all of your machines and take advantage of package management.

Answer from ferventcoder on Stack Overflow
Top answer
1 of 1
1

To answer this question I'm going to highlight a couple of points for you to consider.

  1. Until official support has been announced, don't use the non-official PowerShell PackageManagement provider for Chocolatey. It is an unsupported preview subject to bugs and security flaws (it was also not created by the Chocolatey team). Instead use choco.exe, or another official provider.
  2. AutoUninstaller is the resource in official Chocolatey clients that can remove natively installed software from packages that do not contain an uninstall script. It's important to note that you also need to install from those official clients. More information at https://chocolatey.org/docs/commands-uninstall

Why are these packages still present after uninstall-package?

It really depends on what you used to install the packages and whether Chocolatey was able to capture a snapshot for auto uninstaller.

Many packages do not require an uninstall script. Some do. When they are an MSI and are upgraded outside of Chocolatey (like Chrome does automatically), you either need Package Synchronizer or an uninstall script to uninstall the software.

Is there a best-practice way to do this?

If this is for organizational use, and you have a low tolerance for breakages, we recommend you build your own internal packages. Then you can completely control the process and have a repeatable, reliable process. This is how hundreds of organizations that use Chocolatey currently have enhanced their installation processes. They typically already have software installers already present on some internal file share and build packages around them to take advantage of better automation processes (versus old batch files they may have been using, or worse, manually installing from).

If you are curious on why you should build your own, see https://chocolatey.org/docs/community-packages-disclaimer (it attempts to highlight the issues with a public repository and it being subjected to distribution rights, something an internal repository is not subject to).

Is there a best-practice way to script python's re-installation so this won't happen again?

Use a configuration management tool like Puppet, Chef, Ansible, or DSC with the Chocolatey provider. https://chocolatey.org/docs/features-infrastructure-automation

This is how you create automation across all of your machines and take advantage of package management.

Discussions

Need a programmatic method to uninstall python on Windows Server 2022.
Python tool uninstallation fails when tried using commandline method. [Uninstall-Package" or "& cmd /c $UninstallString /quiet /uninstall" ] Both the methods fail. Please suggest some alternate route to resolve this. Windows for business | Windows Server | User experience | PowerShell More on learn.microsoft.com
🌐 learn.microsoft.com
4
5
December 8, 2023
Uninstallation command
I need a windows sillent python uninstallation command.Kindly help me on this issue. Thanks in advance. More on discuss.python.org
🌐 discuss.python.org
5
0
August 29, 2023
Need a programmatic method to uninstall python on Windows Server 2022.
Python tool uninstallation fails when tried using commandline method. [Uninstall-Package" or "& cmd /c $UninstallString /quiet /uninstall" ] Both the methods fail. Please suggest some alternate route to resolve this. Windows for business | Windows Server | User experience | PowerShell More on answers.microsoft.com
🌐 answers.microsoft.com
4
5
December 8, 2023
command - Powershell help for Python uninstall - Stack Overflow
Looking to uninstall Python 3.12.3. using cmd.exe via intune. When I run the command via command it works as intended how ever when I use intune to push the command the CMD window appears and nothing More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › HealthCatalyst › PythonPowershellUtilities
GitHub - HealthCatalyst/PythonPowershellUtilities: The only powershell module you should ever need. · GitHub
This module caches the ... once the version is uninstalled. For python version 3.x the python development team provides several installers for windows, one of which is an executable installer that can be run from the command line / powershell....
Starred by 10 users
Forked by 2 users
Languages   PowerShell
🌐
PowerShell Gallery
powershellgallery.com › packages › PythonPowershellUtilities › 2.0.1 › Content › Functions › Uninstall-Python.ps1
PowerShell Gallery | Functions/Uninstall-Python.ps1 2.0.1
PythonPowershellUtilities · 2.0.1 · Functions/Uninstall-Python.ps1 · Contact Us · Terms of Use · Gallery Status · Feedback · © 2026 Microsoft Corporation
🌐
Fixtherisk
fixtherisk.in › automating-python-uninstallation-with-powershell
Automating Python Uninstallation with PowerShell – Fix The Risk
In this article I will discuss about how we can remotely uninstall all versions of python and from all user profile. Python, a versatile and widely-used programming language, has become an integral part of many development environments. However, ensuring the security of your systems demands not only the use of up-to-date software but also the efficient removal of outdated versions. In this blog post, we delve into a PowerShell ...
🌐
SILENT INSTALL HQ
silentinstallhq.com › python-3-12-install-and-uninstall-powershell
Python 3.12 Silent Install & Uninstall (PowerShell Script)
October 12, 2025 - Learn how to silently install and uninstall Python 3.12 using PowerShell (PSADT). Step-by-step guide for IT admins and deployment pros.
Find elsewhere
🌐
SILENT INSTALL HQ
silentinstallhq.com › python-2-7-install-and-uninstall-powershell
Python 2.7 Install and Uninstall (PowerShell) - SILENT INSTALL HQ
October 12, 2025 - This article will serve as an informative guide and give you a clear understanding of how to perform silent or interactive installs and uninstalls of Python 2.7 using the Powershell App Deployment…
🌐
Python.org
discuss.python.org › python help
Uninstallation command - Python Help - Discussions on Python.org
August 29, 2023 - I need a windows sillent python uninstallation command.Kindly help me on this issue. Thanks in advance.
🌐
SILENT INSTALL HQ
silentinstallhq.com › python-3-13-install-and-uninstall-powershell
Python 3.13 Silent Install & Uninstall (PowerShell Script)
October 12, 2025 - Learn how to silently install and uninstall Python 3.13 using PowerShell (PSADT). Step-by-step guide for IT admins and deployment pros.
🌐
Araqev
araqev.com › home › how can i uninstall python from powershell?
How Can I Uninstall Python from PowerShell?
March 22, 2025 - Learn how to remove Python from PowerShell with our step-by-step guide. Discover effective methods to uninstall Python and clean up your system efficiently. Follow our simple instructions to ensure a hassle-free removal process.
🌐
PowerShell Gallery
powershellgallery.com › packages › PythonPowershellUtilities › 0.7.0 › Content › Functions › Uninstall-Python.ps1
PowerShell Gallery | Functions/Uninstall-Python.ps1 0.7.0
PythonPowershellUtilities · 0.7.0 · Functions/Uninstall-Python.ps1 · Contact Us · Terms of Use · Gallery Status · Feedback · © 2026 Microsoft Corporation
🌐
DEV Community
dev.to › cuongld2 › automatically-install-and-uninstall-app-by-powershell-in-windows-wrapper-in-python-code-1naa
Automatically install and uninstall app by powershell in Windows wrapper in Python code - DEV Community
January 14, 2020 - So today I'm gonna share with you how to do that in powershell wrapper by Python. ... We would need to check if the app is installed yet, if it is installed and it is the latest version -> skip. If it is installed but the version is not latest --> uninstall then install.
🌐
Stack Overflow
stackoverflow.com › questions › 78469481 › powershell-help-for-python-uninstall
command - Powershell help for Python uninstall - Stack Overflow
Looking to uninstall Python 3.12.3. using cmd.exe via intune. When I run the command via command it works as intended how ever when I use intune to push the command the CMD window appears and nothing
🌐
Mimo
mimo.org › tutorials › python › how-to-uninstall-python
How to Uninstall Python
If you see zsh: command not found: ... or python.org. If your Linux uninstall wants to remove many packages, cancel it and uninstall only non-system versions. If you see Permission denied when deleting files, use admin privileges (sudo on macOS/Linux or run PowerShell as Administrator ...
Top answer
1 of 1
1

So after some time of me and my colleague troubleshooting this, we gained a better understanding of the situation and what actually happened. This doesn't solve what we were trying to do originally (deploy Python 3.8.1 MSI's through WSUS), but it at least helps us clean up. Hopefully this helps another admin out there who may have experienced something similar to this with WSUS Package Publisher or something else!!

We're deploying Python through WSUS, so that means that all local machines install Python as NTAUTH\SYSTEM. This explains why Python was installing correctly, without complaints, in the location I specified in the .MST (C:\Program Files\Python38).

For some reason, the Python MSI's all ignore the ALLUSERS=1 call in the .MST, and by specifying it as a parameter. No idea why (maybe someone from the Python team or someone with a deeper understanding could chime in? :) ).

The result of this means, from my understanding/testing, that the installer detects that it's not running as an elevated process, and therefore installs the MSI as user NTAUTH\SYSTEM, for NTAUTH\SYSTEM, placing the keys for Python launcher etc in HKCU instead of HKLM. But because of the .MST and the access rights that NTAUTH\SYSTEM has, it places the installation files in C:\Program Files\Python38 as requested.

This explains why installations would fail, uninstallation was impossible no matter what, and why our Python Launcher was behaving weirdly despite PATH being set correctly.

  • Installations would fail because the keys would all still be placed in the HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\
  • The installers never appeared in Installed Applications despite successful installation, because it was installed for the NTAUTH\SYSTEM and not All Users
  • The uninstallation through MSIEXEC or by right clicking the MSI would claim that it wasn't installed, because Python was technically not installed for either the system (aka All Users when elevated), nor the user trying to uninstall it (aka my user account, without elevation).
  • py -0 wasn't picking up the Py38 installation despite picking up other versions, because the launcher was searching in the HKLM keys, which 381 wasn't installing in.

So to clean this huge mess up, we needed to uninstall all of the Python 3.8.1 MSI's as NTAUTH\SYSTEM, and without elevation. There are several ways to do this - either by downloading and using PSEXEC to launch a CMD or Powershell as System (psexec64.exe -sid powershell.exe) and running MSIEXEC through that, or (the approach we took) create a Scheduled Task on the machine, have it run as NTAUTH\SYSTEM, without the highest privilages, and uninstall anything which had "Python 3.8.1*" property. A quick Powershell script for this:

$products = Get-WmiObject Win32_Product

foreach ($pkg in (
        "Python 3.8.1 Tcl*",
        "Python 3.8.1 Util*",
        "Python 3.8.1 Test*",
        "Python 3.8.1 Dev*",
        "Python 3.8.1 Documentation*",
        "Python 3.8.1 pip*",
        "Python 3.8.1 Standard*",
        "Python 3.8.1 Exe*",
        "Python 3.8.1 Core*",
        "Python 3.8.1 Add*",
        "Python Launcher*"
    )) {
    $products | Where-Object {
        ($_.Name -like $pkg)
    } | Select-Object -ExpandProperty LocalPackage | Foreach-Object {
        Start-Process -FilePath "msiexec.exe" -ArgumentList "/x $_ /QN" -Wait
    }
}

get-wmiobject Win32_Product | where-object {$_.Name -like "Python*"} | Format-Table Name, LocalPackage
🌐
Reddit
reddit.com › r/powershell › looking to uninstall python 3.12.3 via intune
r/PowerShell on Reddit: looking to uninstall python 3.12.3 via intune
May 7, 2024 -

Looking to remove python 3.12.3 from intune. I've tried everything under the sun so far but have not had no luck. Can someone correct me on where I am going wrong with this uninstall.

Below are a few of the commands that I have used for the uninstall command in intune

"AppData\Local\Package Cache\{5ee4d2b6-a5dc-4321-b6bd-3ebc98120a51}\python-3.12.3-amd64.exe" /uninstall

cmd /c "AppData\Local\Package Cache\{5ee4d2b6-a5dc-4321-b6bd-3ebc98120a51}\python-3.12.3-amd64.exe" /uninstall

I have used uninstall view to get the string for the application and have been experimenting with powershell and cmd locally to ensure that the commands work before i move them over to intune. As soon as they are run from intune they fail but run as intended via powershell / cmd.

Any helpful insight to get this working is appreciated.

🌐
TutorialsPoint
tutorialspoint.com › article › how-to-uninstall-software-using-package-management-in-powershell
How to uninstall software using Package management in PowerShell?
Python TechnologiesDatabasesComputer ProgrammingWeb DevelopmentJava TechnologiesComputer ScienceMobile DevelopmentBig Data & AnalyticsMicrosoft TechnologiesDevOpsLatest TechnologiesMachine LearningDigital MarketingSoftware QualityManagement Tutorials View All Categories ... There are mainly 3 methods by which you can uninstall software using PowerShell...