Skip to content

Commit 8634a8f

Browse files
authored
Merge pull request #7863 from wattbt/patch-4
Code sample expanded upon
2 parents 5b0160e + 28cdc64 commit 8634a8f

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)