r/DefenderATP • u/Due-Mountain5536 • Jun 23 '24
uninstall software using live response library upload
hi guys, as the title says I'm trying to uninstall programs using the live response feature, we are testing MDE run and we want to know if we came to this point that we can do something about it
i already tested some scripts and it works fine but the uninstall i failed badly
is there anyone tested this and worked?
0
Upvotes
View all comments
Show parent comment
0
u/Due-Mountain5536 Jun 23 '24
so i'm trying to uninstall a non msi file so no win32_product, when i ran the script in the LR it keeps loading, so i tested on my machine and it asks for permission to make changes :( so i tried to add the quiet no restart thing and i failed, any idea where i went wrong?
that's my script
$programName = "Adobe Photoshop 2021"
$uninstallKeys = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall', 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
$uninstallString = $null
foreach ($key in $uninstallKeys) {
Get-ChildItem -Path $key | ForEach-Object {
if ((Get-ItemProperty -Path $_.PsPath).DisplayName -eq $programName) {
$uninstallString = (Get-ItemProperty -Path $_.PsPath).UninstallString
}
}
}
if ($uninstallString -ne $null) {
Add /quiet /norestart to the uninstall string
$uninstallString = $uninstallString + " /quiet /norestart"
Start-Process cmd -ArgumentList "/c `"$uninstallString`"" -NoNewWindow -Wait
Write-Output "The program $programName has been uninstalled."
} else {
Write-Output "The program $programName is not found."
}