-
Notifications
You must be signed in to change notification settings - Fork 29
/
Uninstall.ps1
37 lines (29 loc) · 1.03 KB
/
Uninstall.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#Fill this variable with the Winget package ID
$PackageName = "Adobe.Acrobat.Reader.64-bit"
#Creating Loggin Folder
if (!(Test-Path -Path C:\ProgramData\WinGetLogs)) {
New-Item -Path C:\ProgramData\WinGetLogs -Force -ItemType Directory
}
#Start Logging
Start-Transcript -Path "C:\C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\$($PackageName)_Uninstall.log" -Append
#Detect Apps
$InstalledApps = & $WingetPath\winget.exe list --id $PackageName
if ($InstalledApps) {
Write-Host "Trying to uninstall $($PackageName)"
try {
$ResolveWingetPath = Resolve-Path "C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller____8wekyb3d8bbwe"
if ($ResolveWingetPath) {
$WingetPath = $ResolveWingetPath[-1].Path
}
$config
cd $wingetpath
& $WingetPath\winget.exe uninstall $PackageName --silent
}
catch {
Throw "Failed to uninstall $($PackageName)"
}
}
else {
Write-Host "$($PackageName) is not installed or detected"
}
Stop-Transcript