Repository navigation
Expand file tree
/
Copy pathDetect-SSOPromptAdminControl.ps1
More file actions
72 lines (61 loc) · 2.07 KB
/
Copy pathDetect-SSOPromptAdminControl.ps1
File metadata and controls
72 lines (61 loc) · 2.07 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<#
.SYNOPSIS
Detect compliance for admin control of SSO prompts in Windows.
.DESCRIPTION
This script validates that the policy registry value for automatic acceptance of
SSO permissions is configured as expected.
.NOTES
Version: 1.1
Author: Martin Himken
Initial creation date: 23.08.26
Last change: 27.08.26
Changes: see changelog.md
Intune Remediation settings:
* Run this script using the logged-on credentials: No
* Enforce script signature check: No
* Run script in 64-bit PowerShell: Yes
#>
$ErrorActionPreference = 'Stop'
function Get-RegistryValueKind {
param(
[Parameter(Mandatory = $true)]
[string]$Path,
[Parameter(Mandatory = $true)]
[string]$Name
)
try {
$item = Get-Item -LiteralPath $Path -ErrorAction Stop
return $item.GetValueKind($Name)
} catch {
return $null
}
}
$registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AAD"
$valueName = "AutoAcceptSsoPermission"
$expectedValue = 1
try {
Write-Output "APPLICABLE: Device is in scope for compliance checks."
if (-not (Test-Path -LiteralPath $registryPath)) {
Write-Output "NONCOMPLIANT: Missing registry path $registryPath."
exit 1
}
$valueKind = Get-RegistryValueKind -Path $registryPath -Name $valueName
if ($null -eq $valueKind) {
Write-Output "NONCOMPLIANT: Missing value '$valueName' at $registryPath."
exit 1
}
if ([string]$valueKind -ne 'DWord') {
Write-Output "NONCOMPLIANT: '$valueName' at $registryPath is type $valueKind, expected DWord."
exit 1
}
$currentValue = Get-ItemPropertyValue -LiteralPath $registryPath -Name $valueName -ErrorAction SilentlyContinue
if ($null -eq $currentValue -or ([int]$currentValue -ne $expectedValue)) {
Write-Output "NONCOMPLIANT: '$valueName' at $registryPath is $currentValue, expected $expectedValue."
exit 1
}
Write-Output "COMPLIANT: '$valueName' at $registryPath is $expectedValue."
exit 0
} catch {
Write-Output "ERROR: Detection failed. $($_.Exception.Message)"
exit 1
}