Schmittel IT Systems

Automated removal of HP bloatware with Intune

We show how new and old computers can be cleaned of HP bloatware using Intune.

Hello to the very first article about Intune and removing HP bloatware. Here is a brief overview of who we are and how we came up with this topic: We are an IT service provider and our many customers from industry, trade and many others include a public school in Saxony-Anhalt. As part of the "Digitalpakt Schule" funding programme, there was money for the purchase of new IT equipment, including HP notebooks for all teachers provided by the state.

Unfortunately, the teachers had to set up the devices themselves, meaning that important settings were not made. As public schools are known to have a certain budget and Office 365 A1 was already in use, we decided to integrate the devices into the central Intune management via Windows Autopilot.

The following does not go into the setup of Intune and Autopilot, but only describes how the HP bloatware apps can be removed automatically.

What are the requirements?

  • The device must be connected to Intune
  • The user or device must have an Intune licence (included in M365 Business Premium, M365 E3, E5)
  • There must be a dynamic group with HP devices.

After some research on the Internet, we found a script from Jeroen Burgerhout for removing HP bloatware. Unfortunately, this is no longer completely up-to-date and not all programmes have been removed.

We have added 4 programmes to his script. It can be found in our GitHub repo. At the bottom of the page you will find a description of how the script works.

Deployment of the programme in Intune

In order for the script to remove the HP bloatware on all computers and notebooks, it must be published in Intune and assigned to the devices.

  1. First, the RemoveHPBloatware.intunewin file must be uploaded to Intune
  2. App information must be filled in
  3. The installation and uninstallation commands must now be entered in the Program section
    1. Enter the following command in the installation command field powershell.exe -noprofile -executionpolicy bypass -file .\RemoveHPBloatware.ps1
    2. Enter the following command in the uninstall command field cmd.exe /c del %ProgramData%\HP\RemoveHPBloatware\RemoveHPBloatware.ps1.tag
  4. In the Detection rules section, the rules must now be defined so that Intune can recognise whether the script has been successfully installed.
    1. Select manual detection under Rule format.
    2. Click on + Add.
    3. Under Rule type , select the option File.
    4. Enter the following value in the Path field %ProgramData%\HP\RemoveHPBloatware
    5. Enter the following value in the File or folder field RemoveHPBloatware.ps1.tag
    6. Select File or folder exists as the detection method.
    7. Click on OK.

Now you just need to assign the programme to the devices, this can be done manually for a handful of devices, or you can create a dynamic group with the HP devices assignment and then select this group under Required.

Do you need support to implement Intune or Endpoint Manager?

Get non-binding advice now

How does the HP Bloatware Script work?

The script first creates a TAG file. Intune can use this to determine whether the script has been successfully installed.

 

# Create a tag file just so Intune knows this was installed
if (-not (Test-Path "$($env:ProgramData)\HP\RemoveHPBloatware"))
{
    Mkdir "$($env:ProgramData)\HP\RemoveHPBloatware"
}
Set-Content -Path "$($env:ProgramData)\HP\RemoveHPBloatware\RemoveHPBloatware.ps1.tag" -Value "Installed"

 

In the second part of the script, the Appx packages from HP are defined. Of course, other programmes can also be added and programmes can be excluded.

 

# Start logging
Start transcript "$($env:ProgramData)\HP\RemoveHPBloatware\RemoveHPBloatware.log"
# List of built-in apps to remove
$UninstallPackages = @(
    "AD2F1837.HPEasyClean"
    "AD2F1837.HPPCHardwareDiagnosticsWindows"
    "AD2F1837.HPPowerManager"
    "AD2F1837.HPPrivacySettings"
    "AD2F1837.HPProgrammableKey"
    "AD2F1837.HPQuickDrop"
    "AD2F1837.HPSupportAssistant"
    "AD2F1837.HPSystemInformation"
    "AD2F1837.HPWorkWell"
    "AD2F1837.myHP"
    "Tile.TileWindowsApplication"
)

 

Part three of the script defines the HP programmes that are to be removed. As in part two, programmes can also be added.

 

# List of programs to uninstall
$UninstallPrograms = @(
    "HP Client Security Manager"
    "HP Notifications"
    "HP Security Update Service"
    "HP System Default Settings"
    "HP Wolf Security"
    "HP Wolf Security Application Support for Sure Sense"
    "HP Wolf Security Application Support for Windows"
    "HP Connection Optimiser"
    "HP Documentation"
    "HP Security Update Service"
    "HP Sure Click"
    "HP Sure Sense Installer"
    "HP System Default Settings"
)

 

In the last part, the programmes and appx packages are now removed.

 

$HPidentifier = "AD2F1837"

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

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

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

# Remove provisioned packages first
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
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 {

    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)]"}
}

Stop-Transcript