The reconstructed evaluation script behind this rule's OVAL check(s) — every module a compound check combines, with this rule's own concrete values and DISA's SCC tool's real per-module mechanism curated from static teardown of SCC releases.
# Windows PowerShell
# Reconstructed from oval:mil.disa.stig.windows2022:def:254435
# Windows Server 2022 Deny access to this computer from the network user right on domain-joined member servers must be configured to prevent access from highly privileged domain accounts and local accounts and from unauthenticated access on all systems.
# Per-module read mechanism curated from static teardown of DISA's SCC tool
# (SCAP Compliance Checker) -- see the SCC Automation Reference above.
# wmi57_object (wmi57_test)
function test_1 {
return (((Get-CimInstance -Namespace 'root\cimv2' -Query 'SELECT DomainRole FROM win32_computersystem' | Select-Object -First 1) | Select-Object -ExpandProperty 'DomainRole') -eq '3')
}
# Deny access to this computer from the network - Guests
# userright_object (userright_test)
function test_2 {
return (($__tmp = "$env:TEMP\scc_userrights_$([guid]::NewGuid().Guid).cfg"; secedit /export /cfg $__tmp /areas USER_RIGHTS /quiet | Out-Null; $__m = Select-String -Path $__tmp -Pattern '^SeDenyNetworkLogonRight\s*=\s*(.*)$'; Remove-Item $__tmp -ErrorAction SilentlyContinue; if ($__m -and $__m.Matches[0].Groups[1].Value.Trim().Length -gt 0) { (($__m.Matches[0].Groups[1].Value -split ',') | ForEach-Object { $__sid = $_.Trim().TrimStart('*'); try { (New-Object System.Security.Principal.SecurityIdentifier($__sid)).Translate([System.Security.Principal.NTAccount]).Value -replace '^[^\\]*\\', '' } catch { $__sid } }) -join ',' } else { '' }) -eq 'Guests')
}
# Deny access to this computer from the network - Domain Admins
# userright_object (userright_test)
function test_3 {
return (($__tmp = "$env:TEMP\scc_userrights_$([guid]::NewGuid().Guid).cfg"; secedit /export /cfg $__tmp /areas USER_RIGHTS /quiet | Out-Null; $__m = Select-String -Path $__tmp -Pattern '^SeDenyNetworkLogonRight\s*=\s*(.*)$'; Remove-Item $__tmp -ErrorAction SilentlyContinue; if ($__m -and $__m.Matches[0].Groups[1].Value.Trim().Length -gt 0) { (($__m.Matches[0].Groups[1].Value -split ',') | ForEach-Object { $__sid = $_.Trim().TrimStart('*'); try { (New-Object System.Security.Principal.SecurityIdentifier($__sid)).Translate([System.Security.Principal.NTAccount]).Value -replace '^[^\\]*\\', '' } catch { $__sid } }) -join ',' } else { '' }) -match '^(?i)(.+\\)?Domain Admins$')
}
# Deny access to this computer from the network - Enterprise Admins
# userright_object (userright_test)
function test_4 {
return (($__tmp = "$env:TEMP\scc_userrights_$([guid]::NewGuid().Guid).cfg"; secedit /export /cfg $__tmp /areas USER_RIGHTS /quiet | Out-Null; $__m = Select-String -Path $__tmp -Pattern '^SeDenyNetworkLogonRight\s*=\s*(.*)$'; Remove-Item $__tmp -ErrorAction SilentlyContinue; if ($__m -and $__m.Matches[0].Groups[1].Value.Trim().Length -gt 0) { (($__m.Matches[0].Groups[1].Value -split ',') | ForEach-Object { $__sid = $_.Trim().TrimStart('*'); try { (New-Object System.Security.Principal.SecurityIdentifier($__sid)).Translate([System.Security.Principal.NTAccount]).Value -replace '^[^\\]*\\', '' } catch { $__sid } }) -join ',' } else { '' }) -match '^(?i)(.+\\)?Enterprise Admins$')
}
# Deny access to this computer from the network - Local account
# userright_object (userright_test)
function test_5 {
return (($__tmp = "$env:TEMP\scc_userrights_$([guid]::NewGuid().Guid).cfg"; secedit /export /cfg $__tmp /areas USER_RIGHTS /quiet | Out-Null; $__m = Select-String -Path $__tmp -Pattern '^SeDenyNetworkLogonRight\s*=\s*(.*)$'; Remove-Item $__tmp -ErrorAction SilentlyContinue; if ($__m -and $__m.Matches[0].Groups[1].Value.Trim().Length -gt 0) { (($__m.Matches[0].Groups[1].Value -split ',') | ForEach-Object { $__sid = $_.Trim().TrimStart('*'); try { (New-Object System.Security.Principal.SecurityIdentifier($__sid)).Translate([System.Security.Principal.NTAccount]).Value -replace '^[^\\]*\\', '' } catch { $__sid } }) -join ',' } else { '' }) -match '^(?i)(NT Authority\\)?Local account$')
}
# Deny access to this computer from the network - Local account and member of Administrators
# userright_object (userright_test)
function test_6 {
return (($__tmp = "$env:TEMP\scc_userrights_$([guid]::NewGuid().Guid).cfg"; secedit /export /cfg $__tmp /areas USER_RIGHTS /quiet | Out-Null; $__m = Select-String -Path $__tmp -Pattern '^SeDenyNetworkLogonRight\s*=\s*(.*)$'; Remove-Item $__tmp -ErrorAction SilentlyContinue; if ($__m -and $__m.Matches[0].Groups[1].Value.Trim().Length -gt 0) { (($__m.Matches[0].Groups[1].Value -split ',') | ForEach-Object { $__sid = $_.Trim().TrimStart('*'); try { (New-Object System.Security.Principal.SecurityIdentifier($__sid)).Translate([System.Security.Principal.NTAccount]).Value -replace '^[^\\]*\\', '' } catch { $__sid } }) -join ',' } else { '' }) -match '^(?i)(NT Authority\\)?Local account and member of Administrators group$')
}
# wmi57_object (wmi57_test)
function test_7 {
return (((Get-CimInstance -Namespace 'root\cimv2' -Query 'SELECT DomainRole FROM win32_computersystem' | Select-Object -First 1) | Select-Object -ExpandProperty 'DomainRole') -eq '2')
}
# Deny access to this computer from the network - Guests
# userright_object (userright_test)
function test_8 {
return (($__tmp = "$env:TEMP\scc_userrights_$([guid]::NewGuid().Guid).cfg"; secedit /export /cfg $__tmp /areas USER_RIGHTS /quiet | Out-Null; $__m = Select-String -Path $__tmp -Pattern '^SeDenyNetworkLogonRight\s*=\s*(.*)$'; Remove-Item $__tmp -ErrorAction SilentlyContinue; if ($__m -and $__m.Matches[0].Groups[1].Value.Trim().Length -gt 0) { (($__m.Matches[0].Groups[1].Value -split ',') | ForEach-Object { $__sid = $_.Trim().TrimStart('*'); try { (New-Object System.Security.Principal.SecurityIdentifier($__sid)).Translate([System.Security.Principal.NTAccount]).Value -replace '^[^\\]*\\', '' } catch { $__sid } }) -join ',' } else { '' }) -eq 'Guests')
}
if (((test_1 -and test_2 -and test_3 -and test_4 -and (test_5 -or test_6)) -or (test_7 -and test_8))) {
Write-Output "PASS"
} else {
Write-Output "FAIL"
} Assessment Script Powered by AISyntax-verified
A standalone PowerShell script to assess this control automatically. Review before running it in your environment.
Syntax-checked as valid PowerShell. Not executed here — running it for real needs the actual ms_windows_server_2022 target this check assesses.
# OVAL Definition: oval:mil.disa.stig.windows2022:def:254435
$userRights = Get-CimInstance -ClassName Win32_UserRight -Filter "Right='Deny access to this computer from the network'"
if ($userRights -eq $null) { exit 1 }
$expectedGroups = @("Guests", "^(?i)(.+\\\\)?Domain Admins$", "^(?i)(.+\\\\)?Enterprise Admins$", "^(?i)(NT Authority\\\\)?Local account$")
foreach ($group in $userRights) {
if ($group.Member -notcontains $expectedGroups) { exit 1 }
}
exit 0