Dear Experts,
System account is running Powershell, Get-ADTApplication is working fine, except Uninstall-ADTApplication. by the way, this APP is installed by current user. How to uninstall it ? thank you very much in advance!
## removes any chrome installation if installed
$previouschrome = (Get-ADTApplication -Name 'Google Chrome')
if ($previouschrome -ne $null){
Write-ADTLogEntry -Message "$($adtSession.Appvendor, $adtSession.Appname) previous version detected. Uninstalling."
Uninstall-ADTApplication -InstalledApplication $previouschrome `
-LogFileName "$($adtSession.Appvendor, $adtSession.Appname) Previous Version" `
-ArgumentList '/QN /noreboot'}
I use the above for most installs that have been installed manually. example is chrome
If the application was originally installed in the user context, you may need to retrieve the Uninstall String and use this as part of your uninstall in the users context.
However, before we go down that rabbit hole, what does the $app variable actually contain?
If it contains all the entries in your screen grab above, I think you could try:
Uninstall-ADTApplication -InstalledApplication $($app.DisplayName)
The reason behind this (from your original question) is the -InstalledApplication parameter does not accept wildcards:
An alternative is:
Get-ADTApplication -Name 'Octoplant Client' | Uninstall-ADTApplication -InstalledApplication $_
Although this is risky - especially if you have multiple apps installed that contain 'Octoplant Client' in their name - as it will likely uninstall all of them, so you may need to include some filtering using the -FilterScript' parameter to prevent this from occurring.
Hello Scott, thank you for your advice, I tried your suggestion, it doesn't work. $app is the object - InstalledApplication, So that it can be a parameter in the Uninstall-ADTApplication -InstalledApplication $app.
maybe the only way is as you said "you may need to retrieve the Uninstall String and use this as part of your uninstall in the users context."
For those who can't understand the thread that Mitch just posted; the Get-InstalledApplication function is gain the ability to retrieve user-context applications in PSADT v4.2.
yes, agreed. Uninstall-ADTApplication should be enhanced in the future.
at present I will follow the Scott suggestion that getting uninstall string then run it under the user context.
Glad to have offered a working solution for the time being.
P.S. My name is Adrian (surname is Scott) ![]()