Deployment applications command lines and powershell - nonoloki2/Devops GitHub Wiki
Uninstalling Lightshot with powershell (this script can be used with other apps) just change variables
$productNames = @("lightshot") $UninstallKeys = @('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall', 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' ) $uninstallKeys = foreach ($key in (Get-ChildItem $UninstallKeys -ErrorAction SilentlyContinue) ) {
foreach ($product in $productNames) { if ($key.GetValue("DisplayName") -like "$product") { [pscustomobject]@{ KeyName = $key.Name.split('')[-1]; DisplayName = $key.GetValue("DisplayName"); UninstallString = $key.GetValue("UninstallString"); Publisher = $key.GetValue("Publisher"); } } } }
foreach ($key in $uninstallkeys) { $uninstallString = $key.UninstallString
if ($uninstallString.StartsWith('MsiExec.exe')) {
$uninstallString = $uninstallString.replace('/I','/X') + ' /qn /norestart'
} elseif($uninstallString -like "*\lightshot*") {
$uninstallString += ' /VerySilent'
Start-Sleep -Seconds 10
Remove-Item -Path "C:\Users\*\AppData\Local\lightshot" -Recurse -Force
Start-Sleep -Seconds 10
} Else {
$uninstallString += ' /S'
}
Write-Output "Uninstalling $($Key.DisplayName) with $uninstallString"
# Uncomment to run the uninstall - line below
& cmd /c "$uninstallString"
}
if (test-path "C:\Program Files (x86)\Skillbrains") {
Remove-Item -Path "C:\Program Files (x86)\Skillbrains" -Recurse -Force
}