Skip to content

Instantly share code, notes, and snippets.

@mark05e
Last active May 10, 2024 10:51
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save mark05e/2db81671f39a041a5992a64a77748dc7 to your computer and use it in GitHub Desktop.
Save mark05e/2db81671f39a041a5992a64a77748dc7 to your computer and use it in GitHub Desktop.
# ██████╗ ███████╗███╗ ███╗ ██████╗ ██╗ ██╗███████╗ ██╗ ██╗██████╗
# ██╔══██╗██╔════╝████╗ ████║██╔═══██╗██║ ██║██╔════╝ ██║ ██║██╔══██╗
# ██████╔╝█████╗ ██╔████╔██║██║ ██║██║ ██║█████╗ ███████║██████╔╝
# ██╔══██╗██╔══╝ ██║╚██╔╝██║██║ ██║╚██╗ ██╔╝██╔══╝ ██╔══██║██╔═══╝
# ██║ ██║███████╗██║ ╚═╝ ██║╚██████╔╝ ╚████╔╝ ███████╗ ██║ ██║██║
# ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═══╝ ╚══════╝ ╚═╝ ╚═╝╚═╝
#
# ██████╗ ██╗ ██████╗ █████╗ ████████╗██╗ ██╗ █████╗ ██████╗ ███████╗
# ██╔══██╗██║ ██╔═══██╗██╔══██╗╚══██╔══╝██║ ██║██╔══██╗██╔══██╗██╔════╝
# ██████╔╝██║ ██║ ██║███████║ ██║ ██║ █╗ ██║███████║██████╔╝█████╗
# ██╔══██╗██║ ██║ ██║██╔══██║ ██║ ██║███╗██║██╔══██║██╔══██╗██╔══╝
# ██████╔╝███████╗╚██████╔╝██║ ██║ ██║ ╚███╔███╔╝██║ ██║██║ ██║███████╗
# ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝
#
# ██████╗ ███████╗████████╗ █████╗
# ██╔══██╗██╔════╝╚══██╔══╝██╔══██╗
# ██████╔╝█████╗ ██║ ███████║
# ██╔══██╗██╔══╝ ██║ ██╔══██║
# ██████╔╝███████╗ ██║ ██║ ██║
# ╚═════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝
#
# Remove HP bloatware / crapware - BETA version
#
# -- source : https://gist.github.com/mark05e/a79221b4245962a477a49eb281d97388
# -- contrib: francishagyard2, mark05E, erottier, JoachimBerghmans, sikkepitje, Ithendyr
# -- note : this script could use your improvements. contributions welcome!
# List of built-in apps to remove
$UninstallPackages = @(
"AD2F1837.HPJumpStarts"
"AD2F1837.HPPCHardwareDiagnosticsWindows"
"AD2F1837.HPPowerManager"
"AD2F1837.HPPrivacySettings"
"AD2F1837.HPSupportAssistant"
"AD2F1837.HPSureShieldAI"
"AD2F1837.HPSystemInformation"
"AD2F1837.HPQuickDrop"
"AD2F1837.HPWorkWell"
"AD2F1837.myHP"
"AD2F1837.HPDesktopSupportUtilities"
"AD2F1837.HPQuickTouch"
"AD2F1837.HPEasyClean"
"AD2F1837.HPSystemInformation"
)
# List of programs to uninstall
$UninstallPrograms = @(
"HP Device Access Manager"
"HP Client Security Manager"
"HP Connection Optimizer"
"HP Documentation"
"HP MAC Address Manager"
"HP Notifications"
"HP System Info HSA Service"
"HP Security Update Service"
"HP System Default Settings"
"HP Sure Click"
"HP Sure Click Security Browser"
"HP Sure Run"
"HP Sure Run Module"
"HP Sure Recover"
"HP Sure Sense"
"HP Sure Sense Installer"
"HP Wolf Security"
"HP Wolf Security - Console"
"HP Wolf Security Application Support for Sure Sense"
"HP Wolf Security Application Support for Windows"
)
$HPidentifier = "AD2F1837"
$InstalledPackages = Get-AppxPackage -AllUsers `
| Where-Object {($UninstallPackages -contains $_.Name) -or ($_.Name -match "^$HPidentifier")}
$ProvisionedPackages = Get-AppxProvisionedPackage -Online `
| Where-Object {($UninstallPackages -contains $_.DisplayName) -or ($_.DisplayName -match "^$HPidentifier")}
$InstalledPrograms = Get-Package | Where-Object {$UninstallPrograms -contains $_.Name}
# Stop HP Services
Function StopDisableService($name) {
if (Get-Service -Name $name -ea SilentlyContinue) {
Stop-Service -Name $name -Force -Confirm:$False
Set-Service -Name $name -StartupType Disabled
}
}
StopDisableService -name "HotKeyServiceUWP"
StopDisableService -name "HPAppHelperCap"
StopDisableService -name "HP Comm Recover"
StopDisableService -name "HPDiagsCap"
StopDisableService -name "HotKeyServiceUWP"
StopDisableService -name "LanWlanWwanSwitchgingServiceUWP" # do we need to stop this?
StopDisableService -name "HPNetworkCap"
StopDisableService -name "HPSysInfoCap"
StopDisableService -name "HP TechPulse Core"
# Remove installed programs
$InstalledPrograms | ForEach-Object {
Write-Host -Object "Attempting to uninstall: [$($_.Name)]..."
Try {
$Null = $_ | Uninstall-Package -AllVersions -Force -ErrorAction Stop
Write-Host -Object "Successfully uninstalled: [$($_.Name)]"
}
Catch {
Write-Warning -Message "Failed to uninstall: [$($_.Name)]"
Write-Host -Object "Attempting to uninstall as MSI package: [$($_.Name)]..."
Try {
$product = Get-WmiObject win32_product | where { $_.name -like "$($_.Name)" }
if ($_ -ne $null) {
msiexec /x $product.IdentifyingNumber /quiet /noreboot
}
else { Write-Warning -Message "Can't find MSI package: [$($_.Name)]" }
}
Catch { Write-Warning -Message "Failed to uninstall MSI package: [$($_.Name)]" }
}
}
# Fallback attempt 1 to remove HP Wolf Security using msiexec
Try {
MsiExec /x "{0E2E04B0-9EDD-11EB-B38C-10604B96B11E}" /qn /norestart
Write-Host -Object "Fallback to MSI uninistall for HP Wolf Security initiated"
}
Catch {
Write-Warning -Object "Failed to uninstall HP Wolf Security using MSI - Error message: $($_.Exception.Message)"
}
# Fallback attempt 2 to remove HP Wolf Security using msiexec
Try {
MsiExec /x "{4DA839F0-72CF-11EC-B247-3863BB3CB5A8}" /qn /norestart
Write-Host -Object "Fallback to MSI uninistall for HP Wolf 2 Security initiated"
}
Catch {
Write-Warning -Object "Failed to uninstall HP Wolf Security 2 using MSI - Error message: $($_.Exception.Message)"
}
# Remove appx provisioned packages - AppxProvisionedPackage
ForEach ($ProvPackage in $ProvisionedPackages) {
Write-Host -Object "Attempting to remove provisioned package: [$($ProvPackage.DisplayName)]..."
Try {
$Null = Remove-AppxProvisionedPackage -PackageName $ProvPackage.PackageName -Online -ErrorAction Stop
Write-Host -Object "Successfully removed provisioned package: [$($ProvPackage.DisplayName)]"
}
Catch {Write-Warning -Message "Failed to remove provisioned package: [$($ProvPackage.DisplayName)]"}
}
# Remove appx packages - AppxPackage
ForEach ($AppxPackage in $InstalledPackages) {
Write-Host -Object "Attempting to remove Appx package: [$($AppxPackage.Name)]..."
Try {
$Null = Remove-AppxPackage -Package $AppxPackage.PackageFullName -AllUsers -ErrorAction Stop
Write-Host -Object "Successfully removed Appx package: [$($AppxPackage.Name)]"
}
Catch {Write-Warning -Message "Failed to remove Appx package: [$($AppxPackage.Name)]"}
}
# # Uncomment this section to see what is left behind
# Write-Host "Checking stuff after running script"
# Write-Host "For Get-AppxPackage -AllUsers"
# Get-AppxPackage -AllUsers | where {$_.Name -like "*HP*"}
# Write-Host "For Get-AppxProvisionedPackage -Online"
# Get-AppxProvisionedPackage -Online | where {$_.DisplayName -like "*HP*"}
# Write-Host "For Get-Package"
# Get-Package | select Name, FastPackageReference, ProviderName, Summary | Where {$_.Name -like "*HP*"} | Format-List
# # Feature - Ask for reboot after running the script
# $input = Read-Host "Restart computer now [y/n]"
# switch($input){
# y{Restart-computer -Force -Confirm:$false}
# n{exit}
# default{write-warning "Skipping reboot."}
# }
@mark05e
Copy link
Author

mark05e commented Feb 26, 2023

@jkerekes99 - I've just added Device Access Manager to the list.

@jkerekes99
Copy link

jkerekes99 commented Feb 26, 2023

@mark05e thank you for adding Device Access Manager to the list, however running the new script, it still goes straight to uninstalling HP Client Security Manager and I get the same error as in my previous screenshot.

Is it an ordering issue or is the script not detecting "HP Device Access Manager"?

It is definitely still installed:
https://www.dropbox.com/s/mhxnraybgh93ohn/Screenshot%202023-02-26%20232932.png?dl=0

@lms93
Copy link

lms93 commented Feb 28, 2023

@mark05e thank you for adding Device Access Manager to the list, however running the new script, it still goes straight to uninstalling HP Client Security Manager and I get the same error as in my previous screenshot.

Is it an ordering issue or is the script not detecting "HP Device Access Manager"?

It is definitely still installed: https://www.dropbox.com/s/mhxnraybgh93ohn/Screenshot%202023-02-26%20232932.png?dl=0

Yip having the same issue here

@mark05e
Copy link
Author

mark05e commented Mar 1, 2023

@jkerekes99 @lms93 - could you try the updated code?

I've moved some of the uninstall code further down inorder to help with the uninstall sequence.

@jkerekes99
Copy link

@mark05e I just tried the updated script, unfortunately, the first line of output is to attempt to uninstall "HP Client Security Manager" which again fails because HP Device Access Manager is still installed.

@lms93
Copy link

lms93 commented Mar 5, 2023

Hey Mark,
I've tried the updated code. I'm using it to target solely, HP Notifications, Wolf Security and HP Support Assistant.
It looks like all of these are being uninstalled, the only thing is HP Support Assistant is not uninstalling silently. I think it needs to use switch /s /v/qn UninstallKeepPreferences=FALSE

List of built-in apps to remove

$UninstallPackages = @(
"AD2F1837.HPSupportAssistant"
"AD2F1837.HPSureShieldAI"

)

List of programs to uninstall

$UninstallPrograms = @(
"HP Documentation"
"HP Support Assistant"
"HP Notifications"
"HP Wolf Security"
"HP Wolf Security Application Support for Sure Sense"
"HP Wolf Security Application Support for Windows"
)

$HPidentifier = "AD2F1837"

$InstalledPackages = Get-AppxPackage -AllUsers `
| Where-Object {($UninstallPackages -contains $.Name) -or ($.Name -match "^$HPidentifier")}

$ProvisionedPackages = Get-AppxProvisionedPackage -Online `
| Where-Object {($UninstallPackages -contains $.DisplayName) -or ($.DisplayName -match "^$HPidentifier")}

$InstalledPrograms = Get-Package | Where-Object {$UninstallPrograms -contains $_.Name}

Remove appx provisioned packages - AppxProvisionedPackage

ForEach ($ProvPackage in $ProvisionedPackages) {

Write-Host -Object "Attempting to remove provisioned package: [$($ProvPackage.DisplayName)]..."

Try {
    $Null = Remove-AppxProvisionedPackage -PackageName $ProvPackage.PackageName -Online -ErrorAction Stop
    Write-Host -Object "Successfully removed provisioned package: [$($ProvPackage.DisplayName)]"
}
Catch {Write-Warning -Message "Failed to remove provisioned package: [$($ProvPackage.DisplayName)]"}

}

Remove appx packages - AppxPackage

ForEach ($AppxPackage in $InstalledPackages) {

Write-Host -Object "Attempting to remove Appx package: [$($AppxPackage.Name)]..."

Try {
    $Null = Remove-AppxPackage -Package $AppxPackage.PackageFullName -AllUsers -ErrorAction Stop
    Write-Host -Object "Successfully removed Appx package: [$($AppxPackage.Name)]"
}
Catch {Write-Warning -Message "Failed to remove Appx package: [$($AppxPackage.Name)]"}

}

Remove installed programs

$InstalledPrograms | ForEach-Object {

Write-Host -Object "Attempting to uninstall: [$($_.Name)]..."

Try {
    $Null = $_ | Uninstall-Package -AllVersions -Force -ErrorAction Stop
    Write-Host -Object "Successfully uninstalled: [$($_.Name)]"
}
Catch {Write-Warning -Message "Failed to uninstall: [$($_.Name)]"}

}

Fallback attempt 1 to remove HP Wolf Security using msiexec

Try {
MsiExec /x "{0E2E04B0-9EDD-11EB-B38C-10604B96B11E}" /qn /norestart
Write-Host -Object "Fallback to MSI uninistall for HP Wolf Security initiated"
}
Catch {
Write-Warning -Object "Failed to uninstall HP Wolf Security using MSI - Error message: $($_.Exception.Message)"
}

Fallback attempt 2 to remove HP Wolf Security using msiexec

Try {
MsiExec /x "{4DA839F0-72CF-11EC-B247-3863BB3CB5A8}" /qn /norestart
Write-Host -Object "Fallback to MSI uninistall for HP Wolf 2 Security initiated"
}
Catch {
Write-Warning -Object "Failed to uninstall HP Wolf Security 2 using MSI - Error message: $($_.Exception.Message)"
}

@jake9000
Copy link

jake9000 commented Mar 16, 2023

I have found luck with this exact syntax for HP Support Assist

$hpsauninstall = gci "${env:programfiles(x86)}\*\*\uninstallhpsa.exe" | select -expand fullname
$hpsa = start-process $hpsauninstall -argumentlist "/s /v/qn UninstallKeepPreferences=FALSE" -wait

Basically HP does not consistently name its directories and the uninstaller seems to do okay with this invoke method but not others from what I have seen.

I had 2 deployments (undeployments?) where the process got stuck forever, but after terminating uninstallhpsa.exe the uninstallation completed on its own. I no longer have any hpsav8 devices to iron that down with though, nor a copy of hpsav8 to test with locally. Maybe wrapping this in a timer that terminates after a few minutes could help with reliability.

@janwillem-v
Copy link

We've added the line: REG DELETE HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Streams\Desktop /F
To remove that HP question-mark icon from the taskbar.

Nice script! Many thanks.

@cwrsimon
Copy link

Great job! Thank you so much for sharing!

@kmt7br6
Copy link

kmt7br6 commented Jul 7, 2023

I have been trying to use this script but with the exclusion of "HP Support Assistant"
To do so I removed support assistant from the list at the beginning of the script
Yet every time I run it, the support assistant is also removed.

How would I exclude the support assistant from being uninstalled please?

Thank you!
Kind regards

@mark05e
Copy link
Author

mark05e commented Jul 13, 2023

@kmt7br6 Can you update these lines and see if it works? This is along with the exclusions you have already done.

$InstalledPackages = Get-AppxPackage -AllUsers `
            | Where-Object {($UninstallPackages -contains $_.Name)

$ProvisionedPackages = Get-AppxProvisionedPackage -Online `
            | Where-Object {($UninstallPackages -contains $_.DisplayName) 

Original lines https://gist.github.com/mark05e/2db81671f39a041a5992a64a77748dc7#file-remove-hpbloatware-beta-ps1-L72-L76

@duaneking
Copy link

Rebooted due to a forced update now I'm dealing with this BS again; IMHO this is nothing less than spyware installed to gather competitive intelligence on their customers, and I never consented to it as the owner of the hardware.

@kmt7br6
Copy link

kmt7br6 commented Jul 26, 2023

@kmt7br6 Can you update these lines and see if it works? This is along with the exclusions you have already done.

$InstalledPackages = Get-AppxPackage -AllUsers `
            | Where-Object {($UninstallPackages -contains $_.Name)

$ProvisionedPackages = Get-AppxProvisionedPackage -Online `
            | Where-Object {($UninstallPackages -contains $_.DisplayName) 

Original lines https://gist.github.com/mark05e/2db81671f39a041a5992a64a77748dc7#file-remove-hpbloatware-beta-ps1-L72-L76

OK it took me a while to get back to this "project", but the proposed change alone didn't fix my issue.
in the end, what solved the actual issue was changing the operator from -contains to -in

Additional to that I made some additional changes to the script while i was troubleshooting

So the operators that have been changed now that part of the code look like this:
$InstalledPackages = Get-AppxPackage -AllUsers
| Where-Object {($UninstallPackages -in $_.Name)}

$ProvisionedPackages = Get-AppxProvisionedPackage -Online `
            | Where-Object {($UninstallPackages -in $_.DisplayName)}

$InstalledPrograms = Get-Package | Where-Object {$UninstallPrograms -in $_.Name}`

In next part of code i have put the services in a matrix and first check if they are running or not, and only stop them if they are running.
No real added value except that i find it easier to maintain the services in a list

`# List of services to disable

$DisableServices = @(
    "HotKeyServiceUWP"
    "HPAppHelperCap"
    "HP Comm Recover"
    "HPDiagsCap"
    "HotKeyServiceUWP"
    "LanWlanWwanSwitchgingServiceUWP"
    "HPNetworkCap"
    "HPSysInfoCap"
    "HP TechPulse Core"
)

Stop HP Services

Function StopDisableService($name) {

    if (Get-Service -Name $name -ea SilentlyContinue) {

        if ((Get-Service -Name $name).Status -eq 'Running') {

            Write-Host "Service '$name' is running. Executing code..."

                Stop-Service -Name $name -Force -Confirm:$False
                Set-Service -Name $name -StartupType Disabled

        }

        else {

            Write-Host "Service '$name' is not running. Code execution skipped."

        }
    }
}

foreach ($serv in $DisableServices){

        StopDisableService -name $serv

    }`

And finally at the end of the code you have the section where you check what is left behind, here i did some modifications so I get some output of what is left behind, making my code look like this:

`# Uncomment this section to see what is left behind

Write-Host "Checking stuff after running script"
Write-Host "For Get-AppxPackage -AllUsers"

    $skippedPackages = Get-AppxPackage -AllUsers `
                | Where-Object {$_.Name -like "*HP*"}

    foreach ($skipApp in $skippedPackages){

        Write-Host "Skipped App: '$skipApp'"

    }


Write-Host "For Get-AppxProvisionedPackage -Online"

    $skippedProvision = Get-AppxProvisionedPackage -Online `
                | Where-Object {$_.DisplayName -like "*HP*"}

    foreach ($skipProv in $skippedProvision){

        Write-Host "Skipped provisioned app: '$skipProv'"

    }

Write-Host "For Get-Package"

    $skippedProgram = Get-Package | select Name, FastPackageReference, ProviderName, Summary | Where {$_.Name -like "*HP*"} | Format-List

    foreach ($skipProg in $skippedProgram){

        Write-Host "Skipped Program: '$skipProg'"

    }`

@ChrisWarrenCodux
Copy link

Below is what is my take on disabling the HP services, with the code matching the app removal sequences.

# List of services to disable
$DisableServices = @(
    "HotKeyServiceUWP"
    "HPAppHelperCap"
    "HP Comm Recover"
    "HPDiagsCap"
    "HotKeyServiceUWP"
    "HPNetworkCap"
    "HPSysInfoCap"
    "HP TechPulse Core"
)

$InstalledServices = Get-Service | Where-Object{$DisableServices  -contains $_.Name}

# Disable HP services
ForEach ($Service in $InstalledServices) {

  Write-Host -Object "Attempting to stop HP service: [$($Service.DisplayName)]..."

  Try {
      $Null = Stop-Service -Name $Service.Name -Force -Confirm:$False -ErrorAction Stop
      $Null = Set-Service -Name $Service.Name -StartupType Disabled -ErrorAction Stop
      Write-Host -Object "Successfully stoped HP service: [$($Service.DisplayName)]"
  }
  Catch {Write-Warning -Message "Failed to stop HP service: [$($Service.DisplayName)]"}
}

@CKPIPSC
Copy link

CKPIPSC commented Oct 6, 2023

I am trying to use this script to uninstall HP Bloatware but I am failing with:

HP Connection Optimizer
HP Documentation
HP Wolf Security
HP Wolf Security - Console
HP Security Update Service

-- however these did work

HP Wolf Security Application Support for Sure Sense
HP Wolf Security Application Support for Sure Sense
HP Sure Recover
HP Sure Run Module
HP Notifications
HP System Default Settings

This is what I used (if I run the script 5-6 times in a row it works) and I am trying to push this through intune.

# List of built-in apps to remove
$UninstallPackages = @(
    "AD2F1837.HPJumpStarts"
    "AD2F1837.HPPCHardwareDiagnosticsWindows"
    "AD2F1837.HPPowerManager"
    "AD2F1837.HPPrivacySettings"
    "AD2F1837.HPSupportAssistant"
    "AD2F1837.HPSureShieldAI"
    "AD2F1837.HPSystemInformation"
    "AD2F1837.HPQuickDrop"
    "AD2F1837.HPWorkWell"
    "AD2F1837.myHP"
    "AD2F1837.HPDesktopSupportUtilities"
    "AD2F1837.HPQuickTouch"
    "AD2F1837.HPEasyClean"
    "AD2F1837.HPSystemInformation"
)

# List of programs to uninstall
$UninstallPrograms = @(
    "HP Device Access Manager"
    "HP Client Security Manager"
    "HP Connection Optimizer"
    "HP Documentation"
    "HP MAC Address Manager"
    "HP Notifications"
    "HP System Info HSA Service"
    "HP Security Update Service"
    "HP System Default Settings"
    "HP Sure Click"
    "HP Sure Click Security Browser"
    "HP Sure Run"
    "HP Sure Run Module"
    "HP Sure Recover"
    "HP Sure Sense"
    "HP Sure Sense Installer"
    "HP Wolf Security"
    "HP Wolf Security - Console"
    "HP Wolf Security Application Support for Sure Sense"
    "HP Wolf Security Application Support for Windows"
)

$HPidentifier = "AD2F1837"

$InstalledPackages = Get-AppxPackage -AllUsers `
            | Where-Object {($UninstallPackages -contains $_.Name) -or ($_.Name -match "^$HPidentifier")}

$ProvisionedPackages = Get-AppxProvisionedPackage -Online `
            | Where-Object {($UninstallPackages -contains $_.DisplayName) -or ($_.DisplayName -match "^$HPidentifier")}

$InstalledPrograms = Get-Package | Where-Object {$UninstallPrograms -contains $_.Name}

# Stop HP Services
Function StopDisableService($name) {
    if (Get-Service -Name $name -ea SilentlyContinue) {
        Stop-Service -Name $name -Force -Confirm:$False
        Set-Service -Name $name -StartupType Disabled
    }
}

StopDisableService -name "HotKeyServiceUWP"
StopDisableService -name "HPAppHelperCap"
StopDisableService -name "HP Comm Recover"
StopDisableService -name "HPDiagsCap"
StopDisableService -name "HotKeyServiceUWP"
StopDisableService -name "LanWlanWwanSwitchgingServiceUWP" # do we need to stop this?
StopDisableService -name "HPNetworkCap"
StopDisableService -name "HPSysInfoCap"
StopDisableService -name "HP TechPulse Core"

# Remove installed programs
$InstalledPrograms | ForEach-Object {

  Write-Host -Object "Attempting to uninstall: [$($_.Name)]..."

  Try {
      $Null = $_ | Uninstall-Package -AllVersions -Force -ErrorAction Stop
      Write-Host -Object "Successfully uninstalled: [$($_.Name)]"
  }
  Catch {
    Write-Warning -Message "Failed to uninstall: [$($_.Name)]"
    
    Write-Host -Object "Attempting to uninstall as MSI package: [$($_.Name)]..."
    Try {
      $product = Get-WmiObject win32_product | where { $_.name -like "$($_.Name)" }
      if ($_ -ne $null) {
        msiexec /x $product.IdentifyingNumber /quiet /noreboot
      }
      else { Write-Warning -Message "Can't find MSI package: [$($_.Name)]" }
    }
    Catch { Write-Warning -Message "Failed to uninstall MSI package: [$($_.Name)]" }
    }
}

# Fallback attempt 1 to remove HP Wolf Security using msiexec
Try {
    MsiExec /x "{0E2E04B0-9EDD-11EB-B38C-10604B96B11E}" /qn /norestart
    Write-Host -Object "Fallback to MSI uninistall for HP Wolf Security initiated"
}
Catch {
    Write-Warning -Object "Failed to uninstall HP Wolf Security using MSI - Error message: $($_.Exception.Message)"
}

# Fallback attempt 2 to remove HP Wolf Security using msiexec
Try {
    MsiExec /x "{4DA839F0-72CF-11EC-B247-3863BB3CB5A8}" /qn /norestart
    Write-Host -Object "Fallback to MSI uninistall for HP Wolf 2 Security initiated"
}
Catch {
    Write-Warning -Object  "Failed to uninstall HP Wolf Security 2 using MSI - Error message: $($_.Exception.Message)"
}

# Remove appx provisioned packages - AppxProvisionedPackage
ForEach ($ProvPackage in $ProvisionedPackages) {

    Write-Host -Object "Attempting to remove provisioned package: [$($ProvPackage.DisplayName)]..."

    Try {
        $Null = Remove-AppxProvisionedPackage -PackageName $ProvPackage.PackageName -Online -ErrorAction Stop
        Write-Host -Object "Successfully removed provisioned package: [$($ProvPackage.DisplayName)]"
    }
    Catch {Write-Warning -Message "Failed to remove provisioned package: [$($ProvPackage.DisplayName)]"}
}

# Remove appx packages - AppxPackage
ForEach ($AppxPackage in $InstalledPackages) {
                                            
    Write-Host -Object "Attempting to remove Appx package: [$($AppxPackage.Name)]..."

    Try {
        $Null = Remove-AppxPackage -Package $AppxPackage.PackageFullName -AllUsers -ErrorAction Stop
        Write-Host -Object "Successfully removed Appx package: [$($AppxPackage.Name)]"
    }
    Catch {Write-Warning -Message "Failed to remove Appx package: [$($AppxPackage.Name)]"}
}

# # Uncomment this section to see what is left behind
# Write-Host "Checking stuff after running script"
# Write-Host "For Get-AppxPackage -AllUsers"
# Get-AppxPackage -AllUsers | where {$_.Name -like "*HP*"}
# Write-Host "For Get-AppxProvisionedPackage -Online"
# Get-AppxProvisionedPackage -Online | where {$_.DisplayName -like "*HP*"}
# Write-Host "For Get-Package"
# Get-Package | select Name, FastPackageReference, ProviderName, Summary | Where {$_.Name -like "*HP*"} | Format-List

# # Feature - Ask for reboot after running the script
# $input = Read-Host "Restart computer now [y/n]"
# switch($input){
#           y{Restart-computer -Force -Confirm:$false}
#           n{exit}
#     default{write-warning "Skipping reboot."}
# }

@Netweezurd
Copy link

Hey Mark !
Thanks for this and hope it can move forward... the idea behind these bloatware is flawed and us, the IT techs of this world, we have to waste time waging war againt that garbage. But don't tell them that... with their closed minds... they'll tell you to efff off.

Back to the script, on execution, I think at line 114
msiexec /x $product.IdentifyingNumber /quiet /noreboot
I get a syntax error that pops up the syntax window.
I think "/quiet" is a "/i" install only argument and "/noreboot" is nowhere to be seen on Microsoft's MSIEXEC syntax page .
I rewrote it to :
msiexec /x $product.IdentifyingNumber /qn /norestart
HF

@jkraycfgi
Copy link

jkraycfgi commented Jan 30, 2024

Hello Mark [@mark05e] and everyone,

We have been using the original script with success as needed but after we have been having HP units boot to a 'User Profile Service failed to start' upon login. Some research is showing that 'MyHP' application on the units are causing the profile login issues so we decided to revisit the script to make sure we officially get all the HP junk off of our devices.

I compiled a mix of the changes above to the original script and I am having luck with the below running remotely with a successful completion, but not total removal of all the HP software.

I get some errors on the "HP Wolf Security - Console" and "HP Security Update Service" program. It seems the script below is having some issues pulling those specific modules and they are dependent on each other. Are there any services associated that may need to be ended first?

Application 'C:\Windows\explorer.exe' (pid 15272) cannot be restarted - Application SID does not match Conductor SID..	Microsoft-Windows-RestartManager
1/30/2024, 5:57 PM	10010	Warning	Application	Application 'C:\Windows\explorer.exe' (pid 15272) cannot be restarted - Application SID does not match Conductor SID..	Microsoft-Windows-RestartManager
1/30/2024, 5:56 PM	10010	Warning	Application	Application 'C:\Program Files (x86)\HP\HP Notifications\HPNotifications.exe' (pid 12404) cannot be restarted - Application SID does not match Conductor SID..	Microsoft-Windows-RestartManager
1/30/2024, 5:56 PM	10010	Warning	Application	Application 'C:\Program Files (x86)\HP\HP Notifications\HPNotifications.exe' (pid 12404) cannot be restarted - Application SID does not match Conductor SID..	Microsoft-Windows-RestartManager
**1/30/2024, 5:56 PM	10005	Error	Application	Product: HP Security Update Service -- HP Security Update Service is in use. If you wish to remove it, please uninstall other software first: HP Wolf Security - Console.**
# List of built-in apps to remove
$UninstallPackages = @(
    "AD2F1837.HPJumpStarts"
    "AD2F1837.HPPCHardwareDiagnosticsWindows"
    "AD2F1837.HPPowerManager"
    "AD2F1837.HPPrivacySettings"
    "AD2F1837.HPSupportAssistant"
    "AD2F1837.HPSureShieldAI"
    "AD2F1837.HPSystemInformation"
    "AD2F1837.HPQuickDrop"
    "AD2F1837.HPWorkWell"
    "AD2F1837.myHP"
    "AD2F1837.HPDesktopSupportUtilities"
    "AD2F1837.HPQuickTouch"
    "AD2F1837.HPEasyClean"
    "AD2F1837.HPSystemInformation"
    "Microsoft.GetHelp"
    "Microsoft.Getstarted"
    "Microsoft.MicrosoftOfficeHub"
    "Microsoft.MicrosoftSolitaireCollection"
    "Microsoft.People"
    "microsoft.windowscommunicationsapps"
    "Microsoft.WindowsFeedbackHub"
    "Microsoft.Xbox.TCUI"
    "Microsoft.XboxGameOverlay"
    "Microsoft.XboxGamingOverlay"
    "Microsoft.XboxIdentityProvider"
    "Microsoft.XboxSpeechToTextOverlay"
    "Microsoft.XboxApp"
    "Microsoft.Wallet"
    "Microsoft.SkyeApp"
    "Microsoft.BingWeather"
)

# List of programs to uninstall
$UninstallPrograms = @(
    "HP Client Security Manager"
    "HP Connection Optimizer"
    "HP Documentation"
    "HP MAC Address Manager"
    "HP Notifications"
    "HP Security Update Service"
    "HP System Default Settings"
    "HP Sure Click"
    "HP Sure Click Security Browser"
    "HP Sure Run"
    "HP Sure Run Module"
    "HP Sure Recover"
    "HP Sure Sense"
    "HP Sure Sense Installer"
    "HP ICS"
    "HP Assess and Respond"
    "HP Wolf Security"
    "HP Wolf Security - Console"
    "HP Wolf Security Application Support for Sure Sense"
    "HP Wolf Security Application Support for Windows"
)

$HPidentifier = "AD2F1837"

$InstalledPackages = Get-AppxPackage -AllUsers '
            | Where-Object {($UninstallPackages -contains $_.Name) -or ($_.Name -match "^$HPidentifier")}

$ProvisionedPackages = Get-AppxProvisionedPackage -Online '
            | Where-Object {($UninstallPackages -contains $_.DisplayName) -or ($_.DisplayName -match "^$HPidentifier")}

$InstalledPrograms = Get-Package | Where-Object {$UninstallPrograms -contains $_.Name}

# List of services to disable

$DisableServices = @(
    "HotKeyServiceUWP"
    "HPAppHelperCap"
    "HP Comm Recover"
    "HPDiagsCap"
    "HotKeyServiceUWP"
    "HPNetworkCap"
    "HPSysInfoCap"
    "HP TechPulse Core"
)

#Stop HP Services
Function StopDisableService($name) {

    if (Get-Service -Name $name -ea SilentlyContinue) {

        if ((Get-Service -Name $name).Status -eq 'Running') {

            Write-Host "Service '$name' is running. Executing code..."

                Stop-Service -Name $name -Force -Confirm:$False
                Set-Service -Name $name -StartupType Disabled

        }

        else {

            Write-Host "Service '$name' is not running. Code execution skipped."

        }
    }
}

foreach ($serv in $DisableServices){

        StopDisableService -name $serv

    }

# Remove appx provisioned packages - AppxProvisionedPackage
ForEach ($ProvPackage in $ProvisionedPackages) {

    Write-Host -Object "Attempting to remove provisioned package: [$($ProvPackage.DisplayName)]..."

    Try {
        $Null = Remove-AppxProvisionedPackage -PackageName $ProvPackage.PackageName -Online -ErrorAction Stop
        Write-Host -Object "Successfully removed provisioned package: [$($ProvPackage.DisplayName)]"
    }
    Catch {Write-Warning -Message "Failed to remove provisioned package: [$($ProvPackage.DisplayName)]"}
}

# Remove appx packages - AppxPackage
ForEach ($AppxPackage in $InstalledPackages) {
                                            
    Write-Host -Object "Attempting to remove Appx package: [$($AppxPackage.Name)]..."

    Try {
        $Null = Remove-AppxPackage -Package $AppxPackage.PackageFullName -AllUsers -ErrorAction Stop
        Write-Host -Object "Successfully removed Appx package: [$($AppxPackage.Name)]"
    }
    Catch {Write-Warning -Message "Failed to remove Appx package: [$($AppxPackage.Name)]"}
}

# Remove installed programs
$InstalledPrograms | ForEach-Object {

    Write-Host -Object "Attempting to uninstall: [$($_.Name)]..."

    Try {
        $Null = $_ | Uninstall-Package -AllVersions -Force -ErrorAction Stop
        Write-Host -Object "Successfully uninstalled: [$($_.Name)]"
    }
    Catch {Write-Warning -Message "Failed to uninstall: [$($_.Name)]"}
}

# Fallback attempt 1 to remove HP Wolf Security using msiexec
Try {
    MsiExec /x "{0E2E04B0-9EDD-11EB-B38C-10604B96B11E}" /qn /norestart
    Write-Host -Object "Fallback to MSI uninistall for HP Wolf Security initiated"
}
Catch {
    Write-Warning -Object "Failed to uninstall HP Wolf Security using MSI - Error message: $($_.Exception.Message)"
}

# Fallback attempt 2 to remove HP Wolf Security using msiexec
Try {
    MsiExec /x "{4DA839F0-72CF-11EC-B247-3863BB3CB5A8}" /qn /norestart
    Write-Host -Object "Fallback to MSI uninistall for HP Wolf 2 Security initiated"
}
Catch {
    Write-Warning -Object  "Failed to uninstall HP Wolf Security 2 using MSI - Error message: $($_.Exception.Message)"
}

@Netweezurd
Copy link

Netweezurd commented Feb 7, 2024

Hi all,
I've been using jkraycfgi's version for a while now, I prep most days for a plant, all good but I have a new additional :
ProgramData\HP\TAInstaller\HPInsights.msi_5.23.34\HPInsights.msi
HKLM\SOFTWARE\Classes\Installer\Products\735A8C853A8C6074ABB21EC7D4BE345B
I could not find an Uninstall String in the Reg and when I ran it off Programs and Features, I did not catch anything other than a MsiExec process.
Anyone has a line to add to beloved Remove-HPbloatware-beta ?

@Netweezurd
Copy link

Netweezurd commented Feb 14, 2024

Oh boy...
Hi guys, the firm I work for was with Dell before... a few months ago they got signed by HP... that's why I'm here. My DELLs had no garbage runing on them.
Getting everything off these HPs is such a chore.
After the script, jkraycfgi's version, even after running djsvi's "for handling the aggressively persistent HP spyware services" from the before last comment on mark05E's original Remove-HPbloatware.ps1... I still have a lot of garbage left.

image

HPImageAssistant_Recommended

image

I'm at work... ssomething somewhere is effing up my graphic. Will try from home later.

@CasperStekelenburg
Copy link

CasperStekelenburg commented Feb 15, 2024

Looking for someone to help implement the function based on comment by CasperStekelenburg

I'd try searching the registry for the uninstallstring or IdentifyingNumber.
I'd search in "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" or "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"

Source: Remove-HPbloatware.ps1 comment

@mark05e
Found this again, had some time to write a function you can use:

Function Get-ProgramInstallationStatus {
    <#
        .PARAMETER Application
            The (partial) application name
    #>
    [CmdletBinding()]
    Param(
        [Parameter(Mandatory = $True)]
        [String]$Application
    )

    $UninstallKeys = @(
        "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
    )
    If ([System.Environment]::Is64BitOperatingSystem -eq $True) {
        $UninstallKeys += "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
    }

    Foreach ($UninstallKey in $UninstallKeys) {
        $reg = [microsoft.win32.registrykey]::OpenBaseKey('LocalMachine', "Default")
        $regkey = $reg.OpenSubKey($UninstallKey)
        $subkeys = $regkey.GetSubKeyNames()
        If ($null -ne $subkeys) {
            foreach ($key in $subkeys) {
                $thisKey = $UninstallKey + "\\" + $key
                $thisSubKey = $reg.OpenSubKey($thisKey)
                $DisplayName = $($thisSubKey.GetValue("DisplayName"))
                If ($DisplayName -match $Application -and $DisplayName -notmatch "Language font pack" -and $DisplayName -notmatch "KeepItSafe Online") {
                    $InstallDate = $($thisSubKey.GetValue("InstallDate"))
                    If ($null -ne $InstallDate) {
                        $InstallDate = ([datetime]::ParseExact($InstallDate, 'yyyyMMdd', $null)).ToString("dd-MM-yyyy")
                    }

                    $ProgramInfo = @{
                        "Key"                  = $thisKey
                        "IdentifyingNumber"    = $key
                        "DisplayIcon"          = $($thisSubKey.GetValue("DisplayIcon"))
                        "QuietDisplayName"     = $($thisSubKey.GetValue("QuietDisplayName"))
                        "DisplayName"          = $($thisSubKey.GetValue("DisplayName"))
                        "DisplayVersion"       = $($thisSubKey.GetValue("DisplayVersion"))
                        "EstimatedSize"        = $($thisSubKey.GetValue("EstimatedSize"))
                        "InstallArguments"     = $($thisSubKey.GetValue("InstallArguments"))
                        "InstallDate"          = $InstallDate
                        "InstallLocation"      = $($thisSubKey.GetValue("InstallLocation"))
                        "Is64Bit"              = If ([System.Environment]::Is64BitOperatingSystem -eq $True) { $True } Else { $False }
                        "SystemComponent"      = [bool]$($thisSubKey.GetValue("SystemComponent"))
                        "QuietUninstallString" = $($thisSubKey.GetValue("QuietUninstallString"))
                        "UninstallString"      = $($thisSubKey.GetValue("UninstallString"))
                        "Publisher"            = $($thisSubKey.GetValue("Publisher"))
                        "InstallStatus"        = $True
                    }
                } Else {
                    $ProgramInfo = @{
                        "IdentifyingNumber"    = $null
                        "DisplayIcon"          = $null
                        "QuietDisplayName"     = $null
                        "DisplayName"          = $Application
                        "DisplayVersion"       = $null
                        "EstimatedSize"        = $null
                        "InstallArguments"     = $null
                        "InstallDate"          = $null
                        "InstallLocation"      = $null
                        "Is64Bit"              = If ([System.Environment]::Is64BitOperatingSystem -eq $True) { $True } Else { $False }
                        "SystemComponent"      = $null
                        "QuietUninstallString" = $null
                        "UninstallString"      = $null
                        "Publisher"            = $null
                        "InstallStatus"        = $False
                    }
                }
                If ($ProgramInfo.InstallStatus -eq "True") {
                    Break
                }
            }
        }
        If ($ProgramInfo.InstallStatus -eq "True") {
            Break
        }
    }
    New-Object -TypeName psobject -Property $ProgramInfo
}

@Netweezurd
Copy link

@mark05e Found this again, had some time to write a function you can use:

Function Get-ProgramInstallationStatus {
<#
.PARAMETER Application
The (partial) application name
#>
[CmdletBinding()]
Param(

Nice code @CasperStekelenburg, thanks for puting it up.

I can thinker with lines but I don't do enough scripting to know how to add the lines that would either send it to the con or open and fill a file up with its finding.

Thank You all.

@sikkepitje
Copy link

sikkepitje commented Feb 16, 2024

In addition to the comments made by @CasperStekelenburg, performing "Get-WmiObject win32_product" is bad, because it is very slow and (worse still) it could trigger reinstallation of packages, which is bad.
I get OK results getting similar information using the below function, BUT this produces a list of all installed software, even when it was installed by some other method than MSI. Also attributes have different names and are not in 1:1 relation to list returned by GWMI win32_product. Returned data needs processing to get the same results. To name a few: $product.Identifyingnumber could be extracted fom PSChildName. When UninstallString contains Msiexec , it often has a /I parameter to it , so it really some kind of install string. So to sum up: useful, but needs work.

Function Get-InstalledSoftware64 {
    @(Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*") + `
    @(Get-ItemProperty "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*") `
    | Sort-Object DisplayName `
    | Select-Object DisplayName, DisplayVersion, PSChildName, Publisher, UninstallString, InstallDate `
    | Where-Object {$_.DisplayName.Length -gt 0}
}

BTW , you did great work so far !!!

@Netweezurd
Copy link

image
Anyone knows what the "Sweet F U" service is for ?

@dunxd
Copy link

dunxd commented Mar 19, 2024

Anyone knows what the "Sweet F U" service is for ?

In the comments for the non-beta version of this gist, someone contributed some code which has the comment:

# At this stage the only 'HP Inc.' driver we want to keep is HPSFU, used for firmware servicing.

@ll4mat
Copy link

ll4mat commented Mar 22, 2024

Anyone knows what the "Sweet F U" service is for ?

AFAIK it's part of the HP Support Assistant.
Specifically it's the HP Support Assistant Updater which checks for new driver and firmware updates, downloads and installs them.
If you like to use HP Support Assistant i think you can't avoid this service since it may stop working otherwhise.

@ll4mat
Copy link

ll4mat commented Mar 22, 2024

@Netweezurd

I've been using jkraycfgi's version for a while now, I prep most days for a plant, all good but I have a new additional :
ProgramData\HP\TAInstaller\HPInsights.msi_5.23.34\HPInsights.msi

HP Insights is of the most stubborn bloatware (i even consider it "spyware") i have ever encountered from a manufacturer.
If you uninstall it via the Control Panel or the .msi, you will have it again after some time, as those mofo-components reinstall themselves.
(May the developer responsible for this at HP be struck by lightning while shi*****).

To get permanently rid of it you will need to stop, and afterwards delete a bunch of services to prevent it from getting reinstalled.
Ref: https://h30434.www3.hp.com/t5/Notebook-Software-and-How-To-Questions/Permanently-uninstall-HP-Insights/td-p/8910640

@izzzMe
Copy link

izzzMe commented Mar 22, 2024

Hi All,

Does anyone have their most recent script they could share that gets rid of the above and be deployed via Intune? We are moving to HP devices and there is so much bloatware on them, want an automated script that can be deploy to the devices as they register to Intune? Poly Lens also seems to be another new software that comes with the devices we are getting.

Or is this still the best one to use at present?

Hello Mark [@mark05e] and everyone,

We have been using the original script with success as needed but after we have been having HP units boot to a 'User Profile Service failed to start' upon login. Some research is showing that 'MyHP' application on the units are causing the profile login issues so we decided to revisit the script to make sure we officially get all the HP junk off of our devices.

I compiled a mix of the changes above to the original script and I am having luck with the below running remotely with a successful completion, but not total removal of all the HP software.

I get some errors on the "HP Wolf Security - Console" and "HP Security Update Service" program. It seems the script below is having some issues pulling those specific modules and they are dependent on each other. Are there any services associated that may need to be ended first?

Application 'C:\Windows\explorer.exe' (pid 15272) cannot be restarted - Application SID does not match Conductor SID..	Microsoft-Windows-RestartManager
1/30/2024, 5:57 PM	10010	Warning	Application	Application 'C:\Windows\explorer.exe' (pid 15272) cannot be restarted - Application SID does not match Conductor SID..	Microsoft-Windows-RestartManager
1/30/2024, 5:56 PM	10010	Warning	Application	Application 'C:\Program Files (x86)\HP\HP Notifications\HPNotifications.exe' (pid 12404) cannot be restarted - Application SID does not match Conductor SID..	Microsoft-Windows-RestartManager
1/30/2024, 5:56 PM	10010	Warning	Application	Application 'C:\Program Files (x86)\HP\HP Notifications\HPNotifications.exe' (pid 12404) cannot be restarted - Application SID does not match Conductor SID..	Microsoft-Windows-RestartManager
**1/30/2024, 5:56 PM	10005	Error	Application	Product: HP Security Update Service -- HP Security Update Service is in use. If you wish to remove it, please uninstall other software first: HP Wolf Security - Console.**
# List of built-in apps to remove
$UninstallPackages = @(
    "AD2F1837.HPJumpStarts"
    "AD2F1837.HPPCHardwareDiagnosticsWindows"
    "AD2F1837.HPPowerManager"
    "AD2F1837.HPPrivacySettings"
    "AD2F1837.HPSupportAssistant"
    "AD2F1837.HPSureShieldAI"
    "AD2F1837.HPSystemInformation"
    "AD2F1837.HPQuickDrop"
    "AD2F1837.HPWorkWell"
    "AD2F1837.myHP"
    "AD2F1837.HPDesktopSupportUtilities"
    "AD2F1837.HPQuickTouch"
    "AD2F1837.HPEasyClean"
    "AD2F1837.HPSystemInformation"
    "Microsoft.GetHelp"
    "Microsoft.Getstarted"
    "Microsoft.MicrosoftOfficeHub"
    "Microsoft.MicrosoftSolitaireCollection"
    "Microsoft.People"
    "microsoft.windowscommunicationsapps"
    "Microsoft.WindowsFeedbackHub"
    "Microsoft.Xbox.TCUI"
    "Microsoft.XboxGameOverlay"
    "Microsoft.XboxGamingOverlay"
    "Microsoft.XboxIdentityProvider"
    "Microsoft.XboxSpeechToTextOverlay"
    "Microsoft.XboxApp"
    "Microsoft.Wallet"
    "Microsoft.SkyeApp"
    "Microsoft.BingWeather"
)

# List of programs to uninstall
$UninstallPrograms = @(
    "HP Client Security Manager"
    "HP Connection Optimizer"
    "HP Documentation"
    "HP MAC Address Manager"
    "HP Notifications"
    "HP Security Update Service"
    "HP System Default Settings"
    "HP Sure Click"
    "HP Sure Click Security Browser"
    "HP Sure Run"
    "HP Sure Run Module"
    "HP Sure Recover"
    "HP Sure Sense"
    "HP Sure Sense Installer"
    "HP ICS"
    "HP Assess and Respond"
    "HP Wolf Security"
    "HP Wolf Security - Console"
    "HP Wolf Security Application Support for Sure Sense"
    "HP Wolf Security Application Support for Windows"
)

$HPidentifier = "AD2F1837"

$InstalledPackages = Get-AppxPackage -AllUsers '
            | Where-Object {($UninstallPackages -contains $_.Name) -or ($_.Name -match "^$HPidentifier")}

$ProvisionedPackages = Get-AppxProvisionedPackage -Online '
            | Where-Object {($UninstallPackages -contains $_.DisplayName) -or ($_.DisplayName -match "^$HPidentifier")}

$InstalledPrograms = Get-Package | Where-Object {$UninstallPrograms -contains $_.Name}

# List of services to disable

$DisableServices = @(
    "HotKeyServiceUWP"
    "HPAppHelperCap"
    "HP Comm Recover"
    "HPDiagsCap"
    "HotKeyServiceUWP"
    "HPNetworkCap"
    "HPSysInfoCap"
    "HP TechPulse Core"
)

#Stop HP Services
Function StopDisableService($name) {

    if (Get-Service -Name $name -ea SilentlyContinue) {

        if ((Get-Service -Name $name).Status -eq 'Running') {

            Write-Host "Service '$name' is running. Executing code..."

                Stop-Service -Name $name -Force -Confirm:$False
                Set-Service -Name $name -StartupType Disabled

        }

        else {

            Write-Host "Service '$name' is not running. Code execution skipped."

        }
    }
}

foreach ($serv in $DisableServices){

        StopDisableService -name $serv

    }

# Remove appx provisioned packages - AppxProvisionedPackage
ForEach ($ProvPackage in $ProvisionedPackages) {

    Write-Host -Object "Attempting to remove provisioned package: [$($ProvPackage.DisplayName)]..."

    Try {
        $Null = Remove-AppxProvisionedPackage -PackageName $ProvPackage.PackageName -Online -ErrorAction Stop
        Write-Host -Object "Successfully removed provisioned package: [$($ProvPackage.DisplayName)]"
    }
    Catch {Write-Warning -Message "Failed to remove provisioned package: [$($ProvPackage.DisplayName)]"}
}

# Remove appx packages - AppxPackage
ForEach ($AppxPackage in $InstalledPackages) {
                                            
    Write-Host -Object "Attempting to remove Appx package: [$($AppxPackage.Name)]..."

    Try {
        $Null = Remove-AppxPackage -Package $AppxPackage.PackageFullName -AllUsers -ErrorAction Stop
        Write-Host -Object "Successfully removed Appx package: [$($AppxPackage.Name)]"
    }
    Catch {Write-Warning -Message "Failed to remove Appx package: [$($AppxPackage.Name)]"}
}

# Remove installed programs
$InstalledPrograms | ForEach-Object {

    Write-Host -Object "Attempting to uninstall: [$($_.Name)]..."

    Try {
        $Null = $_ | Uninstall-Package -AllVersions -Force -ErrorAction Stop
        Write-Host -Object "Successfully uninstalled: [$($_.Name)]"
    }
    Catch {Write-Warning -Message "Failed to uninstall: [$($_.Name)]"}
}

# Fallback attempt 1 to remove HP Wolf Security using msiexec
Try {
    MsiExec /x "{0E2E04B0-9EDD-11EB-B38C-10604B96B11E}" /qn /norestart
    Write-Host -Object "Fallback to MSI uninistall for HP Wolf Security initiated"
}
Catch {
    Write-Warning -Object "Failed to uninstall HP Wolf Security using MSI - Error message: $($_.Exception.Message)"
}

# Fallback attempt 2 to remove HP Wolf Security using msiexec
Try {
    MsiExec /x "{4DA839F0-72CF-11EC-B247-3863BB3CB5A8}" /qn /norestart
    Write-Host -Object "Fallback to MSI uninistall for HP Wolf 2 Security initiated"
}
Catch {
    Write-Warning -Object  "Failed to uninstall HP Wolf Security 2 using MSI - Error message: $($_.Exception.Message)"
}

@IntuneAdmin017
Copy link

@izzzMe

I have tested this script from Intune Remediation for HP wolf products and it worked:

$HPWolfSecurity = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq "HP Wolf Security" }
if ($HPWolfSecurity) {
$HPWolfSecurity.Uninstall()
Start-Sleep -Seconds 2
}

$HPWolfSecurityConsole = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq "HP Wolf Security - Console" }
if ($HPWolfSecurityConsole) {
$HPWolfSecurityConsole.Uninstall()
Start-Sleep -Seconds 2
}

Get-Service -DisplayName "HP Security Update Service" | Stop-Service
$HPSecurityUpdateService = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq "HP Security Update Service" }
if ($HPSecurityUpdateService) {
$HPSecurityUpdateService.Uninstall()
Start-Sleep -Seconds 2
}

@foeyonghai
Copy link

Hi, I applied clean coding to the script. Hope this helps and makes the script more professional.

`# List of built-in apps to remove
$UninstallPackages = @(
"AD2F1837.HPJumpStarts"
"AD2F1837.HPPCHardwareDiagnosticsWindows"
"AD2F1837.HPPowerManager"
"AD2F1837.HPPrivacySettings"
"AD2F1837.HPSupportAssistant"
"AD2F1837.HPSureShieldAI"
"AD2F1837.HPSystemInformation"
"AD2F1837.HPQuickDrop"
"AD2F1837.HPWorkWell"
"AD2F1837.myHP"
"AD2F1837.HPDesktopSupportUtilities"
"AD2F1837.HPQuickTouch"
"AD2F1837.HPEasyClean"
"AD2F1837.HPSystemInformation"
)

List of programs to uninstall

$UninstallPrograms = @(
"HP Client Security Manager"
"HP Connection Optimizer"
"HP Documentation"
"HP MAC Address Manager"
"HP Notifications"
"HP Security Update Service"
"HP System Default Settings"
"HP Sure Click"
"HP Sure Click Security Browser"
"HP Sure Run"
"HP Sure Recover"
"HP Sure Sense"
"HP Sure Sense Installer"
"HP Support Assistant"
"HP Wolf Security"
"HP Wolf Security Application Support for Sure Sense"
"HP Wolf Security Application Support for Windows"
)

$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
"@

Run inventories

$HPidentifier = "AD2F1837"
$InstalledPackages = Get-AppxPackage -AllUsers | Where-Object {($UninstallPackages -contains $.Name) -or ($.Name -match "^$HPidentifier")} -Verbose
$ProvisionedPackages = Get-AppxProvisionedPackage -Online | Where-Object {($UninstallPackages -contains $.DisplayName) -or ($.DisplayName -match "^$HPidentifier")} -Verbose
$InstalledPrograms = Get-Package | Where-Object {$UninstallPrograms -contains $.Name} -Verbose
$HPCommRecoveryPresent = Test-Path -Path "C:\Program Files\HPCommRecovery"
$apps = Get-WmiObject -Class Win32_Product | Where-Object {$
.Name -match "HP"}
$HPSAuninstall = "${Env:ProgramFiles(x86)}\HP\HP Support Framework\UninstallHPSA.exe"

Remove HP APPX provisioned packages - AppxProvisionedPackage

function Step1 {
ForEach ($ProvPackage in $ProvisionedPackages) {
Write-Host -Object "Attempting to remove provisioned package: [$($ProvPackage.DisplayName)]..."

    Try {
        $Null = Remove-AppxProvisionedPackage -PackageName $ProvPackage.PackageName -Online -ErrorAction Stop -Verbose
        Write-Host -Object "Successfully removed provisioned package: [$($ProvPackage.DisplayName)]"
    }
    Catch {Write-Warning -Message "Failed to remove provisioned package: [$($ProvPackage.DisplayName)]"}
}

# Go to the next function
Step2

}

Remove HP APPX packages - AppxPackage

function Step2 {
ForEach ($AppxPackage in $InstalledPackages) {
Write-Host -Object "Attempting to remove Appx package: [$($AppxPackage.Name)]..."

    Try {
        $Null = Remove-AppxPackage -Package $AppxPackage.PackageFullName -AllUsers -ErrorAction Stop -Verbose
        Write-Host -Object "Successfully removed Appx package: [$($AppxPackage.Name)]"
    }
    Catch {Write-Warning -Message "Failed to remove Appx package: [$($AppxPackage.Name)]"}
}

# Go to the next function
Step3

}

Remove HP installed programs

function Step3 {
$InstalledPrograms | ForEach-Object {
Try {
$Null = $_ | Uninstall-Package -AllVersions -Force -ErrorAction Stop -Verbose
Write-Host -Object "Successfully uninstalled: [$($.Name)]"
}
Catch {Write-Warning -Message "Failed to uninstall: [$($
.Name)]"}
}

# Go to the next function
Step4

}

Remove HP Win32 Apps

function Step4 {
foreach ($app in $apps) {
$id = $app.IdentifyingNumber
msiexec /uninstall "$id" /quiet /log $msilog /norestart
}

# Go to next function
Step5

}

Remove HP Connection Optimizer

function Step5 {
if ($HPCommRecoveryPresent) {
$optimizerUninstallAnswer | Out-File $env:TEMP\optimizer.iss
$arguments = "/s /f1"$env:Temp\optimizer.iss" /f2"C:\Temp\Uninstall.log""
Start-Process "C:\Program Files (x86)\InstallShield Installation Information{6468C4A5-E47E-405F-B675-A70A70983EA6}\Setup.exe" -ArgumentList $arguments -PassThru -Wait
}

#Go to next function
Step6

}

Remove HP Documentation

function Step6 {
#Remove HP Documentation
if (Test-Path "${Env:ProgramFiles}\HP\Documentation\Doc_uninstall.cmd" -PathType Leaf) {
try {
Invoke-Item "${Env:ProgramFiles}\HP\Documentation\Doc_uninstall.cmd"
Write-Host "Successfully removed provisioned package: HP Documentation"
}
catch {
Write-Host "Error Remvoving HP Documentation $($_.Exception.Message)"
}
}
else {
Write-Host "HP Documentation is not installed"
}

    # Go to next function
    Step7

}

Remove HP Active Support

function Step7 {
if (Test-Path -Path "HKLM:\Software\WOW6432Node\Hewlett-Packard\HPActiveSupport") {
try {
Remove-Item -Path "HKLM:\Software\WOW6432Node\Hewlett-Packard\HPActiveSupport"
Write-Host "HP Support Assistant regkey deleted $($.Exception.Message)"
}
catch {
Write-Host "Error retreiving registry key for HP Support Assistant: $($
.Exception.Message)"
}
}
else {
Write-Host "HP Support Assistant regkey not found"
}

if (Test-Path $HPSAuninstall -PathType Leaf) {
    try {
        & $HPSAuninstall /s /v/qn UninstallKeepPreferences=FALSE
        Write-Host "Successfully removed provisioned package: HP Support Assistant silently"
    }
    catch {
        Write-Host "Error uninstalling HP Support Assistant: $($_.Exception.Message)"
    }
}
else {
    Write-Host "HP Support Assistant Uninstaller not found"
}
# Go to next function
Step8

}

Check is apps are still present

function Step8 {
$apps = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -match "HP"}
if ($apps) {
#Try to remove apps that are still present
foreach ($app in $apps) {
$id = $app.IdentifyingNumber
msiexec /uninstall "$id" /quiet /log $msilog /norestart
}
}
}

Start with the first function

Step1`

@foeyonghai
Copy link

Hi @xxIPREDATORIxx, I placed my own version here: https://github.com/IntuneSpecialist/Intune/tree/main/Powershell%20scripts. Its the same version as I mentioned above but since they never responded I descided to place my own version there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment