I am attempting convert a PowerShell command that generates a list of applications that are currently installed on a device in Python to use that list in an application uninstaller.
The command I am working with is:
Get-ItemProperty HKLM:\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall* |
Select-Object DisplayName, DisplayVersion, UninstallString
When attempting to convert the command I get the error:
'Select-Object' is not recognized as an internal or external command, operable program or batch file.
My example Python code is as follows:
shell = "powershell.exe "
shell_command = "Get-ItemProperty HKLM:\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall*"
followup_command = "Select-Object DisplayName, DisplayVersion, UninstallString"
result = subprocess.run(
shell + shell_command + " | " + followup_command,
encoding="UTF-8",
stdout=subprocess.PIPE,
)
result = result.stdout
print(result)
Where am I going wrong?