These are sample script for Intune Custom Compliance policies
https://learn.microsoft.com/en-us/mem/intune/protect/compliance-custom-json
- Login into Intune Admin Center
- Navigate to Devices > Compliance > Scripts or Endpoint security > Device compliance > Scripts
- Click Add > Windows 10 or Later. Provide a Name, description, and publisher.
- Copy the contents of the script in the detection script settings. Then set:
- Run this script using the logged on credentials > NO
- Enforce script signature check > NO
- Run script in 64 bit PowerShell Host > YES
- Click Next > Create
- Login into Intune Admin Center
- Go to Devices > Windows > Compliance
- Click Create policy > Windows 10 and Later. Click Create
- Provide a Name and description. Click Next
- On the Compliance settings tab, expand Custom Compliance
- Set Custom compliance to Require
- Under Select your discovery script, select Click to select, and select the script that corresponds to this compliance policy
- Under Upload and validate the JSON file with your custom compliance settings, click the file icon and browse to the JSON file.
- Verify the Settings name, Operator and Value are accurate. There can be multiple
- Click Next, Keep Action for noncompliance if this is being used for Autopilot
- Click Next, select a tag or tags if required
- Click Next, assign the policy to groups that contain either devices or users (recommend)
- Click Next > Create