Fixlet for uninstallation of Python older version

I have been working since long on this & banning my head into it but unable to do so.
Requiring some help on how to uninstall all the previous python versions which are available in system with all the traces removed either from program files as well as from registry i wanted to remove every single entry of older versions.

I’m using below script to uninstall the previous versions it casing me some issue folders are not removing & even the entry from program files is also not removing. When trying to do it manually it’s not removing.

//Task kill
if {exists running applications whose (name of it as string as lowercase starts with “py”)}
waithidden taskkill /f /im py*
endif
//Remove previous version
delete __appendfile
delete pyremove.cmd
appendfile {concatenation “%0d%0a” of (“start /w msiexec /x " & it & " /qn REBOOT=ReallySuppress”) of ((unique values of names of keys whose (value “DisplayName” of it as string as lowercase contains “python” AND value “DisplayVersion” of it as string starts with “3.” AND value “DisplayVersion” of it as string < “3.12.4150.0”) of keys “HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall” of (x32 registries; x64 registries)))}
appendfile {concatenation “%0d%0a” of (“start /w msiexec /x " & it & " /qn REBOOT=ReallySuppress”) of ((unique values of names of keys whose (value “DisplayName” of it as string as lowercase contains “python launcher”) of keys “HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall” of (x32 registries; x64 registries)))}
copy __appendfile pyremove.cmd
waithidden pyremove.cmd
//Pause
parameter “startTime”=“{now}”
pause while {(now-time(parameter “startTime”) < 5*minute)}
//Delete leftover registry entries
delete __createfile
delete regcleanup.ps1
createfile until _eof
$Reg = ‘Python’
$Key = ‘HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall’
Get-ChildItem $Key -Rec -EA SilentlyContinue | ForEach-Object {{
** $CurrentKey = (Get-ItemProperty -Path $_.PsPath | Sort-Object DisplayName)**
** If ($CurrentKey -match $Reg){{**
** $CurrentKey|Remove-Item -Force**
** }**
}
_eof
copy __createfile regcleanup.ps1
action uses wow64 redirection {not x64 of operating system}
waithidden powershell.exe -ExecutionPolicy Bypass -File regcleanup.ps1
action uses wow64 redirection {x64 of operating system}
waithidden powershell.exe -ExecutionPolicy Bypass -File regcleanup.ps1
//Delete leftover files
if {exist (files of folders “C:\Windows”) whose (name of it starts with “py” and version of it < “3.12.4150.0”)}
delete __appendfile
delete delfiles.cmd
appendfile {concatenation “%0d%0a” of ("del " & “%22” & it & “%22”) of (pathnames of (files of folders “C:\Windows”) whose (name of it starts with “py”))}
copy __appendfile delfiles.cmd
waithidden cmd /c delfiles.cmd
endif

If a process does not function correctly when performed manually, it is unlikely that BigFix will be able to execute it successfully. BigFix is designed to automate tasks based on proven, working logic.

Recommendation: Please collaborate with your PowerShell scripting expert to ensure the process works manually before incorporating it into a BigFix Fixlet or Task.

As vk.khurava, you need to test and get the scritpt working manually before wrapping it / intergrating it in a BigFix Fixlet.