Skip to content

Instantly share code, notes, and snippets.

@jhamilton09
Created April 19, 2016 15:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jhamilton09/8dd790d9d698bc333820da7ecae653f1 to your computer and use it in GitHub Desktop.
Save jhamilton09/8dd790d9d698bc333820da7ecae653f1 to your computer and use it in GitHub Desktop.
PowerShell script to uninstall QuickTime for Windows
<#
Name of the script: UninstallQuickTime.ps1
Author of the script: Jason Hamilton
Author contact information: https://www.404techsupport.com/
Version of the script: 0.1
Where you got the idea: QuickTime deprecated by Apple
Version of PowerShell required: 3.0
If Elevated permissions required: Yes
If specific modules are required: No
Comments about new types of constructions:
Comments about specific cmdlets:
Ideas for future improvement:
Known errors:
#>
#Check to see if server is reachable before proceeding
if (Test-connection server.fqdn -quiet) {
$cn = $env:COMPUTERNAME
$Receipt = [string]::concat("\\server.fqdn\share\folder\Logs\QuickTime\", $cn, ".txt")
# Check if receipt exists. If it does, uninstall not needed and exit
If (Test-Path $Receipt){
exit
} else {
#Receipt does not exist, uninstall has never run before
#Log initial receipt
$timestamp = get-date -f "MM/dd/yyyy HH:mm"
Write-Output "Uninstall started $timestamp" | Out-File -FilePath $Receipt
#Gets QuickTime installed instances from the Registry
$QTreg = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object {$_.DisplayName -match "Quicktime" } | Select-Object -Property DisplayName, UninstallString
#Loop through results
ForEach ($QT in $QTreg) {
If ($QT.UninstallString) {
$displayname = $QT.DisplayName
$uninstall = $QT.UninstallString
Write-Output "Display name: $displayname" | Out-File -FilePath $Receipt -Append
#Swap install parameter for uninstall in string
$uninstall = $uninstall -replace "/I", "/x "
Write-Output "Uninstall string: $uninstall" | Out-File -FilePath $Receipt -Append
#Use Uninstall string to initiate removal
Start-Process cmd.exe -ArgumentList "/c $uninstall /quiet /norestart" -NoNewWindow
}
}
#Log receipt conclusion
$timestamp = get-date -f "MM/dd/yyyy HH:mm"
Write-Output "Script completed $timestamp" | Out-File -FilePath $Receipt -Append
}
}
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment