How to detect and fix Windows issues using PowerShell remediation scripts with Endpoint analytics Proactive remediations
In this example, we have noticed an issue where the Windows license hasn't activated on some devices, and they are coming up with the error "Windows is not activated"
You can read more about how to solve that problem in this guide:
We will first use a detection PowerShell script to check the Windows activation status of devices.
If Windows has been activated OK the device will be "Compliant" if Windows is not activated, the device will be "Non Compliant"
Next, we will use another PowerShell remediation script to activate Windows using the firmware embedded BIOS key.
IF($licensestatus.LicenseStatus -eq "1")
{
$Compliance = "Compliant"
exit 0
}
Else
{
$Compliance = "NonCompliant"
exit 1
}
Return $Compliance
$ProductKey = (Get-CimInstance -ClassName SoftwareLicensingService).OA3xOriginalProductKey $Service = get-wmiObject -query 'select * from SoftwareLicensingService' $Service.InstallProductKey($ProductKey) $Service.RefreshLicenseStatus()
Logon to Endpoint Manager admin center
https://endpoint.microsoft.com
Reports - Endpoint Analytics
Proactive remediations - create script package
Name: Windows Not Activated
Detection script file - browse for and select Windows Activation detection script
Remediation script file - browse for and select Windows remediation detection script
Run script in 64-bit PowerShell Yes
We are not using scope tags in this example - click Next
Assign the script to a test group of devices
Click Create
Select the "Windows Not Activated Script"
From the Overview you can see the detection and remediation status
Under Device Status, you can see devices where the issue has been detected and remediated or where the issue has re-occurred
Reference:
Tutorial: Proactive remediations
by Author
https://docs.microsoft.com/en-us/mem/analytics/proactive-remediations
Comments