Checklist
Steps to Reproduce
$logFileName = "Script-PendingRebootNotification.log"
$logFilePath = "$env:ProgramData\Airwatch\UnifiedAgent\Logs"
# Log a message to a log file
function Write-Log {
Param (
[Parameter(Mandatory = $true)]
[string]$Message,
[Parameter(Mandatory = $true)]
[ValidateSet("Info", "Warning", "Error", "Debug")]
[string]$LogLevel
)
If (-not (Test-Path $logFilePath)) {
New-Item -ItemType Directory -Path $logFilePath -Force
}
$time = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
$formattedMessage = "$time [$LogLevel] - $Message"
$formattedMessage | Out-File -FilePath "$logFilePath\$logFileName" -Append -Encoding "utf8"
#Write-Host $formattedMessage
}
### Main Script ###
$OSVersion = [System.Environment]::OSVersion.Version
$OSVersion.psobject.Properties | ForEach-Object {
Write-Log -LogLevel "Debug" -Message "OSVersion.$($_.Name): $($_.Value)"
}
# Import the BurntToast module
Write-Log -LogLevel "Info" -Message "Importing BurntToast module"
try {
Import-Module BurntToast -ErrorAction Stop
Write-Log -LogLevel "Info" -Message "BurntToast module imported successfully"
} catch {
Write-Log -LogLevel "Error" -Message "Failed to import BurntToast module: $_"
exit 0
}
Description
The BurntToast module currently uses [System.Environment]::OSVersion.Version to validate if it's running on Windows 10 or later. However, this method of version detection can be unreliable when the PowerShell script is executed within certain environments (MDM products), such as the Omnissa Workspace ONE (WS1) custom PowerShell host (AW.ProtectionAgent.PowershellExecutor64.exe).
In these cases, [System.Environment]::OSVersion.Version returns 6.2.9200 (Windows 8), even if the underlying OS is Windows 10 or 11. This causes the module to throw an error and fail to import:
"This version of BurntToast will only work on Windows 10 or equivalent Windows Server version."
Steps to Reproduce (in Workspace ONE)
- Deploy a script using
BurntToast via Workspace ONE UEM.
- The custom executor triggers the script.
[System.Environment]::OSVersion.Version reports 6.2.9200.
- The module fails to import due to the checks in
BurntToast.psm1.
Proposed Solution
Switch from [System.Environment]::OSVersion.Version to a more robust detection method using WMI/CIM, which correctly identifies the OS version even when the process is running under compatibility layers or custom hosts.
Benefits
- Reliability: Correctly detects OS version in MDM agents (Workspace ONE, etc.) and compatibility modes.
- Accuracy:
Win32_OperatingSystem is the "source of truth" for the installed OS version.
- No Side Effects: This change only affects the initial module import check.
Additional Context
- Historical Comparison: This logic was actually working correctly in version 0.8.5 and earlier. In that version, the module used
Get-CimInstance to perform the check.
- V0.8.5 Logic:
$WinMajorVersion = (Get-CimInstance -ClassName Win32_OperatingSystem -Property Version).Version.Split('.')[0]
if ($WinMajorVersion -ge 10) { ... }
- Changes in newer versions: The switch to
[System.Environment]::OSVersion.Version appears to have introduced this regression for users in controlled environments like Workspace ONE.
Actual Behavior
Running this locally on my Windows 11 machine, I see the following output in the logs:
2026-02-17 13:59:28 [Debug] - OSVersion.Major: 10
2026-02-17 13:59:28 [Debug] - OSVersion.Minor: 0
2026-02-17 13:59:28 [Debug] - OSVersion.Build: 26200
2026-02-17 13:59:28 [Debug] - OSVersion.Revision: 0
2026-02-17 13:59:28 [Debug] - OSVersion.MajorRevision: 0
2026-02-17 13:59:28 [Debug] - OSVersion.MinorRevision: 0
2026-02-17 13:59:28 [Debug] - BurntToastPesterNotWindows10:
2026-02-17 13:59:28 [Info] - Importing BurntToast module
2026-02-17 13:59:28 [Info] - BurntToast module imported successfully
Running this via a WS1 script, I see the following output in the logs:
2026-02-19 05:30:07 [Debug] - OSVersion.Major: 6
2026-02-19 05:30:07 [Debug] - OSVersion.Minor: 2
2026-02-19 05:30:07 [Debug] - OSVersion.Build: 9200
2026-02-19 05:30:07 [Debug] - OSVersion.Revision: 0
2026-02-19 05:30:07 [Debug] - OSVersion.MajorRevision: 0
2026-02-19 05:30:07 [Debug] - OSVersion.MinorRevision: 0
2026-02-19 05:30:07 [Debug] - BurntToastPesterNotWindows10:
2026-02-19 05:30:07 [Info] - Importing BurntToast module
2026-02-19 05:30:07 [Error] - Failed to import BurntToast module: This version of BurntToast will only work on Windows 10 or equivalent Windows Server version. If you would like to use BurntToast on Windows 8, please use version 0.4 of the module
Experience with Toast
Intermediate
Environment data: PowerShell
Name Value
---- -----
PSVersion 5.1.26100.7705
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.26100.7705
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Environment data: OS
OsName : Microsoft Windows 11 Enterprise
OsVersion : 10.0.26100
OsArchitecture : 64-bit
Environment data: BurntToast
Name Value
---- -----
PSVersion 5.1.26100.7705
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.26100.7705
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
OsName : Microsoft Windows 11 Enterprise
OsVersion : 10.0.26100
OsArchitecture : 64-bit
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.1.0 BurntToast {Get-BTHeader, Get-BTHistory, New-BTAction, New-BTAudio...}
Consent to Attribution
Checklist
Steps to Reproduce
Description
The
BurntToastmodule currently uses[System.Environment]::OSVersion.Versionto validate if it's running on Windows 10 or later. However, this method of version detection can be unreliable when the PowerShell script is executed within certain environments (MDM products), such as the Omnissa Workspace ONE (WS1) custom PowerShell host (AW.ProtectionAgent.PowershellExecutor64.exe).In these cases,
[System.Environment]::OSVersion.Versionreturns6.2.9200(Windows 8), even if the underlying OS is Windows 10 or 11. This causes the module to throw an error and fail to import:"This version of BurntToast will only work on Windows 10 or equivalent Windows Server version."
Steps to Reproduce (in Workspace ONE)
BurntToastvia Workspace ONE UEM.[System.Environment]::OSVersion.Versionreports6.2.9200.BurntToast.psm1.Proposed Solution
Switch from
[System.Environment]::OSVersion.Versionto a more robust detection method using WMI/CIM, which correctly identifies the OS version even when the process is running under compatibility layers or custom hosts.Benefits
Win32_OperatingSystemis the "source of truth" for the installed OS version.Additional Context
Get-CimInstanceto perform the check.[System.Environment]::OSVersion.Versionappears to have introduced this regression for users in controlled environments like Workspace ONE.Actual Behavior
Running this locally on my Windows 11 machine, I see the following output in the logs:
Running this via a WS1 script, I see the following output in the logs:
Experience with Toast
Intermediate
Environment data: PowerShell
Environment data: OS
Environment data: BurntToast
Consent to Attribution