Skip to content

Commit 28cdc64

Browse files
authored
Code sample expanded upon
The sample discovery script to me anyway, seemed short on a practical example that a customer could build upon, and made it harder to understand at first glance, what the script should actually be doing. I've suggested using some code to first gather the results from the device, and then feed it into the hash, as I think it would help understanding. I've also removed the line in the output script that referenced a Microsoft employee's username - I don't think it is necessary to show the script being run, but just the actual output.
1 parent 5b0160e commit 28cdc64

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

memdocs/intune/protect/compliance-custom-script.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The discovery script:
3535

3636
- Is added to Intune before you create a compliance policy. After it's added, it will be available to select when you create a compliance policy with custom settings.
3737
- Runs on a device that receives the compliance policy. The script evaluates the conditions of the JSON file you upload to the same policy.
38-
- Identifies one or more settings, as defined in the JSON, and returns a list of discovered values for those settings. A single script can be assigned to each policy, and supports discovery of multiple settings.
38+
- Identifies one or more settings, as defined in the JSON, and returns a list of discovered values for those settings. A single script can be assigned to each policy, and supports discovery of multiple settings.
3939
- Must be compressed to output results in one line. For example: `$hash = @{ ModelName = "Dell"; BiosVersion = "1.24"; TPMChipPresent = $true}`
4040
- Must include the following line at the end of the script: `return $hash | ConvertTo-Json -Compress`
4141

@@ -44,14 +44,17 @@ The discovery script:
4444
The following is a sample PowerShell script.
4545

4646
```powershell
47-
$hash = @{ ModelName = "Dell"; BiosVersion = "1.24"; TPMChipPresent = $true}
47+
$WMI_ComputerSystem = Get-WMIObject -class Win32_ComputerSystem
48+
$WMI_BIOS = Get-WMIObject -class Win32_BIOS
49+
$TPM = Get-Tpm
50+
51+
$hash = @{ ModelName = $WMI_ComputerSystem.Model; BiosVersion = $WMI_BIOS.SMBIOSBIOSVersion; TPMChipPresent = $TPM.TPMPresent}
4852
return $hash | ConvertTo-Json -Compress
4953
```
5054

5155
The following is the output of the sample script:
5256

5357
```
54-
PS C:\Users\apervaiz\Documents> .\sample.ps1
5558
{"ModelName": "Dell","BiosVersion": 1.24,"TPMChipPresent": true}
5659
```
5760

@@ -72,4 +75,4 @@ PS C:\Users\apervaiz\Documents> .\sample.ps1
7275

7376
- [Use custom compliance settings](../protect/compliance-use-custom-settings.md)
7477
- [Create a JSON for custom compliance](../protect/compliance-custom-json.md)
75-
- [Create a compliance policy](../protect/create-compliance-policy.md)
78+
- [Create a compliance policy](../protect/create-compliance-policy.md)

0 commit comments

Comments
 (0)