Remove PUA
Summary
This script manages the removal of predefined bloatware packages or lists installed bloatware based on a centrally maintained list. It offers three primary operations: bulk removal, selective removal, and bloatware listing. The remove parameter allows bypassing the PUA List to remove any installed AppxPackage.
PUA List: https://content.provaltech.com/attachments/potentially-unwanted-applications.json
Sample Run

To get the list of installed Bloatware:

To remove all installed Bloatware installed on the computer from the PUA List:

To remove all installed Bloatware except any of WindowsStoreApps category apps and Microsoft.BingNews, and Microsoft.MSPaint:

To remove individual AppxPackages installed on the machine like Microsoft.MicrosoftOfficeHub, Microsoft.XboxApp, Microsoft.Messaging, and Microsoft.People:


Dependencies
Implementation
Script Details
Step 1
Navigate to Automation ➞ Tasks

Step 2
Create a new Script Editor style task by choosing the Script Editor option from the Add dropdown menu
The New Script page will appear on clicking the Script Editor button:

Step 3
Fill in the following details in the Description section:
Name: Remove - PUA
Description:
This script manages the removal of predefined bloatware packages or lists installed bloatware based on a centrally maintained list. It offers three primary operations: bulk removal, selective removal, and bloatware listing. The remove parameter allows bypassing the PUA List to remove any installed AppxPackage.
PUA List: https://content.provaltech.com/attachments/potentially-unwanted-applications.json
Category: Application

Parameters
ListBloatware
Add a new parameter by clicking the Add Parameter button present at the top-right corner of the screen.
This screen will appear.

- Set
ListBloatwarein theParameter Namefield. - Select
Flagfrom theParameter Typedropdown menu. - Click the
Savebutton.

Remove
Add a new parameter by clicking the Add Parameter button present at the top-right corner of the screen.
This screen will appear.

- Set
Removein theParameter Namefield. - Select
Text Stringfrom theParameter Typedropdown menu. - Click the
Savebutton.

RemoveAll
Add a new parameter by clicking the Add Parameter button present at the top-right corner of the screen.
This screen will appear.

- Set
RemoveAllin theParameter Namefield. - Select
Flagfrom theParameter Typedropdown menu. - Click the
Savebutton.

Category
Add a new parameter by clicking the Add Parameter button present at the top-right corner of the screen.
This screen will appear.

- Set
Categoryin theParameter Namefield. - Select
Text Stringfrom theParameter Typedropdown menu. - Click the
Savebutton.

Except
Add a new parameter by clicking the Add Parameter button present at the top-right corner of the screen.
This screen will appear.

- Set
Exceptin theParameter Namefield. - Select
Text Stringfrom theParameter Typedropdown menu. - Click the
Savebutton.

Script Editor
Click the Add Row button in the Script Editor section to start creating the script
A blank function will appear.
Row 1: Function: PowerShell Script
Search and select the PowerShell Script function.
The following function will pop up on the screen:
Paste in the following PowerShell script and set the Expected time of script execution in seconds to 3600 seconds. Click the Save button.
#region user parameters
$ListBloatware = '@ListBloatware@'
$Remove = '@Remove@'
$RemoveAll = '@RemoveAll@'
$Category = '@Category@'
$Except = '@Except@'
if ($ListBloatware -match '1|True|Yes') {
$ListBloatware = $true
} else {
$ListBloatware = $false
}
if ($Remove -and $Remove -notmatch 'Remove' -and $Remove -match '[A-z]') {
$Remove = $Remove -replace ', ', ',' -replace ' ,', ','
$Remove = $Remove.Trim()
$Remove = $Remove.Split(',')
}
if ($RemoveAll -match '1|True|Yes') {
$RemoveAll = $true
} else {
$RemoveAll = $false
}
if ($RemoveAll -and $Category -and $Category -notmatch 'Category' -and $Category -match '[A-z]') {
if (!(('MsftBloatApps', 'ThirdPartyBloatApps') -contains $Category)) {
throw 'Invalid category. Supported categories are: MsftBloatApps, and ThirdPartyBloatApps'
} else {
$Category = $Category
}
} else {
$Category = $false
}
if ($RemoveAll -and $Except -and $Except -notmatch 'Except' -and $Except -match '[A-z]') {
$Except = $Except -replace ', ', ',' -replace ' ,', ','
$Except = $Except.Trim()
$Except = $Except.Split(',')
} else {
$Except = $false
}
#endregion
#region parameters hash table
$Parameters = @{}
if ( $ListBloatware ) {
$Parameters.Add('ListBloatware', $true)
} elseif ( $Remove ) {
$Parameters.Add('Remove', $Remove)
} elseif ( $RemoveAll ) {
$Parameters.Add('RemoveAll', $true)
if ( $Category ) {
$Parameters.Add('Category', $Category)
}
if ( $Except ) {
$Parameters.Add('Except', $Except)
}
} else {
throw 'Invalid parameter set.'
}
#endregion
#region variables
[Net.ServicePointManager]::SecurityProtocol = [enum]::ToObject([Net.SecurityProtocolType], 3072)
$ProjectName = 'Remove-PUA'
$BaseURL = 'https://file.provaltech.com/repo'
$PS1URL = "$BaseURL/script/$ProjectName.ps1"
$WorkingDirectory = "C:\ProgramData\_automation\script\$ProjectName"
$PS1Path = "$WorkingDirectory\$ProjectName.ps1"
$Workingpath = $WorkingDirectory
$LogPath = "$WorkingDirectory\$ProjectName-log.txt"
$ErrorLogPath = "$WorkingDirectory\$ProjectName-Error.txt"
#endregion
#region Setup - Folder Structure
New-Item -Path $WorkingDirectory -ItemType Directory -ErrorAction SilentlyContinue | Out-Null
try {
Invoke-WebRequest -Uri $PS1URL -OutFile $PS1path -UseBasicParsing -ErrorAction Stop
} catch {
if (!(Test-Path -Path $PS1Path )) {
throw ('Failed to download the script from ''{0}'', and no local copy of the script exists on the machine. Reason: {1}' -f $PS1URL, $($Error[0].Exception.Message))
}
}
#endregion
& $PS1Path @Parameters
#region Execution
if ($Parameters) {
& $PS1Path @Parameters
} else {
& $PS1Path
}
#endregion
if ( !(Test-Path $LogPath) ) {
throw 'PowerShell Failure. A Security application seems to have restricted the execution of the PowerShell Script.'
}
if ( Test-Path $ErrorLogPath ) {
$ErrorContent = ( Get-Content -Path $ErrorLogPath )
throw $ErrorContent
}
Get-Content -Path $LogPath

Row 2: Function: Script Log
Add a new row by clicking the Add Row button.
A blank function will appear.
Search and select the Script Log function.
The following function will pop up on the screen:
In the script log message, simply type %output% and click the Save button
Click the Save button at the top-right corner of the screen to save the script.
Completed Script
Output
- Script log