As we have all seen recently, it is time we get rid of Apple QuickTime from PCs as they are no longer going to update the software. I had a few ask me to publish a blanket uninstaller for QuickTime. With the help of Sapien's PowerShell Studio, I wrote this script to uninstall it from all of the machines in my firm. This uninstaller will query the Add/Remove programs for any applications named quicktime. It will uninstall any version of QuickTime. I have pre-configured the script parameters to search for apps name 'QuickTime' and use the msi switches '/qb- /norestart'.
You can download the script from here.
You can download the script from here.
1: <#
2: .SYNOPSIS
3: Apple Quicktime
4:
5: .DESCRIPTION
6: Uninstall Apple Quicktime
7:
8: .PARAMETER ApplicationName
9: A description of the ApplicationName parameter.
10:
11: .PARAMETER WindowTitle
12: Title of the PowerShell window
13:
14: .PARAMETER MSI_Switches
15: The switches used when executing the uninstallation of the MSI
16:
17: .EXAMPLE
18: powershell.exe -executionpolicy bypass -file uninstall.ps1
19:
20: .NOTES
21: ===========================================================================
22: Created with: SAPIEN Technologies, Inc., PowerShell Studio 2016 v5.2.119
23: Created on: 4/18/2016 1:44 PM
24: Created by: Mick Pletcher
25: Organization:
26: Filename: UninstallQuicktime.ps1
27: ===========================================================================
28: #>
29: param
30: (
31: [string]$ApplicationName = 'quicktime',
32: [string]$WindowTitle = 'Uninstall Apple Quicktime',
33: [string]$MSI_Switches = '/qb- /norestart'
34: )
35:
36: function Set-ConsoleTitle {
37: <#
38: .SYNOPSIS
39: Console Title
40:
41: .DESCRIPTION
42: Sets the title of the PowerShell Console
43:
44: .PARAMETER Title
45: Title of the PowerShell console
46:
47: .NOTES
48: Additional information about the function.
49: #>
50:
51: [CmdletBinding()]
52: param
53: (
54: [Parameter(Mandatory = $true)][String]$Title
55: )
56:
57: $host.ui.RawUI.WindowTitle = $Title
58: }
59:
60:
61: Function InitializeVariables {
62: $Global:BuildLog = $Env:windir + "\Waller\Logs\BuildLogs\Build.csv"
63: $Global:Errors = $null
64: $Global:LogFile = $Env:windir + "\Waller\Logs\BuildLogs\AppleQuicktime.log"
65: $Global:Phase = "Software Deployment"
66: $Global:RelativePath = (split-path $SCRIPT:MyInvocation.MyCommand.Path -parent) + "\"
67: }
68:
69: function Uninstall-MSIByName {
70: <#
71: .SYNOPSIS
72: Uninstall-MSIByName
73:
74: .DESCRIPTION
75: 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.
76:
77: .EXAMPLE
78: Uninstall-MSIByName "Adobe Reader" "/qb- /norestart"
79:
80: .NOTES
81: Additional information about the function.
82: #>
83:
84: [CmdletBinding()]
85: param ()
86:
87: $Uninstall = Get-ChildItem HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall -Recurse -ErrorAction SilentlyContinue
88: $Uninstall += Get-ChildItem HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall -Recurse -ErrorAction SilentlyContinue
89: $SearchName = "*" + $ApplicationName + "*"
90: $Executable = $Env:windir + "\system32\msiexec.exe"
91: Foreach ($Key in $Uninstall) {
92: $TempKey = $Key.Name -split "\\"
93: If ($TempKey[002] -eq "Microsoft") {
94: $Key = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + $Key.PSChildName
95: } else {
96: $Key = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" + $Key.PSChildName
97: }
98: If ((Test-Path $Key) -eq $true) {
99: $KeyName = Get-ItemProperty -Path $Key
100: If ($KeyName.DisplayName -like $SearchName) {
101: $TempKey = $KeyName.UninstallString -split " "
102: If ($TempKey[0] -eq "MsiExec.exe") {
103: Write-Host "Uninstall"$KeyName.DisplayName"....." -NoNewline
104: $Parameters = "/x " + $KeyName.PSChildName + [char]32 + $MSI_Switches
105: $ErrCode = (Start-Process -FilePath $Executable -ArgumentList $Parameters -Wait -Passthru).ExitCode
106: If (($ErrCode -eq 0) -or ($ErrCode -eq 3010) -or ($ErrCode -eq 1605)) {
107: Write-Host "Success" -ForegroundColor Yellow
108: } else {
109: Write-Host "Failed with error code "$ErrCode -ForegroundColor Red
110: }
111: }
112: }
113: }
114: }
115: }
116:
117: Clear-Host
118: Set-ConsoleTitle -Title $WindowTitle
119: Uninstall-MSIByName
120: Exit-PowerShell
121:
This script worked perfectly with PDQ Deploy. Thanks!
ReplyDelete