HP debloat script
Manual run version
Remediation script version
# List of software to check
$softwareList = @(
"HP Wolf Security",
"HP Wolf Security - Console",
"Poly Lens",
"HP Sure Run Module",
"HP Sure Recover",
"HP Security Update Service",
"HPSureShieldAI",
"HP Client Security Manager",
"HP Sure Click",
"HP Sure Run"
)
# Create the 'C:\install' folder if it does not exist
$installFolderPath = "C:\install"
if (-not (Test-Path -Path $installFolderPath)) {
New-Item -ItemType Directory -Path $installFolderPath | Out-Null
}
# Check if any software is installed
$installedSoftware = Get-WmiObject -Class Win32_Product -ErrorAction SilentlyContinue | Where-Object { $softwareList -contains $_.Name }
if ($installedSoftware) {
foreach ($software in $installedSoftware) {
"$($software.Name) is installed on the computer." | Out-File -FilePath "$installFolderPath\HP_Bloatware.txt" -Append
}
exit 1
}
else {
foreach ($software in $softwareList) {
"$software is not installed on the computer." | Out-File -FilePath "$installFolderPath\HP_Bloatware.txt" -Append
}
exit 0
}
exit 0
# List of software to check
$softwareList = @(
"HP Wolf Security",
"HP Wolf Security - Console",
"Poly Lens",
"HP Sure Run Module",
"HP Sure Recover",
"HP Security Update Service",
"HPSureShieldAI",
"HP Client Security Manager",
"HP Sure Click",
"HP Sure Run"
)
# Create the 'C:\install' folder if it does not exist
$installFolderPath = "C:\install"
if (-not (Test-Path -Path $installFolderPath)) {
New-Item -ItemType Directory -Path $installFolderPath | Out-Null
}
# Check if any software is installed
$installedSoftware = Get-WmiObject -Class Win32_Product -ErrorAction SilentlyContinue | Where-Object { $softwareList -contains $_.Name }
$removedSoftware = @()
if ($installedSoftware) {
foreach ($software in $installedSoftware) {
# "$($software.Name) is installed on the computer. Removing..." | Out-File -FilePath "$installFolderPath\HP_Bloatware.txt" -Append
$software.Uninstall()
$removedSoftware += $software.Name
}
# $removedSoftware | ForEach-Object { "removed: $_" } | Out-File -FilePath "$installFolderPath\HP_Bloatware.txt" -Append
}
else {
# "No HP Bloatware found on your PC" | Out-File -FilePath "$installFolderPath\HP_Bloatware.txt" -Append
exit 0
}
if ($removedSoftware.Count -eq $softwareList.Count) {
# "All applications were successfully removed." | Out-File -FilePath "$installFolderPath\HP_Bloatware.txt" -Append
exit 0
}
else {
# "Some applications were not removed." | Out-File -FilePath "$installFolderPath\HP_Bloatware.txt" -Append
exit 0
}
exit 0
# Check if the file exists
if (Test-Path "C:\Program Files (x86)\InstallShield Installation Information\{6468C4A5-E47E-405F-B675-A70A70983EA6}\Setup.exe") {
# Write the message to the file
# "HP Connection Optimizer is installed on the computer" | Out-File -FilePath "C:\install\HP_Bloatware_CO.txt"
# Exit with code 1 (for rememdiation script usage in Itnue)
exit 1
} else {
# "HP Connection Optimizer is not installed on the computer" | Out-File -FilePath "C:\install\HP_Bloatware-CO.txt"
# Exit with code 0 (for rememdiation script usage in Itnue)
exit 0
}
exit 0
# silently uninstall HP Connection Optimizer
# create c:\install folder if it does not exist
$installFolderPath = "C:\install"
if (-not (Test-Path -Path $installFolderPath)) {
New-Item -ItemType Directory -Path $installFolderPath | Out-Null
}
If (Test-Path "C:\Program Files (x86)\InstallShield Installation Information\{6468C4A5-E47E-405F-B675-A70A70983EA6}\Setup.exe") {
$optimizerUninstallAnswer = "[InstallShield Silent]
Version=v7.00
File=Response File
[File Transfer]
OverwrittenReadOnly=NoToAll
[{6468C4A5-E47E-405F-B675-A70A70983EA6}-DlgOrder]
Dlg0={6468C4A5-E47E-405F-B675-A70A70983EA6}-SdWelcomeMaint-0
Count=3
Dlg1={6468C4A5-E47E-405F-B675-A70A70983EA6}-MessageBox-0
Dlg2={6468C4A5-E47E-405F-B675-A70A70983EA6}-SdFinishReboot-0
[{6468C4A5-E47E-405F-B675-A70A70983EA6}-SdWelcomeMaint-0]
Result=303
[{6468C4A5-E47E-405F-B675-A70A70983EA6}-MessageBox-0]
Result=6
[Application]
Name=HP Connection Optimizer
Version=2.0.18.0
Company=HP Inc.
Lang=0409
[{6468C4A5-E47E-405F-B675-A70A70983EA6}-SdFinishReboot-0]
Result=1
BootOption=0
"
$optimizerUninstallAnswer | Out-File $env:TEMP\optimizer.iss
$arguments = "/s /f1`"$env:Temp\optimizer.iss`" /f2`"$env:TEMP\Uninstall.log`""
Start-Process "C:\Program Files (x86)\InstallShield Installation Information\{6468C4A5-E47E-405F-B675-A70A70983EA6}\Setup.exe" -ArgumentList $arguments -PassThru -Wait
"Removing HP Connection Optimizer from the computer." | Out-File -FilePath "$installFolderPath\HP_Bloatware_CO.txt" -Append
exit 0
}
else {
"Removal found HP Connection Optimizer is not installed on the computer." | Out-File -FilePath "$installFolderPath\HP_Bloatware_CO.txt" -Append
exit 0
}
exit 0