##Enter the path to the registry key $regpath = "HKCU:\Software\Policies\Microsoft\Windows\WindowsAI" ##Enter the name of the registry key $regname = "DisableAIDataAnalysis" ##Enter the value of the registry key $regvalue = "1" Try { $Registry = Get-ItemProperty -Path $regpath -Name $regname -ErrorAction Stop | Select-Object -ExpandProperty $regname If ($Registry -eq $regvalue){ Write-Output "Compliant" Exit 0 } Write-Warning "Not Compliant" Exit 1 } Catch { Write-Output "RegKey Not Found, Compliant" Exit 0 }