-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathWndows-CustomCompliance-MDE-Onboardingstate.ps1
More file actions
51 lines (41 loc) · 1.59 KB
/
Copy pathWndows-CustomCompliance-MDE-Onboardingstate.ps1
File metadata and controls
51 lines (41 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<#
.SYNOPSIS
DefenderforEndpoint-OnboardingState
.DESCRIPTION
DefenderforEndpoint-OnboardingState checks the Client onboarding state for Defender for Endpoint
.INPUTS
None. You cannot pipe objects to the script.
.OUTPUTS
System.Management.Automation.PSCustomObject
.NOTES
Example output: {"OnboardingState":1}
.COMPONENT
Microsoft Intune
#>
# Defender for Endpoint - Onboardingstate Registry settings
$registryPath = "HKLM:\SOFTWARE\Microsoft\Windows Advanced Threat Protection\Status"
$propertyName = "OnboardingState"
$expectedValue = 1
# Get the Defender for Endpoint Onboarding State
# Check if the registry key exists
if (Test-Path $registryPath) {
try {
# Try to get the value of the specified property
$OnboardingState = (Get-ItemProperty -Path $registryPath -Name $propertyName).$propertyName
if ($OnboardingState -eq $expectedValue) {
Write-output "Registry key '$registryPath\$propertyName' exists and has the expected value ($expectedValue)."
} else {
Write-output "Registry key '$registryPath\$propertyName' exists, but its value is not $expectedValue."
}
} catch {
Write-output "Failed to retrieve the value of '$propertyName' in registry key '$registryPath'."
}
} else {
Write-output "Registry key '$registryPath' does not exist."
}
# Return the encryption method
$OnboardingStateResult = [pscustomobject]@{
OnboardingState = $OnboardingState
}
# Return the encryption method as JSON
$OnboardingStateResult | Select-object -Property OnboardingState | ConvertTo-Json -Compress