-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathUninstallQuicktime.ps1
More file actions
119 lines (98 loc) · 3.69 KB
/
UninstallQuicktime.ps1
File metadata and controls
119 lines (98 loc) · 3.69 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<#
.SYNOPSIS
Apple Quicktime
.DESCRIPTION
Uninstall Apple Quicktime
.PARAMETER ApplicationName
A description of the ApplicationName parameter.
.PARAMETER WindowTitle
Title of the PowerShell window
.PARAMETER MSI_Switches
The switches used when executing the uninstallation of the MSI
.EXAMPLE
powershell.exe -executionpolicy bypass -file uninstall.ps1
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.119
Created on: 4/18/2016 1:44 PM
Created by: Mick Pletcher
Filename: UninstallQuicktime.ps1
===========================================================================
#>
param
(
[string]$ApplicationName = 'quicktime',
[string]$WindowTitle = 'Uninstall Apple Quicktime',
[string]$MSI_Switches = '/qb- /norestart'
)
function Set-ConsoleTitle {
<#
.SYNOPSIS
Console Title
.DESCRIPTION
Sets the title of the PowerShell Console
.PARAMETER Title
Title of the PowerShell console
.NOTES
Additional information about the function.
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)][String]$Title
)
$host.ui.RawUI.WindowTitle = $Title
}
Function InitializeVariables {
$Global:BuildLog = $Env:windir + "\Waller\Logs\BuildLogs\Build.csv"
$Global:Errors = $null
$Global:LogFile = $Env:windir + "\Waller\Logs\BuildLogs\AppleQuicktime.log"
$Global:Phase = "Software Deployment"
$Global:RelativePath = (split-path $SCRIPT:MyInvocation.MyCommand.Path -parent) + "\"
}
function Uninstall-MSIByName {
<#
.SYNOPSIS
Uninstall-MSIByName
.DESCRIPTION
Uninstalls an application that was installed using the MSI installer. This function will query the 32-bit and 64-bit add/remove programs entries to match a what is defined in the ApplicationName parameter. You do not have to enter the entire name. This allows you to uninstall multiple versions of an application by entering just a portion of the name that is displayed amoung all versions.
.EXAMPLE
Uninstall-MSIByName "Adobe Reader" "/qb- /norestart"
.NOTES
Additional information about the function.
#>
[CmdletBinding()]
param ()
$Uninstall = Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall -Recurse -ErrorAction SilentlyContinue
$Uninstall += Get-ChildItem HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall -Recurse -ErrorAction SilentlyContinue
$SearchName = "*" + $ApplicationName + "*"
$Executable = $Env:windir + "\system32\msiexec.exe"
Foreach ($Key in $Uninstall) {
$TempKey = $Key.Name -split "\\"
If ($TempKey[002] -eq "Microsoft") {
$Key = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $Key.PSChildName
} else {
$Key = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" + $Key.PSChildName
}
If ((Test-Path $Key) -eq $true) {
$KeyName = Get-ItemProperty -Path $Key
If ($KeyName.DisplayName -like $SearchName) {
$TempKey = $KeyName.UninstallString -split " "
If ($TempKey[0] -eq "MsiExec.exe") {
Write-Host "Uninstall"$KeyName.DisplayName"....." -NoNewline
$Parameters = "/x " + $KeyName.PSChildName + [char]32 + $MSI_Switches
$ErrCode = (Start-Process -FilePath $Executable -ArgumentList $Parameters -Wait -Passthru).ExitCode
If (($ErrCode -eq 0) -or ($ErrCode -eq 3010) -or ($ErrCode -eq 1605)) {
Write-Host "Success" -ForegroundColor Yellow
} else {
Write-Host "Failed with error code "$ErrCode -ForegroundColor Red
}
}
}
}
}
}
Clear-Host
Set-ConsoleTitle -Title $WindowTitle
Uninstall-MSIByName
Exit-PowerShell