Skip to main content

Windows 11 Compatibility

Overview

Runs the Microsoft Hardware Readiness Script to verify the hardware compliance for Windows 11. It will then store the compatible details in the Custom field - cPVAL Win 11 Compatibility

Sample Run

Play Button > Run Automation > Script
SampleRun1

Search and select Windows 11 Compatibility alt text

Set the required arguments and click the Run button to run the script.

  • Run As: System
  • Preset Parameter: <Leave it Blank>

ImageRun

Run Automation: Yes
RunAutomation

Dependencies

Automation Setup/Import

Step 1

Navigate to Administration > Library > Automation
Step1

Step 2

Locate the Add button on the right-hand side of the screen, click on it and click the New Script button.
Step2

The scripting window will open.
ScriptingScreen

Step 3

Configure the Create Script section as follows:

  • Name: Windows 11 Compatibility
  • Description: Runs the Microsoft Hardware Readiness Script to verify the hardware compliance.
  • Categories: <Leave it blank>
  • Language: PowerShell
  • Operating System: Windows
  • Architecture: All
  • Run As: System

Script

Step 4

Paste the following powershell script in the scripting section:

# Define working directory and script path
$WorkingDirectory = "$Env:SystemDrive\ProgramData\_automation\script\HardwareReadiness"
$PS1Path = "$WorkingDirectory\HardwareReadiness.ps1"

try {
# Create directory if it doesn't exist
if (-not (Test-Path -Path $WorkingDirectory)) {
New-Item -Type Directory -Path $WorkingDirectory -Force | Out-Null
}

# Set TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

# Download the script
$webClient = New-Object System.Net.WebClient
$webClient.DownloadFile("https://aka.ms/HWReadinessScript", $PS1Path)

# Verify download
if (-not (Test-Path -Path $PS1Path)) {
throw "Script download failed"
}

# Execute script and capture output
$scriptOutput = & $PS1Path

# Get the last line which contains the JSON
$jsonOutput = $scriptOutput | Select-Object -Last 1

# Convert the JSON output
$result = $jsonOutput | ConvertFrom-Json

# Store the result in a variable
$compatibilityStatus = $result.returnResult

# Store the status in a custom field
Ninja-Property-Set cpvalWin11Compat $compatibilityStatus
Write-Output "Windows 11 Compatibility Status: $compatibilityStatus"

# Format output for Ninja
$output = @{
Result = $result.returnResult
Details = $result.logging
ExitCode = $result.returnCode
}

# Output results
$output | ConvertTo-Json

} catch {
$errorOutput = @{
Result = "ERROR"
Details = $_.Exception.Message
ExitCode = 1
}
$errorOutput | ConvertTo-Json
exit 1
}

NinjaPowerShell

Saving the Automation

Click the Save button in the top-right corner of the screen to save your automation.
SaveButton

You will be prompted to enter your MFA code. Provide the code and press the Continue button to finalize the process.
MFA

Completed Automation

NinjaScript

Output

  • Activity Details