Private/Test-CopilotPlatform.ps1
|
function Test-CopilotPlatform { <# .SYNOPSIS Detects whether the current machine is a Windows 11 Copilot+ PC. .DESCRIPTION Checks for the presence of NPU hardware, the Windows AI Fabric Service (WSAIFabricSvc), and any running WorkloadsSessionHost processes. Returns a diagnostic object indicating platform readiness. Used internally by Install-WinslopFix to warn administrators if the module is being deployed to a machine that doesn't need it. #> [CmdletBinding()] [OutputType([PSCustomObject])] param() process { $result = [PSCustomObject]@{ IsCopilotPlatform = $false HasNPU = $false HasAIFabricService = $false AIFabricServiceStatus = 'NotFound' WorkloadsSessionHostCount = 0 WindowsBuild = $null NPUDeviceName = $null } # Check Windows build try { $os = Get-CimInstance -ClassName Win32_OperatingSystem -ErrorAction Stop $result.WindowsBuild = $os.BuildNumber } catch { Write-Verbose "Failed to query OS build: $($_.Exception.Message)" } # Check for NPU hardware via PnP devices try { $npuDevices = Get-PnpDevice -Class 'System' -ErrorAction SilentlyContinue | Where-Object { $_.FriendlyName -match 'NPU|Neural|AI Accelerator' -and $_.Status -eq 'OK' } if (-not $npuDevices) { # Also check for known NPU device classes $npuDevices = Get-PnpDevice -ErrorAction SilentlyContinue | Where-Object { $_.FriendlyName -match 'Qualcomm.*Hexagon|AMD.*AI|Intel.*NPU|Neural Processing' -and $_.Status -eq 'OK' } } if ($npuDevices) { $result.HasNPU = $true $result.NPUDeviceName = ($npuDevices | Select-Object -First 1).FriendlyName } } catch { Write-Verbose "Failed to query PnP devices for NPU: $($_.Exception.Message)" } # Check for Windows AI Fabric Service $aiService = Get-Service -Name 'WSAIFabricSvc' -ErrorAction SilentlyContinue if ($aiService) { $result.HasAIFabricService = $true $result.AIFabricServiceStatus = $aiService.Status.ToString() } # Check for active WorkloadsSessionHost processes $sessionHosts = @(Get-Process -Name 'WorkloadsSessionHost' -ErrorAction SilentlyContinue) $result.WorkloadsSessionHostCount = $sessionHosts.Count # Determine overall platform status $result.IsCopilotPlatform = ( $result.HasAIFabricService -or $result.HasNPU -or $result.WorkloadsSessionHostCount -gt 0 ) return $result } } |