Navigation
Introduction
Managing product deployments in Workspace ONE UEM can be challenging, especially if you have a large number of products set up. There may be scenarios where products need to be run on a regular basis to ensure devices maintain their intended configurations. This script, along with Task Scheduler on Windows, allows you to automate the process of force reprocessing products, ensuring settings are reapplied as needed without manual intervention.
This blog will walk through how the script works and provide some examples on how you could make use of it. You can find this script, along with other Workspace ONE automation tools, in my GitHub repo.
Why Use ForceReprocess.ps1?
There are several scenarios where it is useful to re-run a product on a schedule, ensuring device settings remain consistent and functional. Some examples include:
- Reapplying XML-based settings: Some configurations, such as those deployed via a Zebra StageNow XML file, may need to be reset periodically to ensure devices adhere to predefined settings which are changeable by a user.
- Restoring sound profiles: If a device’s volume settings are frequently adjusted by users, an automated product can reset them to the desired default levels.
- Re-enabling Bluetooth: In environments where Bluetooth is required but users may disable it, regularly reprocessing a product can ensure it remains enabled.
- Setting Device Wallpaper: Sets a company standard wallpaper on each device
By using ForceReprocess.ps1 with Windows Task Scheduler, you can automate these tasks, reducing the need for manual configuration adjustments and improving device compliance.
💡While this script was created with automation in mind, it can also be run manually.
How the Script Works
The script is designed to:
- Authenticate with Workspace ONE UEM using UEMAuth.ps1
- Retrieve a list of devices assigned to a specific Smart Group.
- Iterate through the devices and trigger a force reprocess of the specified product.
What You’ll Need
Before running the script, ensure:
- PowerShell Execution Policy allows script execution (
Set-ExecutionPolicy Bypass -Scope Process
if needed). - The UEMAuth.ps1 script is present in the same directory as this script. See Automating Workspace ONE UEM API Authentication with PowerShell for more information
💡If using any of my scripts in automation, ensure you’ve run UEMAuth.ps1 manually once to generate a credentials file before setting any scheduled tasks up - You have created an OAuth Client for your Workspace One UEM tenant – see my post on OAuth Client Creation in WS1 UEM for a how-to
- The Product ID for the product you wish to Force Reprocess
- The SmartGroup ID for the devices assigned to the product
- If you want to run this script on a regular basis automatically, see my post on Automating Powershell Scripts via Task Scheduler for additional requirements and how to set this up
Script Breakdown
Setting Required Variables
Users must specify two values before running the script:
$SmartGroup = "enter smartgroup number here"
$ProductNumber = "enter product number here"
These define the Smart Group ID and the Product ID to be reprocessed.
Authenticating with Workspace ONE UEM
The script imports UEMAuth.ps1, designed to handle authentication and set global API variables. If these variables are missing, the script exits with an error.
. $AuthScriptPath # Dot-source the authentication script
if (-not $global:UEMHeaders -or -not $global:ws1url) {
Write-Host "Error: Authentication script did not set required variables." -ForegroundColor Red
exit 1
}
Fetching Assigned Devices
Using the Smart Group ID, the script queries the Workspace ONE UEM API to get a list of device IDs associated with the group:
$Response = Invoke-RestMethod -Method Get -ContentType "$global:Content" -Headers $global:UEMHeaders[$version] \
-Uri "https://$global:ws1url/api/mdm/smartgroups/$SmartGroup/devices" -DisableKeepAlive
$DeviceIDs = $Response.SmartGroupDevices.Devices.Device.Id
If no devices are found, the script exits gracefully.
Reprocessing the Product
For each device retrieved, the script sends an API request to reprocess the specified product:
ForEach ($DeviceID in $DeviceIDs) {
$Body = @"
<?xml version="1.0"?>
<ReprocessProductInputEntity>
<ForceFlag>true</ForceFlag>
<DeviceIds>
<DeviceIds>
<ID>$DeviceID</ID>
</DeviceIds>
</DeviceIds>
<ProductID>$ProductNumber</ProductID>
</ReprocessProductInputEntity>
"@
try {
Invoke-RestMethod -Method Post -ContentType "$global:Content" -Headers $global:UEMHeaders[$version] \
-Uri "https://$global:ws1url/api/mdm/products/reprocessProduct" -Body $Body
} catch {
Write-Host "Failed to reprocess product for device $DeviceID - $_.Exception.Message" -ForegroundColor Red
}
}
Each API request includes the device ID and the product number, ensuring the product is force reprocessed across all assigned devices.
Conclusion
The ForceReprocess.ps1 script provides a streamlined method for reprocessing Workspace ONE UEM products across multiple devices. By leveraging PowerShell automation, administrators can ensure updates and changes are applied efficiently without manual intervention. When combined with Task Scheduler, this script allows for scheduled enforcement of settings, keeping devices in compliance and reducing the need for manual adjustments.