Hi
This is on a business environment, Windows 11 laptops with Intune\PMPC deployments.
I'm writing a script to uninstall Chrome that users have installed themselves without admin rights, so the app is in their AppData Local folders. Google are really sneaky with their installer as it allows users to install without admin (well they could until I blocked the downloads) but cannot be uninstalled cleanly as it's under the user profile.
So I need to uninstall the app under the User logon. I did do a script that basically ripped out Chrome registry keys, files, killed off task schedules etc but its messy and not good practice.
I'm using PSADT v4, done the usual script to find the setup.exe location and then tried to uninstall using Start-ADTProcessUser. But when I do, its prompting for UAC creds but does not accept any user\admin credentials. If I cancel out the UAC, the script continues and says completed but when I check, Chrome is still installed and the log shows errors.
I have tried various methods - usually I do not specify the username as I think PSADT uses the current console user. But I tried this:-
Start-ADTProcessAsUser -UserName $LoggedOnUser.NTAccount -FilePath "$UninstPath" -ArgumentList "--uninstall --system-level --multi-install --force-uninstall"
which prompts for UAC and on cancelling, I got this is in the log
Start-ADTProcessAsUser -UserName $LoggedOnUser.NTAccount -FilePath "$UninstPath" -ArgumentList "--uninstall --system-level --multi-install --force-uninstall"
which prompts for UAC and on cancelling, I got this is in the log
**[Uninstall] :: An unhandled error within [invoke-appdeploytoolkit.ps1] has occurred.
Error Record:
Message : Execution failed with exit code [22].
FullyQualifiedErrorId : ProcessExitCodeError,Start-ADTProcessAsUser
ScriptStackTrace : at Start-ADTProcess, C:\installers\uninstall-chrome\PSAppDeployToolkit\PSAppDeployToolkit.psm1: line 22393
at Start-ADTProcessAsUser, C:\installers\uninstall-chrome\PSAppDeployToolkit\PSAppDeployToolkit.psm1: line 22844
at Uninstall-ADTDeployment, C:\installers\uninstall-chrome\invoke-appdeploytoolkit.ps1: line 291
at , C:\installers\uninstall-chrome\invoke-appdeploytoolkit.ps1: line 467
at , : line 1
TargetObject : Process : System.Diagnostics.Process (setup)
LaunchInfo : ProcessLaunchInfo { FilePath = C:\Users\hylandk\AppData\Local\Google\Chrome\Application\144.0.7559.97\Installer\setup.exe, ArgumentList = System.Collections.ObjectModel.ReadOnlyCollection`1[System.String], WorkingDirectory = C:\Users\hylandk\AppData\Local\Google\Chrome\Application\144.0.7559.97\Installer, RunAsActiveUser = RunAsActiveUser { NTAccount = CAREERSSCOTLAND\hylandk, SID = S-1-12-1-1374557309-1198881816-4004264339-2024299956, UserName = hylandk, DomainName = CAREERSSCOTLAND, SessionId = 3 }, UseLinkedAdminToken = False, UseHighestAvailableToken = False, InheritEnvironmentVariables = False, ExpandEnvironmentVariables = False, DenyUserTermination = False, InheritHandles = False, UseUnelevatedToken = False, UseShellExecute = False, Verb = , CreateNoWindow = False, WaitForChildProcesses = False, KillChildProcessesWithParent = False, StreamEncoding = System.Text.SBCSCodePageEncoding, WindowStyle = , ProcessWindowStyle = , PriorityClass = , CancellationToken = , NoTerminateOnTimeout = False }
CommandLine : "C:\Users\hylandk\AppData\Local\Google\Chrome\Application\144.0.7559.97\Installer\setup.exe" --uninstall --system-level --multi-install --force-uninstall
ExitCode : 22
StdOut : {}
StdErr : {}
Interleaved : {}
PositionMessage : At C:\installers\uninstall-chrome\invoke-appdeploytoolkit.ps1:291 char:17
+ ... Start-ADTProcessAsUser -UserName $LoggedOnUser.NTAccount ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
If I remove the UserName parameter, I again get UAC prompt and cancel out with similar log error and an error 60001
[Finalization] :: [IDSTeam_RemoveGoogleChrome_1.1_x64] uninstall completed in [19.2966429] seconds with exit code [60001].
So am I misunderstanding what Start-ADTProcessAsUser can do or am I just using it incorrectly?
Script is being run with psexec -s to reflect System install under Intune
Any assistance appreciated
Thanks
Kevin
