Scripts

Share this post:

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

Corporate Device Identifiers

$manufacturer = (Get-CimInstance -ClassName Win32_ComputerSystem).Manufacturer
$model = (Get-CimInstance -ClassName Win32_ComputerSystem).Model
$serialNumber = (Get-CimInstance -ClassName Win32_BIOS).SerialNumber

"$manufacturer,$model,$serialNumber"
$scriptContent = @"
# FixPubFWProfile.ps1
# This script fixes the public network profile

# Get the network profiles
`$networkProfiles = Get-NetConnectionProfile

# Wait for 60 seconds
Start-Sleep -Seconds 60

# Loop through each profile and reset the nic if it is public
foreach (`$Nprofile in `$networkProfiles) {
    if (`$Nprofile.NetworkCategory -eq "Public") { 
        Restart-NetAdapter -Name `$Nprofile.InterfaceAlias
    }
}
"@

$scriptPath = "c:\Install\Scripts\FixPubFWProfile.ps1"

# Create the directory if it doesn't exist
if (-not (Test-Path -Path (Split-Path -Path $scriptPath))) {
    New-Item -ItemType Directory -Path (Split-Path -Path $scriptPath) -Force
}

# Write the script content to the file
Set-Content -Path $scriptPath -Value $scriptContent

Write-Output "Script created at $scriptPath"

$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-ExecutionPolicy Bypass -NoProfile -File `"$scriptPath`""
$trigger = New-ScheduledTaskTrigger -AtStartup
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable

#check if the task already exists
$taskExists = Get-ScheduledTask -TaskName "FixPublicNetworkProfile" -ErrorAction SilentlyContinue
if ($taskExists) {
    Write-Output "Scheduled task 'FixPublicNetworkProfile' already exists"
}
else {
    Register-ScheduledTask -Action $action -Trigger $trigger -Principal $principal -Settings $settings -TaskName "FixPublicNetworkProfile" -Description "Fixes the public network profile 1 minute after startup"
    Write-Output "Scheduled task 'FixPublicNetworkProfile' created to run at startup with a 1 minute delay in the script"
}

Fix-Public-Network-Profile.ps1

Share this post: