<# .SYNOPSIS Atlas AVD Endpoint Controls Assessment: a free, read-only check of the technical security controls you can validate on one Windows machine. .DESCRIPTION Runs locally on a Windows 10/11 workstation, Windows Server or Azure Virtual Desktop session host and reports, for each technical control it can see from the endpoint, whether it is in place. Every check names the CMMC 2.0 Level 2 practice (NIST SP 800-171 Rev. 2 requirement) it supports. What it does NOT do: - It changes nothing. Every check only reads the registry, WMI/CIM, built-in cmdlets or the output of built-in tools. - It sends nothing anywhere. There are no network calls; the report is written only to the folder you choose. - It is not a certification. Passing every check does not make a machine "CMMC compliant"; most practices also need policy, process and evidence that no script can see. Run it from an elevated PowerShell prompt for complete results. Without elevation, checks that need administrator rights (audit policy, BitLocker details, TPM) report "Unknown" rather than guessing. Published by Atlas AVD: https://www.atlasavd.com/tools/cmmc-readiness .PARAMETER OutputDirectory Folder for the HTML, JSON and CSV reports. Defaults to the current folder, or the Desktop when the current folder is under C:\Windows (as it is in a fresh elevated prompt). .PARAMETER NoReport Print the results to the console only; write no files. .PARAMETER ListControls List every control this script checks (ID, family, CMMC practice, title) without running any checks. .PARAMETER Practice Run only the checks for these CMMC 2.0 Level 2 practices (for example AC.L2-3.1.1, or the bare NIST number 3.1.1). Omit to run every check. .PARAMETER Control Run only these checks by ID (for example AC-03, SC-01). Omit to run every check. Combined with -Practice, a check runs when it matches either. .PARAMETER PassThru Also return the result objects to the pipeline. .EXAMPLE .\atlas-endpoint-assessment.ps1 Runs every check and writes the reports to the current folder. .EXAMPLE .\atlas-endpoint-assessment.ps1 -Practice AC.L2-3.1.1 Runs only the checks for one requirement. .EXAMPLE .\atlas-endpoint-assessment.ps1 -ListControls Shows the control catalogue without checking anything. .EXAMPLE .\atlas-endpoint-assessment.ps1 -OutputDirectory C:\Temp -PassThru | Where-Object Status -eq 'Fail' Writes the reports to C:\Temp and lists only the failing controls. .NOTES Version: 1.1.0 License: MIT. Free to use, copy and modify. Requires: Windows PowerShell 5.1 or PowerShell 7+ on Windows. #> [CmdletBinding()] param( [string]$OutputDirectory = '', [switch]$NoReport, [switch]$ListControls, [string[]]$Practice = @(), [string[]]$Control = @(), [switch]$PassThru ) $ErrorActionPreference = 'Stop' if (-not $OutputDirectory) { # An elevated prompt starts in System32; never drop reports there. $OutputDirectory = (Get-Location).Path if ($env:windir -and $OutputDirectory.StartsWith($env:windir, [StringComparison]::OrdinalIgnoreCase)) { $OutputDirectory = [Environment]::GetFolderPath('Desktop') if (-not $OutputDirectory) { $OutputDirectory = $env:USERPROFILE } } } $script:AssessmentVersion = '1.1.0' # -- Control catalogue -------------------------------------------------------- # One row per control. The website's control list (atlasavd.com/tools/ # cmmc-readiness) is generated from the same IDs and titles, and a test # there fails if the two drift apart. # Id stable identifier (family prefix + number) # Family NIST SP 800-171 family # Practice CMMC 2.0 Level 2 practice the check supports # Admin $true when the check needs an elevated prompt for a full answer $script:Catalogue = @( # Access Control @{ Id = 'AC-01'; Family = 'Access Control'; Practice = 'AC.L2-3.1.5'; Admin = $false; Title = 'Local Administrators group has no broad groups' } @{ Id = 'AC-02'; Family = 'Access Control'; Practice = 'AC.L2-3.1.5'; Admin = $false; Title = 'Built-in Administrator account is disabled' } @{ Id = 'AC-03'; Family = 'Access Control'; Practice = 'AC.L2-3.1.1'; Admin = $false; Title = 'Guest account is disabled' } @{ Id = 'AC-04'; Family = 'Access Control'; Practice = 'AC.L2-3.1.7'; Admin = $false; Title = 'User Account Control is on and prompts administrators' } @{ Id = 'AC-05'; Family = 'Access Control'; Practice = 'AC.L2-3.1.10'; Admin = $false; Title = 'Screen locks after 15 minutes or less of inactivity' } @{ Id = 'AC-06'; Family = 'Access Control'; Practice = 'AC.L2-3.1.9'; Admin = $false; Title = 'Logon banner (system use notification) is shown' } @{ Id = 'AC-07'; Family = 'Access Control'; Practice = 'AC.L2-3.1.13'; Admin = $false; Title = 'Remote Desktop requires Network Level Authentication' } @{ Id = 'AC-08'; Family = 'Access Control'; Practice = 'AC.L2-3.1.11'; Admin = $false; Title = 'Idle and disconnected remote sessions are ended' } @{ Id = 'AC-09'; Family = 'Access Control'; Practice = 'AC.L2-3.1.12'; Admin = $false; Title = 'Unsolicited Remote Assistance is off' } @{ Id = 'AC-10'; Family = 'Access Control'; Practice = 'AC.L2-3.1.1'; Admin = $false; Title = 'Anonymous enumeration of accounts and shares is blocked' } @{ Id = 'AC-11'; Family = 'Access Control'; Practice = 'AC.L2-3.1.3'; Admin = $false; Title = 'Remote Desktop drive and clipboard redirection is restricted' } @{ Id = 'AC-12'; Family = 'Access Control'; Practice = 'AC.L2-3.1.8'; Admin = $false; Title = 'Account lockout after 10 or fewer failed logons' } # Identification and Authentication @{ Id = 'IA-01'; Family = 'Identification and Authentication'; Practice = 'IA.L2-3.5.7'; Admin = $false; Title = 'Minimum password length is 14 or more' } @{ Id = 'IA-02'; Family = 'Identification and Authentication'; Practice = 'IA.L2-3.5.7'; Admin = $true; Title = 'Password complexity is required' } @{ Id = 'IA-03'; Family = 'Identification and Authentication'; Practice = 'IA.L2-3.5.8'; Admin = $false; Title = 'Password history remembers 24 or more passwords' } @{ Id = 'IA-04'; Family = 'Identification and Authentication'; Practice = 'IA.L2-3.5.10'; Admin = $false; Title = 'LAN Manager hashes are not stored' } @{ Id = 'IA-05'; Family = 'Identification and Authentication'; Practice = 'IA.L2-3.5.10'; Admin = $false; Title = 'Only NTLMv2 is sent; LM and NTLM are refused' } @{ Id = 'IA-06'; Family = 'Identification and Authentication'; Practice = 'IA.L2-3.5.10'; Admin = $false; Title = 'WDigest does not keep plaintext credentials in memory' } @{ Id = 'IA-07'; Family = 'Identification and Authentication'; Practice = 'IA.L2-3.5.10'; Admin = $false; Title = 'LSA runs as a protected process' } @{ Id = 'IA-08'; Family = 'Identification and Authentication'; Practice = 'IA.L2-3.5.10'; Admin = $false; Title = 'Credential Guard is running' } @{ Id = 'IA-09'; Family = 'Identification and Authentication'; Practice = 'IA.L2-3.5.2'; Admin = $false; Title = 'Device is joined to a directory (Entra ID or Active Directory)' } @{ Id = 'IA-10'; Family = 'Identification and Authentication'; Practice = 'IA.L2-3.5.10'; Admin = $false; Title = 'Cached domain logons are limited to 4 or fewer' } # Audit and Accountability @{ Id = 'AU-01'; Family = 'Audit and Accountability'; Practice = 'AU.L2-3.3.1'; Admin = $true; Title = 'Advanced audit policy covers logon, account and policy events' } @{ Id = 'AU-02'; Family = 'Audit and Accountability'; Practice = 'AU.L2-3.3.1'; Admin = $false; Title = 'Advanced audit policy overrides legacy category settings' } @{ Id = 'AU-03'; Family = 'Audit and Accountability'; Practice = 'AU.L2-3.3.2'; Admin = $false; Title = 'Process creation events include the command line' } @{ Id = 'AU-04'; Family = 'Audit and Accountability'; Practice = 'AU.L2-3.3.1'; Admin = $false; Title = 'PowerShell script block logging is on' } @{ Id = 'AU-05'; Family = 'Audit and Accountability'; Practice = 'AU.L2-3.3.1'; Admin = $false; Title = 'Security event log holds at least 192 MB' } @{ Id = 'AU-06'; Family = 'Audit and Accountability'; Practice = 'AU.L2-3.3.7'; Admin = $false; Title = 'Clock synchronizes with an authoritative time source' } # Configuration Management @{ Id = 'CM-01'; Family = 'Configuration Management'; Practice = 'CM.L2-3.4.1'; Admin = $false; Title = 'Windows version is still supported by Microsoft' } @{ Id = 'CM-02'; Family = 'Configuration Management'; Practice = 'CM.L2-3.4.6'; Admin = $false; Title = 'SMBv1 is disabled' } @{ Id = 'CM-03'; Family = 'Configuration Management'; Practice = 'CM.L2-3.4.6'; Admin = $false; Title = 'PowerShell 2.0 engine is removed' } @{ Id = 'CM-04'; Family = 'Configuration Management'; Practice = 'CM.L2-3.4.7'; Admin = $false; Title = 'Nonessential remote services are disabled' } @{ Id = 'CM-05'; Family = 'Configuration Management'; Practice = 'CM.L2-3.4.7'; Admin = $false; Title = 'LLMNR and NetBIOS name resolution are disabled' } @{ Id = 'CM-06'; Family = 'Configuration Management'; Practice = 'CM.L2-3.4.8'; Admin = $false; Title = 'Application control (App Control for Business or AppLocker) is enforced' } @{ Id = 'CM-07'; Family = 'Configuration Management'; Practice = 'CM.L2-3.4.9'; Admin = $false; Title = 'Windows Installer never runs with elevated privileges' } @{ Id = 'CM-08'; Family = 'Configuration Management'; Practice = 'CM.L2-3.4.6'; Admin = $false; Title = 'AutoRun and AutoPlay are disabled on all drives' } @{ Id = 'CM-09'; Family = 'Configuration Management'; Practice = 'CM.L2-3.4.2'; Admin = $false; Title = 'Secure Boot is enabled' } @{ Id = 'CM-10'; Family = 'Configuration Management'; Practice = 'CM.L2-3.4.1'; Admin = $false; Title = 'Installed software inventory' } # Media Protection @{ Id = 'MP-01'; Family = 'Media Protection'; Practice = 'MP.L2-3.8.7'; Admin = $false; Title = 'Removable storage access is restricted by policy' } # System and Communications Protection @{ Id = 'SC-01'; Family = 'System and Communications Protection'; Practice = 'SC.L2-3.13.1'; Admin = $false; Title = 'Windows Firewall is on for every profile' } @{ Id = 'SC-02'; Family = 'System and Communications Protection'; Practice = 'SC.L2-3.13.6'; Admin = $false; Title = 'Firewall blocks inbound connections by default' } @{ Id = 'SC-03'; Family = 'System and Communications Protection'; Practice = 'SC.L2-3.13.16'; Admin = $false; Title = 'System drive is encrypted with BitLocker' } @{ Id = 'SC-04'; Family = 'System and Communications Protection'; Practice = 'SC.L2-3.13.11'; Admin = $true; Title = 'BitLocker uses XTS-AES encryption' } @{ Id = 'SC-05'; Family = 'System and Communications Protection'; Practice = 'SC.L2-3.13.11'; Admin = $false; Title = 'FIPS-compliant algorithm policy is on' } @{ Id = 'SC-06'; Family = 'System and Communications Protection'; Practice = 'SC.L2-3.13.8'; Admin = $false; Title = 'SSL 3.0, TLS 1.0 and TLS 1.1 are disabled' } @{ Id = 'SC-07'; Family = 'System and Communications Protection'; Practice = 'SC.L2-3.13.8'; Admin = $false; Title = 'SMB signing is required (client and server)' } @{ Id = 'SC-08'; Family = 'System and Communications Protection'; Practice = 'SC.L2-3.13.8'; Admin = $false; Title = 'Remote Desktop uses TLS and high encryption' } @{ Id = 'SC-09'; Family = 'System and Communications Protection'; Practice = 'SC.L2-3.13.13'; Admin = $false; Title = 'Office blocks macros in files from the internet' } @{ Id = 'SC-10'; Family = 'System and Communications Protection'; Practice = 'SC.L2-3.13.10'; Admin = $true; Title = 'TPM is present and ready' } @{ Id = 'SC-11'; Family = 'System and Communications Protection'; Practice = 'SC.L2-3.13.2'; Admin = $false; Title = 'Memory integrity (HVCI) is running' } @{ Id = 'SC-12'; Family = 'System and Communications Protection'; Practice = 'SC.L2-3.13.1'; Admin = $false; Title = 'IP source routing is disabled' } # System and Information Integrity @{ Id = 'SI-01'; Family = 'System and Information Integrity'; Practice = 'SI.L2-3.14.2'; Admin = $false; Title = 'Antivirus real-time protection is on' } @{ Id = 'SI-02'; Family = 'System and Information Integrity'; Practice = 'SI.L2-3.14.4'; Admin = $false; Title = 'Antivirus signatures are less than 3 days old' } @{ Id = 'SI-03'; Family = 'System and Information Integrity'; Practice = 'SI.L2-3.14.5'; Admin = $false; Title = 'A malware scan ran in the last 7 days' } @{ Id = 'SI-04'; Family = 'System and Information Integrity'; Practice = 'SI.L2-3.14.2'; Admin = $false; Title = 'Defender tamper protection is on' } @{ Id = 'SI-05'; Family = 'System and Information Integrity'; Practice = 'SI.L2-3.14.2'; Admin = $false; Title = 'Cloud-delivered protection and PUA blocking are on' } @{ Id = 'SI-06'; Family = 'System and Information Integrity'; Practice = 'SI.L2-3.14.2'; Admin = $false; Title = 'Attack surface reduction rules are configured' } @{ Id = 'SI-07'; Family = 'System and Information Integrity'; Practice = 'SI.L2-3.14.6'; Admin = $false; Title = 'Network protection is on' } @{ Id = 'SI-08'; Family = 'System and Information Integrity'; Practice = 'SI.L2-3.14.7'; Admin = $false; Title = 'Endpoint detection and response sensor is running' } @{ Id = 'SI-09'; Family = 'System and Information Integrity'; Practice = 'SI.L2-3.14.1'; Admin = $false; Title = 'An update was installed in the last 35 days' } @{ Id = 'SI-10'; Family = 'System and Information Integrity'; Practice = 'SI.L2-3.14.1'; Admin = $false; Title = 'No reboot is pending to finish updates' } @{ Id = 'SI-11'; Family = 'System and Information Integrity'; Practice = 'SI.L2-3.14.2'; Admin = $false; Title = 'Microsoft Defender SmartScreen is on' } # Azure Virtual Desktop session hosts @{ Id = 'AVD-01'; Family = 'Azure Virtual Desktop'; Practice = 'AC.L2-3.1.3'; Admin = $false; Title = 'Screen capture protection is on' } @{ Id = 'AVD-02'; Family = 'Azure Virtual Desktop'; Practice = 'AC.L2-3.1.3'; Admin = $false; Title = 'Watermarking is on' } @{ Id = 'AVD-03'; Family = 'Azure Virtual Desktop'; Practice = 'AC.L2-3.1.3'; Admin = $false; Title = 'Profile containers (FSLogix) are configured' } ) # -Practice / -Control narrow the run to the checks for one or more # requirements. A practice matches on the full ID (AC.L2-3.1.1) exactly, or on # the bare NIST number (3.1.1), case-insensitively. A full ID with the wrong # family prefix (IA.L2-3.1.1) matches nothing rather than another requirement. $script:Filtered = $false if ($Practice.Count -gt 0 -or $Control.Count -gt 0) { $script:Filtered = $true $wantPractice = @($Practice | ForEach-Object { $_.Trim() }) $wantControl = @($Control | ForEach-Object { $_.Trim() }) $selected = @($script:Catalogue | Where-Object { $full = $_.Practice $bare = $full -replace '^[A-Za-z]{2}\.L2-', '' ($wantPractice -contains $full) -or ($wantPractice -contains $bare) -or ($wantControl -contains $_.Id) }) if ($selected.Count -eq 0) { Write-Error ('No checks match -Practice {0} -Control {1}. Run with -ListControls to see every practice and control ID.' -f ($Practice -join ','), ($Control -join ',')) return } $script:Catalogue = $selected } if ($ListControls) { $script:Catalogue | ForEach-Object { [pscustomobject]@{ Id = $_.Id Family = $_.Family Practice = $_.Practice NeedsAdmin = $_.Admin Title = $_.Title } } | Format-Table -AutoSize -Wrap return } if ($env:OS -ne 'Windows_NT') { Write-Error 'This assessment checks Windows controls and must run on Windows.' return } # -- Helpers ------------------------------------------------------------------ $script:IsAdmin = $false try { $principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) $script:IsAdmin = $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) } catch { $script:IsAdmin = $false } $script:OsInfo = $null try { $script:OsInfo = Get-CimInstance -ClassName Win32_OperatingSystem } catch { } $script:IsServer = $false # Windows 10/11 Enterprise multi-session reports ProductType 3 like a server, so # decide by the edition name instead. if ($script:OsInfo -and $script:OsInfo.Caption -match 'Server') { $script:IsServer = $true } $script:IsAvdHost = [bool](Get-Service -Name 'RDAgentBootLoader' -ErrorAction SilentlyContinue) # Windows PowerShell 5.1 turns a native tool's stderr into a terminating error # when $ErrorActionPreference is Stop, so native calls run under Continue. function Invoke-Native { param([string]$File, [string[]]$Arguments) $prev = $ErrorActionPreference $ErrorActionPreference = 'Continue' try { & $File @Arguments 2>$null } finally { $ErrorActionPreference = $prev } } $script:Inventory = @() function Get-RegValue { param([string]$Path, [string]$Name) try { $item = Get-ItemProperty -Path $Path -Name $Name -ErrorAction Stop return $item.$Name } catch { return $null } } function New-Result { param( [Parameter(Mandatory)] [string]$Id, [Parameter(Mandatory)] [ValidateSet('Pass', 'Fail', 'Warn', 'Info', 'Unknown', 'NotApplicable')] [string]$Status, [Parameter(Mandatory)] [string]$Observed, [string]$Expected = '', [string]$Remediation = '' ) [pscustomobject]@{ Id = $Id; Status = $Status; Observed = $Observed; Expected = $Expected; Remediation = $Remediation } } # Sentinel: a check that needs elevation and isn't elevated says so instead of guessing. function New-NeedsAdmin { param([string]$Id, [string]$Expected) New-Result -Id $Id -Status Unknown -Observed 'Not checked: run from an elevated PowerShell prompt to read this setting.' -Expected $Expected } $script:NetAccounts = $null function Get-NetAccountsPolicy { if ($null -ne $script:NetAccounts) { return $script:NetAccounts } $map = @{} $out = Invoke-Native 'net.exe' @('accounts') foreach ($line in $out) { if ($line -match '^\s*(.+?):\s+(.+?)\s*$') { $map[$Matches[1].Trim()] = $Matches[2].Trim() } } $script:NetAccounts = $map return $map } function Get-NetAccountsNumber { param([string]$Pattern) $policy = Get-NetAccountsPolicy foreach ($k in $policy.Keys) { if ($k -match $Pattern) { $v = $policy[$k] if ($v -match '^\d+$') { return [int]$v } return $v } } return $null } $script:SecEdit = $null function Get-SecEditPolicy { if ($null -ne $script:SecEdit) { return $script:SecEdit } $tmp = Join-Path $env:TEMP ("atlas-secedit-{0}.inf" -f [guid]::NewGuid()) $tmpLog = [IO.Path]::ChangeExtension($tmp, '.log') try { Invoke-Native 'secedit.exe' @('/export', '/cfg', $tmp, '/areas', 'SECURITYPOLICY', '/log', $tmpLog, '/quiet') | Out-Null $map = @{} if (Test-Path $tmp) { foreach ($line in (Get-Content -Path $tmp)) { if ($line -match '^\s*([^=;\[]+?)\s*=\s*(.*?)\s*$') { $map[$Matches[1]] = $Matches[2] } } } $script:SecEdit = $map } finally { foreach ($f in @($tmp, $tmpLog)) { if (Test-Path $f) { Remove-Item -Path $f -Force -ErrorAction SilentlyContinue } } } return $script:SecEdit } $script:MpStatus = $null $script:MpPref = $null function Get-DefenderState { if ($null -eq $script:MpStatus) { try { $script:MpStatus = Get-MpComputerStatus -ErrorAction Stop } catch { $script:MpStatus = $false } } if ($null -eq $script:MpPref) { try { $script:MpPref = Get-MpPreference -ErrorAction Stop } catch { $script:MpPref = $false } } } # Defender in passive or EDR block mode can still report AntivirusEnabled and # real-time protection as true while another product does the blocking; only # Normal (active) mode means Defender's protections are in force. function Test-DefenderActive { if (-not $script:MpStatus) { return $false } if (-not $script:MpStatus.AntivirusEnabled) { return $false } if ($script:MpStatus.PSObject.Properties['AMRunningMode'] -and $script:MpStatus.AMRunningMode -and $script:MpStatus.AMRunningMode -ne 'Normal') { return $false } return $true } $script:DeviceGuard = $null function Get-DeviceGuardState { if ($null -eq $script:DeviceGuard) { try { $script:DeviceGuard = Get-CimInstance -Namespace 'root\Microsoft\Windows\DeviceGuard' -ClassName Win32_DeviceGuard -ErrorAction Stop } catch { $script:DeviceGuard = $false } } return $script:DeviceGuard } # -- Checks ------------------------------------------------------------------- # Each check returns one New-Result. A check that throws is reported as # Unknown with the error, never as a pass. $script:Checks = [ordered]@{} # Access Control --------------------------------------------------------------- $script:Checks['AC-01'] = { $broadSids = @('S-1-1-0', 'S-1-5-11', 'S-1-5-4', 'S-1-5-32-545') # Everyone, Authenticated Users, Interactive, Users $members = @() try { $members = @(Get-LocalGroupMember -SID 'S-1-5-32-544' -ErrorAction Stop) } catch { # Get-LocalGroupMember fails on orphaned SIDs; fall back to ADSI. $group = [ADSI]"WinNT://$env:COMPUTERNAME/$((New-Object Security.Principal.SecurityIdentifier('S-1-5-32-544')).Translate([Security.Principal.NTAccount]).Value.Split('\')[-1]),group" $members = @($group.Invoke('Members') | ForEach-Object { $path = $_.GetType().InvokeMember('ADsPath', 'GetProperty', $null, $_, $null) $sidBytes = $_.GetType().InvokeMember('objectSid', 'GetProperty', $null, $_, $null) $sid = $null if ($sidBytes) { $sid = (New-Object Security.Principal.SecurityIdentifier($sidBytes, 0)) } [pscustomobject]@{ Name = ($path -replace '^WinNT://', '' -replace '/', '\'); SID = $sid } }) } $names = @($members | ForEach-Object { $_.Name }) $broad = @($members | Where-Object { $_.SID -and ($broadSids -contains $_.SID.Value -or $_.SID.Value -match '-513$') }) $observed = "{0} member(s): {1}" -f $names.Count, ($names -join ', ') if ($broad.Count -gt 0) { return New-Result -Id 'AC-01' -Status Fail -Observed $observed -Expected 'Only named administrator accounts or a dedicated admin group.' -Remediation ("Remove {0} from the local Administrators group." -f (($broad | ForEach-Object { $_.Name }) -join ', ')) } if ($names.Count -gt 4) { return New-Result -Id 'AC-01' -Status Warn -Observed $observed -Expected '4 or fewer members, each with a documented need.' -Remediation 'Review each member and remove standing admin rights that are not required (use just-in-time elevation instead).' } New-Result -Id 'AC-01' -Status Pass -Observed $observed -Expected 'Only named administrator accounts or a dedicated admin group.' } $script:Checks['AC-02'] = { $acct = Get-CimInstance -ClassName Win32_UserAccount -Filter "LocalAccount=True" | Where-Object { $_.SID -match '-500$' } | Select-Object -First 1 if (-not $acct) { return New-Result -Id 'AC-02' -Status NotApplicable -Observed 'No local built-in Administrator account (domain controller or removed).' } if ($acct.Disabled) { return New-Result -Id 'AC-02' -Status Pass -Observed ("'{0}' is disabled." -f $acct.Name) -Expected 'Disabled' } New-Result -Id 'AC-02' -Status Fail -Observed ("'{0}' is enabled." -f $acct.Name) -Expected 'Disabled' -Remediation 'Disable the built-in Administrator (Accounts: Administrator account status = Disabled) and manage local admin passwords with Windows LAPS.' } $script:Checks['AC-03'] = { $acct = Get-CimInstance -ClassName Win32_UserAccount -Filter "LocalAccount=True" | Where-Object { $_.SID -match '-501$' } | Select-Object -First 1 if (-not $acct) { return New-Result -Id 'AC-03' -Status NotApplicable -Observed 'No local Guest account.' } if ($acct.Disabled) { return New-Result -Id 'AC-03' -Status Pass -Observed 'Guest account is disabled.' -Expected 'Disabled' } New-Result -Id 'AC-03' -Status Fail -Observed 'Guest account is enabled.' -Expected 'Disabled' -Remediation 'Set Accounts: Guest account status = Disabled.' } $script:Checks['AC-04'] = { $p = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' $lua = Get-RegValue $p 'EnableLUA' $consent = Get-RegValue $p 'ConsentPromptBehaviorAdmin' $secureDesktop = Get-RegValue $p 'PromptOnSecureDesktop' $observed = "EnableLUA={0}; ConsentPromptBehaviorAdmin={1}; PromptOnSecureDesktop={2}" -f $lua, $consent, $secureDesktop if ($lua -ne 1) { return New-Result -Id 'AC-04' -Status Fail -Observed $observed -Expected 'EnableLUA=1' -Remediation 'Turn on User Account Control (User Account Control: Run all administrators in Admin Approval Mode = Enabled) and restart.' } if ($consent -eq 0) { return New-Result -Id 'AC-04' -Status Fail -Observed $observed -Expected 'ConsentPromptBehaviorAdmin 1, 2 or 5 (prompt)' -Remediation 'Set "Behavior of the elevation prompt for administrators" to prompt for consent or credentials on the secure desktop.' } if ($secureDesktop -eq 0) { return New-Result -Id 'AC-04' -Status Warn -Observed $observed -Expected 'PromptOnSecureDesktop=1' -Remediation 'Set "Switch to the secure desktop when prompting for elevation" = Enabled.' } New-Result -Id 'AC-04' -Status Pass -Observed $observed -Expected 'UAC on, administrators prompted on the secure desktop' } $script:Checks['AC-05'] = { $timeout = Get-RegValue 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' 'InactivityTimeoutSecs' if ($null -ne $timeout -and [int]$timeout -gt 0 -and [int]$timeout -le 900) { return New-Result -Id 'AC-05' -Status Pass -Observed ("Machine inactivity limit: {0} seconds." -f $timeout) -Expected '1-900 seconds' } # Fall back to the user's policy-enforced screen saver lock. $ssPath = 'HKCU:\Software\Policies\Microsoft\Windows\Control Panel\Desktop' $ssActive = Get-RegValue $ssPath 'ScreenSaveActive' $ssSecure = Get-RegValue $ssPath 'ScreenSaverIsSecure' $ssTimeout = Get-RegValue $ssPath 'ScreenSaveTimeOut' if ($ssActive -eq '1' -and $ssSecure -eq '1' -and $ssTimeout -match '^\d+$' -and [int]$ssTimeout -gt 0 -and [int]$ssTimeout -le 900) { return New-Result -Id 'AC-05' -Status Pass -Observed ("Password-protected screen saver enforced by user policy after {0} seconds (read for {1}; set the machine inactivity limit to cover every user)." -f $ssTimeout, $env:USERNAME) -Expected '15 minutes or less' } $observed = if ($null -eq $timeout) { 'No machine inactivity limit or enforced screen saver lock is set.' } else { "Machine inactivity limit: $timeout seconds." } New-Result -Id 'AC-05' -Status Fail -Observed $observed -Expected '15 minutes (900 seconds) or less' -Remediation 'Set "Interactive logon: Machine inactivity limit" to 900 seconds or less.' } $script:Checks['AC-06'] = { $p = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' $caption = Get-RegValue $p 'LegalNoticeCaption' $text = Get-RegValue $p 'LegalNoticeText' if ($caption -and $text) { return New-Result -Id 'AC-06' -Status Pass -Observed ("Banner titled '{0}' is configured." -f $caption) -Expected 'A logon banner with title and text' } New-Result -Id 'AC-06' -Status Fail -Observed 'No logon banner is configured.' -Expected 'A logon banner with title and text' -Remediation 'Set "Interactive logon: Message title/text for users attempting to log on" with your organization''s CUI system use notice.' } $script:Checks['AC-07'] = { $deny = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' 'fDenyTSConnections' $nla = Get-RegValue 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' 'UserAuthentication' if ($null -eq $nla) { $nla = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' 'UserAuthentication' } if ($deny -eq 1 -and -not $script:IsAvdHost) { return New-Result -Id 'AC-07' -Status NotApplicable -Observed 'Remote Desktop is turned off.' } if ($nla -eq 1) { return New-Result -Id 'AC-07' -Status Pass -Observed 'Network Level Authentication is required.' -Expected 'UserAuthentication=1' } New-Result -Id 'AC-07' -Status Fail -Observed 'Remote Desktop is on and does not require Network Level Authentication.' -Expected 'UserAuthentication=1' -Remediation 'Set "Require user authentication for remote connections by using Network Level Authentication" = Enabled.' } $script:Checks['AC-08'] = { $p = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' $idle = Get-RegValue $p 'MaxIdleTime' $disc = Get-RegValue $p 'MaxDisconnectionTime' $deny = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' 'fDenyTSConnections' if ($deny -eq 1 -and -not $script:IsAvdHost) { return New-Result -Id 'AC-08' -Status NotApplicable -Observed 'Remote Desktop is turned off.' } $observed = "Idle limit: {0}; disconnected limit: {1} (milliseconds; blank = never)" -f $idle, $disc if ($idle -and [int64]$idle -gt 0 -and $disc -and [int64]$disc -gt 0) { return New-Result -Id 'AC-08' -Status Pass -Observed $observed -Expected 'Both limits set' } New-Result -Id 'AC-08' -Status Fail -Observed $observed -Expected 'Idle and disconnected session time limits set' -Remediation 'Set "Set time limit for active but idle Remote Desktop Services sessions" and "Set time limit for disconnected sessions" (Remote Desktop Session Host > Session Time Limits).' } $script:Checks['AC-09'] = { $pol = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' $local = 'HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance' $unsolicited = Get-RegValue $pol 'fAllowUnsolicited' if ($null -eq $unsolicited) { $unsolicited = Get-RegValue $local 'fAllowUnsolicited' } $help = Get-RegValue $pol 'fAllowToGetHelp' if ($null -eq $help) { $help = Get-RegValue $local 'fAllowToGetHelp' } $observed = "Unsolicited (offer) assistance: fAllowUnsolicited={0}; solicited assistance: fAllowToGetHelp={1}" -f $unsolicited, $help if ($unsolicited -eq 1) { return New-Result -Id 'AC-09' -Status Fail -Observed $observed -Expected 'fAllowUnsolicited=0' -Remediation 'Set "Configure Offer Remote Assistance" = Disabled.' } if ($help -eq 1) { return New-Result -Id 'AC-09' -Status Warn -Observed $observed -Expected 'fAllowUnsolicited=0, fAllowToGetHelp=0' -Remediation 'Set "Configure Solicited Remote Assistance" = Disabled; use your approved remote support tool instead.' } New-Result -Id 'AC-09' -Status Pass -Observed $observed -Expected 'fAllowUnsolicited=0, fAllowToGetHelp=0' } $script:Checks['AC-10'] = { $p = 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' $ra = Get-RegValue $p 'RestrictAnonymous' $raSam = Get-RegValue $p 'RestrictAnonymousSAM' $everyone = Get-RegValue $p 'EveryoneIncludesAnonymous' $observed = "RestrictAnonymous={0}; RestrictAnonymousSAM={1}; EveryoneIncludesAnonymous={2}" -f $ra, $raSam, $everyone if ($ra -ge 1 -and $raSam -eq 1 -and $everyone -ne 1) { return New-Result -Id 'AC-10' -Status Pass -Observed $observed -Expected 'RestrictAnonymous=1, RestrictAnonymousSAM=1' } New-Result -Id 'AC-10' -Status Fail -Observed $observed -Expected 'RestrictAnonymous=1, RestrictAnonymousSAM=1, EveryoneIncludesAnonymous=0' -Remediation 'Enable "Network access: Do not allow anonymous enumeration of SAM accounts and shares".' } $script:Checks['AC-11'] = { $p = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' $drives = Get-RegValue $p 'fDisableCdm' $clip = Get-RegValue $p 'fDisableClip' $deny = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' 'fDenyTSConnections' if ($deny -eq 1 -and -not $script:IsAvdHost) { return New-Result -Id 'AC-11' -Status NotApplicable -Observed 'Remote Desktop is turned off.' } $observed = "Drive redirection disabled: {0}; clipboard redirection disabled: {1}" -f ($drives -eq 1), ($clip -eq 1) if ($drives -eq 1 -and $clip -eq 1) { return New-Result -Id 'AC-11' -Status Pass -Observed $observed -Expected 'Both disabled, or limited by an AVD RDP property' } if ($drives -eq 1 -or $clip -eq 1) { return New-Result -Id 'AC-11' -Status Warn -Observed $observed -Expected 'Both disabled' -Remediation 'Disable the remaining redirection so CUI cannot be copied off the host.' } New-Result -Id 'AC-11' -Status Warn -Observed ($observed + '. (On AVD this may instead be set by the host pool''s RDP properties, which this check cannot see.)') -Expected 'Drive and clipboard redirection disabled' -Remediation 'Set "Do not allow drive redirection" and "Do not allow Clipboard redirection", or set drivestoredirect:s: and redirectclipboard:i:0 on the host pool.' } $script:Checks['AC-12'] = { $threshold = Get-NetAccountsNumber 'lockout threshold' if ($threshold -is [string] -and $threshold -notmatch 'Never') { $threshold = $null } if ($null -eq $threshold) { return New-Result -Id 'AC-12' -Status Unknown -Observed 'Could not read the account lockout policy.' -Expected '1-10' } if ($threshold -is [int] -and $threshold -ge 1 -and $threshold -le 10) { return New-Result -Id 'AC-12' -Status Pass -Observed ("Lockout after {0} failed attempts." -f $threshold) -Expected '1-10' } New-Result -Id 'AC-12' -Status Fail -Observed ("Lockout threshold: {0}." -f $threshold) -Expected '1-10 failed attempts' -Remediation 'Set "Account lockout threshold" to 10 or fewer invalid logon attempts.' } # Identification and Authentication ------------------------------------------- $script:Checks['IA-01'] = { $len = Get-NetAccountsNumber 'minimum password length' if ($null -ne $len -and $len -isnot [int]) { $len = $null } if ($null -eq $len) { return New-Result -Id 'IA-01' -Status Unknown -Observed 'Could not read the password policy.' -Expected '14 or more' } if ($len -ge 14) { return New-Result -Id 'IA-01' -Status Pass -Observed ("Minimum length {0}." -f $len) -Expected '14 or more' } if ($len -ge 12) { return New-Result -Id 'IA-01' -Status Warn -Observed ("Minimum length {0}." -f $len) -Expected '14 or more' -Remediation 'Raise "Minimum password length" to 14.' } New-Result -Id 'IA-01' -Status Fail -Observed ("Minimum length {0}." -f $len) -Expected '14 or more' -Remediation 'Set "Minimum password length" to 14 or more.' } $script:Checks['IA-02'] = { if (-not $script:IsAdmin) { return New-NeedsAdmin 'IA-02' 'PasswordComplexity=1' } $policy = Get-SecEditPolicy $c = $policy['PasswordComplexity'] if ($null -eq $c) { return New-Result -Id 'IA-02' -Status Unknown -Observed 'Could not read the local security policy export.' -Expected 'Enabled' } if ($c -eq '1') { return New-Result -Id 'IA-02' -Status Pass -Observed 'Password complexity is required.' -Expected 'Enabled' } New-Result -Id 'IA-02' -Status Fail -Observed ("PasswordComplexity={0}" -f $c) -Expected 'Enabled' -Remediation 'Set "Password must meet complexity requirements" = Enabled.' } $script:Checks['IA-03'] = { $hist = Get-NetAccountsNumber 'password history' if ($hist -is [string]) { if ($hist -match 'None') { $hist = 0 } else { $hist = $null } } if ($null -eq $hist) { return New-Result -Id 'IA-03' -Status Unknown -Observed 'Could not read the password policy.' -Expected '24 or more' } if ($hist -ge 24) { return New-Result -Id 'IA-03' -Status Pass -Observed ("Remembers {0} passwords." -f $hist) -Expected '24 or more' } New-Result -Id 'IA-03' -Status Fail -Observed ("Remembers {0} passwords." -f $hist) -Expected '24 or more' -Remediation 'Set "Enforce password history" to 24.' } $script:Checks['IA-04'] = { $v = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' 'NoLMHash' if ($v -eq 1) { return New-Result -Id 'IA-04' -Status Pass -Observed 'NoLMHash=1' -Expected 'NoLMHash=1' } New-Result -Id 'IA-04' -Status Fail -Observed ("NoLMHash={0}" -f $v) -Expected 'NoLMHash=1' -Remediation 'Enable "Network security: Do not store LAN Manager hash value on next password change".' } $script:Checks['IA-05'] = { $v = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' 'LmCompatibilityLevel' if ($v -eq 5) { return New-Result -Id 'IA-05' -Status Pass -Observed 'LmCompatibilityLevel=5' -Expected '5' } if ($null -eq $v -or $v -ge 3) { return New-Result -Id 'IA-05' -Status Warn -Observed ("LmCompatibilityLevel={0} (Windows default 3 sends NTLMv2 but still accepts LM/NTLM)." -f $v) -Expected '5' -Remediation 'Set "Network security: LAN Manager authentication level" to "Send NTLMv2 response only. Refuse LM & NTLM".' } New-Result -Id 'IA-05' -Status Fail -Observed ("LmCompatibilityLevel={0}" -f $v) -Expected '5' -Remediation 'Set "Network security: LAN Manager authentication level" to "Send NTLMv2 response only. Refuse LM & NTLM".' } $script:Checks['IA-06'] = { $v = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest' 'UseLogonCredential' if ($v -eq 1) { return New-Result -Id 'IA-06' -Status Fail -Observed 'UseLogonCredential=1: plaintext credentials are cached.' -Expected '0 or not set' -Remediation 'Set HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest\UseLogonCredential to 0.' } New-Result -Id 'IA-06' -Status Pass -Observed ("UseLogonCredential={0} (not set means off on Windows 8.1 and later)." -f $v) -Expected '0 or not set' } $script:Checks['IA-07'] = { $v = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' 'RunAsPPL' $boot = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' 'RunAsPPLBoot' if ($v -eq 1 -or $v -eq 2 -or $boot -ge 1) { return New-Result -Id 'IA-07' -Status Pass -Observed ("RunAsPPL={0}" -f $v) -Expected 'RunAsPPL=1 or 2' } New-Result -Id 'IA-07' -Status Fail -Observed ("RunAsPPL={0}" -f $v) -Expected 'RunAsPPL=1 or 2' -Remediation 'Enable "Configure LSASS to run as a protected process" (Local Security Authority) and restart.' } $script:Checks['IA-08'] = { $dg = Get-DeviceGuardState if (-not $dg) { return New-Result -Id 'IA-08' -Status Unknown -Observed 'Device Guard status is not available on this system.' -Expected 'Credential Guard running' } if (@($dg.SecurityServicesRunning) -contains 1) { return New-Result -Id 'IA-08' -Status Pass -Observed 'Credential Guard is running.' -Expected 'Running' } New-Result -Id 'IA-08' -Status Fail -Observed 'Credential Guard is not running.' -Expected 'Running' -Remediation 'Turn on Virtualization Based Security with Credential Guard (Device Guard policy or Intune) on hardware that supports it.' } $script:Checks['IA-09'] = { $out = Invoke-Native 'dsregcmd.exe' @('/status') $aad = ($out | Select-String -Pattern 'AzureAdJoined\s*:\s*YES' -Quiet) $dom = ($out | Select-String -Pattern 'DomainJoined\s*:\s*YES' -Quiet) $cs = Get-CimInstance -ClassName Win32_ComputerSystem if (-not $dom -and $cs.PartOfDomain) { $dom = $true } $parts = @() if ($aad) { $parts += 'Microsoft Entra ID' } if ($dom) { $parts += ("Active Directory ({0})" -f $cs.Domain) } if ($parts.Count -gt 0) { return New-Result -Id 'IA-09' -Status Pass -Observed ("Joined to " + ($parts -join ' and ') + '.') -Expected 'Joined' } New-Result -Id 'IA-09' -Status Fail -Observed 'Not joined to Entra ID or Active Directory (workgroup).' -Expected 'Joined' -Remediation 'Join the device to Microsoft Entra ID or your domain so its identity and policy are centrally managed.' } $script:Checks['IA-10'] = { $cs = Get-CimInstance -ClassName Win32_ComputerSystem if (-not $cs.PartOfDomain) { return New-Result -Id 'IA-10' -Status NotApplicable -Observed 'Not joined to an Active Directory domain.' } $v = Get-RegValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' 'CachedLogonsCount' if ($null -ne $v -and [int]$v -le 4) { return New-Result -Id 'IA-10' -Status Pass -Observed ("CachedLogonsCount={0}" -f $v) -Expected '4 or fewer' } New-Result -Id 'IA-10' -Status Warn -Observed ("CachedLogonsCount={0} (default 10)" -f $v) -Expected '4 or fewer' -Remediation 'Set "Interactive logon: Number of previous logons to cache" to 4 or fewer (laptops that leave the network may need 1-2).' } # Audit and Accountability ---------------------------------------------------- $script:Checks['AU-01'] = { if (-not $script:IsAdmin) { return New-NeedsAdmin 'AU-01' 'Success and Failure on key subcategories' } # GUIDs are language-independent; the names are only for the report. $required = @( @{ Guid = '{0CCE923F-69AE-11D9-BED3-505054503030}'; Name = 'Credential Validation'; Need = 'Success and Failure' } @{ Guid = '{0CCE9215-69AE-11D9-BED3-505054503030}'; Name = 'Logon'; Need = 'Success and Failure' } @{ Guid = '{0CCE9217-69AE-11D9-BED3-505054503030}'; Name = 'Account Lockout'; Need = 'Failure' } @{ Guid = '{0CCE9235-69AE-11D9-BED3-505054503030}'; Name = 'User Account Management'; Need = 'Success and Failure' } @{ Guid = '{0CCE9237-69AE-11D9-BED3-505054503030}'; Name = 'Security Group Management'; Need = 'Success' } @{ Guid = '{0CCE922F-69AE-11D9-BED3-505054503030}'; Name = 'Audit Policy Change'; Need = 'Success' } @{ Guid = '{0CCE9228-69AE-11D9-BED3-505054503030}'; Name = 'Sensitive Privilege Use'; Need = 'Success and Failure' } @{ Guid = '{0CCE922B-69AE-11D9-BED3-505054503030}'; Name = 'Process Creation'; Need = 'Success' } @{ Guid = '{0CCE9211-69AE-11D9-BED3-505054503030}'; Name = 'Security System Extension'; Need = 'Success' } ) $missing = @() foreach ($r in $required) { $raw = Invoke-Native 'auditpol.exe' @('/get', "/subcategory:$($r.Guid)", '/r') | Where-Object { $_ } | ConvertFrom-Csv | Select-Object -First 1 $value = '' if ($raw) { $value = $raw.'Setting Value' } # Setting Value: 0 none, 1 success, 2 failure, 3 both $needBits = switch ($r.Need) { 'Success' { 1 } 'Failure' { 2 } default { 3 } } if (-not ($value -match '^\d+$') -or (([int]$value -band $needBits) -ne $needBits)) { $missing += ("{0} (needs {1})" -f $r.Name, $r.Need) } } if ($missing.Count -eq 0) { return New-Result -Id 'AU-01' -Status Pass -Observed ("All {0} key subcategories are audited." -f $required.Count) -Expected 'Key subcategories audited' } New-Result -Id 'AU-01' -Status Fail -Observed ("Not audited: " + ($missing -join '; ')) -Expected 'Key subcategories audited' -Remediation 'Configure Advanced Audit Policy for the listed subcategories (Group Policy or Intune).' } $script:Checks['AU-02'] = { $v = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa' 'SCENoApplyLegacyAuditPolicy' if ($v -eq 1) { return New-Result -Id 'AU-02' -Status Pass -Observed 'SCENoApplyLegacyAuditPolicy=1' -Expected '1' } New-Result -Id 'AU-02' -Status Warn -Observed ("SCENoApplyLegacyAuditPolicy={0}" -f $v) -Expected '1' -Remediation 'Enable "Audit: Force audit policy subcategory settings to override audit policy category settings".' } $script:Checks['AU-03'] = { $v = Get-RegValue 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\Audit' 'ProcessCreationIncludeCmdLine_Enabled' if ($v -eq 1) { return New-Result -Id 'AU-03' -Status Pass -Observed 'Command line is included in event 4688.' -Expected 'Enabled' } New-Result -Id 'AU-03' -Status Fail -Observed 'Command line is not included in process creation events.' -Expected 'Enabled' -Remediation 'Enable "Include command line in process creation events" (System > Audit Process Creation).' } $script:Checks['AU-04'] = { $v = Get-RegValue 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' 'EnableScriptBlockLogging' if ($v -eq 1) { return New-Result -Id 'AU-04' -Status Pass -Observed 'Script block logging is enabled by policy.' -Expected 'Enabled' } New-Result -Id 'AU-04' -Status Fail -Observed 'Script block logging is not enabled.' -Expected 'Enabled' -Remediation 'Enable "Turn on PowerShell Script Block Logging" (Windows Components > Windows PowerShell).' } $script:Checks['AU-05'] = { $max = Get-RegValue 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\EventLog\Security' 'MaxSize' # KB if ($null -eq $max) { $bytes = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\Security' 'MaxSize' if ($null -ne $bytes) { $max = [math]::Round([int64]$bytes / 1KB) } } if ($null -eq $max) { return New-Result -Id 'AU-05' -Status Unknown -Observed 'Could not read the Security log size.' -Expected '196608 KB or more' } $mb = [math]::Round([int64]$max / 1024) if ([int64]$max -ge 196608) { return New-Result -Id 'AU-05' -Status Pass -Observed ("Security log maximum size: {0} MB." -f $mb) -Expected '192 MB or more' } New-Result -Id 'AU-05' -Status Fail -Observed ("Security log maximum size: {0} MB." -f $mb) -Expected '192 MB or more (or forwarded to a SIEM)' -Remediation 'Set "Security: Specify the maximum log file size (KB)" to 196608 or more, and forward events to your SIEM.' } $script:Checks['AU-06'] = { $svc = Get-Service -Name 'W32Time' -ErrorAction SilentlyContinue if (-not $svc) { return New-Result -Id 'AU-06' -Status Fail -Observed 'Windows Time service is not installed.' -Expected 'Running and synchronized' } $source = (Invoke-Native 'w32tm.exe' @('/query', '/source') | Select-Object -First 1) if ($source) { $source = $source.Trim() } if ($svc.Status -ne 'Running') { return New-Result -Id 'AU-06' -Status Fail -Observed ("Windows Time service is {0}." -f $svc.Status) -Expected 'Running' -Remediation 'Start the Windows Time service and set it to Automatic.' } if ($source -match '0x[0-9A-Fa-f]{8}|denied|error') { return New-Result -Id 'AU-06' -Status Unknown -Observed 'Could not query the time source; run elevated.' -Expected 'An authoritative time source' } if (-not $source -or $source -match 'Local CMOS Clock|Free-running') { return New-Result -Id 'AU-06' -Status Fail -Observed ("Time source: {0}" -f $source) -Expected 'Domain hierarchy, Azure host or an NTP server' -Remediation 'Configure an authoritative time source (NT5DS for domain members, or an NTP server).' } New-Result -Id 'AU-06' -Status Pass -Observed ("Time source: {0}" -f $source) -Expected 'An authoritative time source' } # Configuration Management ---------------------------------------------------- $script:Checks['CM-01'] = { if (-not $script:OsInfo) { return New-Result -Id 'CM-01' -Status Unknown -Observed 'Could not read the Windows version.' } $build = [int]$script:OsInfo.BuildNumber $caption = $script:OsInfo.Caption $isEnt = $caption -match 'Enterprise|Education' $today = Get-Date # End of servicing dates for the version each build number ships. Enterprise and # Education editions get a longer window for H2 releases of Windows 11. $eos = $null $label = $null if ($script:IsServer) { switch ($build) { { $_ -ge 26100 } { $eos = [datetime]'2034-10-10'; $label = 'Windows Server 2025'; break } { $_ -ge 25398 } { $eos = [datetime]'2025-10-24'; $label = 'Windows Server Annual Channel 23H2'; break } { $_ -ge 20348 } { $eos = [datetime]'2031-10-14'; $label = 'Windows Server 2022'; break } { $_ -ge 17763 } { $eos = [datetime]'2029-01-09'; $label = 'Windows Server 2019'; break } { $_ -ge 14393 } { $eos = [datetime]'2027-01-12'; $label = 'Windows Server 2016'; break } default { $eos = [datetime]'2023-10-10'; $label = 'Windows Server 2012 R2 or older' } } } else { switch ($build) { { $_ -ge 26100 -and $caption -match 'LTSC' } { $label = 'Windows 11 LTSC 2024'; $eos = [datetime]'2029-10-09'; break } { $_ -ge 26200 } { $label = 'Windows 11 25H2'; $eos = if ($isEnt) { [datetime]'2028-10-10' } else { [datetime]'2027-10-12' }; break } { $_ -ge 26100 } { $label = 'Windows 11 24H2'; $eos = if ($isEnt) { [datetime]'2027-10-12' } else { [datetime]'2026-10-13' }; break } { $_ -ge 22631 } { $label = 'Windows 11 23H2'; $eos = if ($isEnt) { [datetime]'2026-11-10' } else { [datetime]'2025-11-11' }; break } { $_ -ge 22000 } { $label = 'Windows 11 21H2/22H2'; $eos = [datetime]'2025-10-14'; break } { $_ -ge 19044 -and $_ -lt 22000 -and $caption -match 'LTSC|LTSB' } { $label = 'Windows 10 LTSC 2021'; $eos = [datetime]'2027-01-12'; break } { $_ -ge 17763 -and $_ -lt 19041 -and $caption -match 'LTSC|LTSB' } { $label = 'Windows 10 LTSC 2019'; $eos = [datetime]'2029-01-09'; break } default { $label = 'Windows 10 or older'; $eos = [datetime]'2025-10-14' } } # Windows 10/11 multi-session on AVD and Windows 10 under ESU get security updates # past these dates; the update-recency check (SI-09) shows whether they arrive. } $ubr = Get-RegValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' 'UBR' $observed = "{0} (build {1}.{2}); end of servicing {3:yyyy-MM-dd}." -f $caption, $build, $ubr, $eos if ($today -gt $eos) { $status = 'Fail' $rem = "Upgrade to a supported version. If this device is enrolled in Extended Security Updates, confirm updates still arrive (SI-09)." return New-Result -Id 'CM-01' -Status $status -Observed ("$observed Detected as $label, which is past end of servicing.") -Expected 'A version still receiving security updates' -Remediation $rem } if (($eos - $today).TotalDays -lt 90) { return New-Result -Id 'CM-01' -Status Warn -Observed ("$observed Less than 90 days of servicing left.") -Expected 'A version still receiving security updates' -Remediation 'Plan the feature update now.' } New-Result -Id 'CM-01' -Status Pass -Observed $observed -Expected 'A version still receiving security updates' } $script:Checks['CM-02'] = { $server = $null try { $server = (Get-SmbServerConfiguration -ErrorAction Stop).EnableSMB1Protocol } catch { } $clientStart = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Services\mrxsmb10' 'Start' $clientInstalled = $null -ne $clientStart -and $clientStart -ne 4 if ($null -eq $server) { $server = (Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters' 'SMB1') -ne 0 -and (Test-Path 'HKLM:\SYSTEM\CurrentControlSet\Services\srv') } $observed = "SMBv1 server enabled: {0}; SMBv1 client driver active: {1}" -f $server, $clientInstalled if (-not $server -and -not $clientInstalled) { return New-Result -Id 'CM-02' -Status Pass -Observed $observed -Expected 'Both disabled' } New-Result -Id 'CM-02' -Status Fail -Observed $observed -Expected 'Both disabled' -Remediation 'Remove the "SMB 1.0/CIFS File Sharing Support" Windows feature.' } $script:Checks['CM-03'] = { $v2 = Get-RegValue 'HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine' 'PowerShellVersion' if ($v2 -and $v2 -like '2.*') { return New-Result -Id 'CM-03' -Status Fail -Observed 'The PowerShell 2.0 engine is installed (it bypasses script block logging and AMSI).' -Expected 'Removed' -Remediation 'Remove the "Windows PowerShell 2.0" optional feature (Disable-WindowsOptionalFeature -Online -FeatureName MicrosoftWindowsPowerShellV2Root).' } New-Result -Id 'CM-03' -Status Pass -Observed 'The PowerShell 2.0 engine is not installed.' -Expected 'Removed' } $script:Checks['CM-04'] = { $risky = @( @{ Name = 'RemoteRegistry'; Label = 'Remote Registry' } @{ Name = 'TlntSvr'; Label = 'Telnet server' } @{ Name = 'SNMP'; Label = 'SNMP service' } @{ Name = 'ftpsvc'; Label = 'FTP server' } @{ Name = 'SSDPSRV'; Label = 'SSDP Discovery' } @{ Name = 'upnphost'; Label = 'UPnP Device Host' } @{ Name = 'WMSvc'; Label = 'Web Management Service' } @{ Name = 'SharedAccess'; Label = 'Internet Connection Sharing' } ) $active = @() foreach ($r in $risky) { $svc = Get-CimInstance -ClassName Win32_Service -Filter ("Name='{0}'" -f $r.Name) -ErrorAction SilentlyContinue if ($svc -and ($svc.State -eq 'Running' -or $svc.StartMode -eq 'Auto')) { $active += ("{0} ({1}, {2})" -f $r.Label, $svc.State, $svc.StartMode) } } if ($active.Count -eq 0) { return New-Result -Id 'CM-04' -Status Pass -Observed 'None of the checked nonessential services is running or set to start automatically.' -Expected 'Disabled' } New-Result -Id 'CM-04' -Status Warn -Observed ("Active: " + ($active -join '; ')) -Expected 'Disabled unless documented as needed' -Remediation 'Disable each service that has no documented business need.' } $script:Checks['CM-05'] = { $llmnr = Get-RegValue 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient' 'EnableMulticast' $nbtOn = @() $adapters = Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration -Filter 'IPEnabled=True' -ErrorAction SilentlyContinue foreach ($a in $adapters) { if ($a.TcpipNetbiosOptions -ne 2) { $nbtOn += $a.Description } } $observed = "LLMNR disabled by policy: {0}; adapters with NetBIOS over TCP/IP not disabled: {1}" -f ($llmnr -eq 0), $nbtOn.Count if ($llmnr -eq 0 -and $nbtOn.Count -eq 0) { return New-Result -Id 'CM-05' -Status Pass -Observed $observed -Expected 'Both disabled' } if ($llmnr -eq 0) { return New-Result -Id 'CM-05' -Status Warn -Observed $observed -Expected 'Both disabled' -Remediation 'Disable NetBIOS over TCP/IP on each adapter (or by DHCP option), unless a legacy app needs it.' } New-Result -Id 'CM-05' -Status Fail -Observed $observed -Expected 'Both disabled' -Remediation 'Enable "Turn off multicast name resolution" (DNS Client) and disable NetBIOS over TCP/IP.' } $script:Checks['CM-06'] = { $dg = Get-DeviceGuardState $wdacEnforced = $false # User-mode status: the kernel-mode status is 2 on any machine with the # vulnerable driver blocklist or HVCI, which is not an application allow-list. if ($dg -and $null -ne $dg.UsermodeCodeIntegrityPolicyEnforcementStatus) { $wdacEnforced = ($dg.UsermodeCodeIntegrityPolicyEnforcementStatus -eq 2) } $sac = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\CI\Policy' 'VerifiedAndReputablePolicyState' # Smart App Control: 1 = on $appLocker = $false try { $pol = Get-AppLockerPolicy -Effective -ErrorAction Stop foreach ($coll in $pol.RuleCollections) { if ($coll.Count -gt 0 -and $coll.EnforcementMode -eq 'Enabled' -and $coll.RuleCollectionType -match 'Exe') { $appLocker = $true } } $idSvc = Get-Service -Name 'AppIDSvc' -ErrorAction SilentlyContinue if ($appLocker -and (-not $idSvc -or $idSvc.Status -ne 'Running')) { $appLocker = $false } } catch { } $parts = @() if ($wdacEnforced) { $parts += 'App Control for Business (WDAC) user-mode policy enforced' } if ($sac -eq 1) { $parts += 'Smart App Control on' } if ($appLocker) { $parts += 'AppLocker executable rules enforced' } if ($parts.Count -gt 0) { return New-Result -Id 'CM-06' -Status Pass -Observed ($parts -join '; ') -Expected 'An enforced allow-list' } New-Result -Id 'CM-06' -Status Fail -Observed 'No enforced application control policy found.' -Expected 'An enforced allow-list (deny-by-exception)' -Remediation 'Deploy App Control for Business or AppLocker in audit mode, review the events, then enforce.' } $script:Checks['CM-07'] = { $m = Get-RegValue 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Installer' 'AlwaysInstallElevated' $u = Get-RegValue 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\Installer' 'AlwaysInstallElevated' if ($m -eq 1 -and $u -eq 1) { return New-Result -Id 'CM-07' -Status Fail -Observed 'AlwaysInstallElevated is on for the machine and this user: any user can install as SYSTEM.' -Expected 'Off' -Remediation 'Set "Always install with elevated privileges" = Disabled in both Computer and User Configuration.' } if ($m -eq 1) { return New-Result -Id 'CM-07' -Status Warn -Observed 'AlwaysInstallElevated is on for the machine (it takes effect for any user who also has it set).' -Expected 'Off' -Remediation 'Set "Always install with elevated privileges" = Disabled.' } New-Result -Id 'CM-07' -Status Pass -Observed 'AlwaysInstallElevated is off.' -Expected 'Off' } $script:Checks['CM-08'] = { $p = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer' $types = Get-RegValue $p 'NoDriveTypeAutoRun' $noAuto = Get-RegValue $p 'NoAutorun' if ($types -eq 255 -and $noAuto -eq 1) { return New-Result -Id 'CM-08' -Status Pass -Observed 'AutoPlay off for all drives and AutoRun commands blocked.' -Expected 'NoDriveTypeAutoRun=255, NoAutorun=1' } New-Result -Id 'CM-08' -Status Fail -Observed ("NoDriveTypeAutoRun={0}; NoAutorun={1}" -f $types, $noAuto) -Expected 'NoDriveTypeAutoRun=255, NoAutorun=1' -Remediation 'Enable "Turn off Autoplay" (All drives) and set "Set the default behavior for AutoRun" to "Do not execute any autorun commands".' } $script:Checks['CM-09'] = { $v = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\SecureBoot\State' 'UEFISecureBootEnabled' if ($v -eq 1) { return New-Result -Id 'CM-09' -Status Pass -Observed 'Secure Boot is on.' -Expected 'On' } if ($null -eq $v) { return New-Result -Id 'CM-09' -Status Fail -Observed 'Secure Boot state is not reported (legacy BIOS boot or Generation 1 VM).' -Expected 'On' -Remediation 'Boot in UEFI mode with Secure Boot (on Azure, use Trusted Launch VMs).' } New-Result -Id 'CM-09' -Status Fail -Observed 'Secure Boot is off.' -Expected 'On' -Remediation 'Turn on Secure Boot in firmware (on Azure, enable Trusted Launch).' } $script:Checks['CM-10'] = { $paths = @( 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' ) $apps = @(Get-ItemProperty -Path $paths -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -and -not $_.SystemComponent } | Sort-Object DisplayName -Unique) $script:Inventory = @($apps | ForEach-Object { [pscustomobject]@{ Name = $_.DisplayName; Version = $_.DisplayVersion; Publisher = $_.Publisher } }) New-Result -Id 'CM-10' -Status Info -Observed ("{0} installed applications (full list in the JSON report)." -f $script:Inventory.Count) -Expected 'Compare against your approved software baseline' -Remediation 'Review the list against your authorized software list; remove anything not approved.' } # Media Protection ------------------------------------------------------------ $script:Checks['MP-01'] = { $p = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\RemovableStorageDevices' $denyAll = Get-RegValue $p 'Deny_All' $denyWrite = Get-RegValue 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\RemovableStorageDevices\{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}' 'Deny_Write' $usbStor = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Services\USBSTOR' 'Start' Get-DefenderState # Device control counts only when it is on AND denies by default; on with # default Allow and no policies restricts nothing. $deviceControl = $false if ($script:MpStatus -and $script:MpStatus.PSObject.Properties['DeviceControlState'] -and $script:MpStatus.PSObject.Properties['DeviceControlDefaultEnforcement']) { $deviceControl = ([string]$script:MpStatus.DeviceControlState -eq 'Enabled') -and ([string]$script:MpStatus.DeviceControlDefaultEnforcement -eq 'Deny') } $parts = @() if ($denyAll -eq 1) { $parts += 'all removable storage denied' } if ($denyWrite -eq 1) { $parts += 'write to removable disks denied' } if ($usbStor -eq 4) { $parts += 'USB mass storage driver disabled' } if ($deviceControl) { $parts += 'Defender device control on, deny by default' } if ($parts.Count -gt 0) { return New-Result -Id 'MP-01' -Status Pass -Observed ($parts -join '; ') -Expected 'Removable storage blocked or limited to approved devices' } New-Result -Id 'MP-01' -Status Fail -Observed 'No removable storage restriction found.' -Expected 'Removable storage blocked or limited to approved devices' -Remediation 'Enable "All Removable Storage classes: Deny all access" (or deny write) or Defender device control with an approved-device list.' } # System and Communications Protection ---------------------------------------- $script:Checks['SC-01'] = { $profiles = @(Get-NetFirewallProfile -PolicyStore ActiveStore -ErrorAction Stop) $off = @($profiles | Where-Object { $_.Enabled -ne $true } | ForEach-Object { $_.Name }) if ($off.Count -eq 0) { return New-Result -Id 'SC-01' -Status Pass -Observed 'Domain, Private and Public profiles are on.' -Expected 'All on' } New-Result -Id 'SC-01' -Status Fail -Observed ("Off: " + ($off -join ', ')) -Expected 'All on' -Remediation 'Turn Windows Defender Firewall on for every profile (Group Policy or Intune).' } $script:Checks['SC-02'] = { $profiles = @(Get-NetFirewallProfile -PolicyStore ActiveStore -ErrorAction Stop) $allow = @($profiles | Where-Object { $_.DefaultInboundAction -eq 'Allow' } | ForEach-Object { $_.Name }) if ($allow.Count -eq 0) { return New-Result -Id 'SC-02' -Status Pass -Observed 'Inbound connections are blocked by default on every profile.' -Expected 'Block' } New-Result -Id 'SC-02' -Status Fail -Observed ("Inbound allowed by default: " + ($allow -join ', ')) -Expected 'Block (deny by default, allow by exception)' -Remediation 'Set "Inbound connections" to Block for every firewall profile.' } $script:Checks['SC-03'] = { $drive = $env:SystemDrive if ($script:IsAdmin) { try { $vol = Get-BitLockerVolume -MountPoint $drive -ErrorAction Stop if ($vol.ProtectionStatus -eq 'On' -and $vol.VolumeStatus -eq 'FullyEncrypted') { return New-Result -Id 'SC-03' -Status Pass -Observed ("{0} is fully encrypted and protection is on." -f $drive) -Expected 'Encrypted, protection on' } if ($vol.VolumeStatus -eq 'EncryptionInProgress') { return New-Result -Id 'SC-03' -Status Warn -Observed ("{0} is encrypting ({1}%)." -f $drive, $vol.EncryptionPercentage) -Expected 'Encrypted, protection on' } return New-Result -Id 'SC-03' -Status Fail -Observed ("{0}: {1}, protection {2}." -f $drive, $vol.VolumeStatus, $vol.ProtectionStatus) -Expected 'Encrypted, protection on' -Remediation 'Turn on BitLocker for the system drive with a TPM protector and escrow the recovery key to Entra ID or AD.' } catch { } } # Unelevated: Explorer's BitLocker property (1 on, 2 off, 3 encrypting, 5 suspended...). $shell = New-Object -ComObject Shell.Application $state = $shell.NameSpace($drive + '\').Self.ExtendedProperty('System.Volume.BitLockerProtection') switch ($state) { 1 { return New-Result -Id 'SC-03' -Status Pass -Observed ("{0} is protected by BitLocker." -f $drive) -Expected 'Encrypted, protection on' } 3 { return New-Result -Id 'SC-03' -Status Warn -Observed ("{0} is encrypting." -f $drive) -Expected 'Encrypted, protection on' } 5 { return New-Result -Id 'SC-03' -Status Fail -Observed ("{0} is encrypted but protection is suspended." -f $drive) -Expected 'Protection on' -Remediation 'Resume BitLocker protection (Resume-BitLocker).' } 2 { return New-Result -Id 'SC-03' -Status Fail -Observed ("{0} is not encrypted." -f $drive) -Expected 'Encrypted, protection on' -Remediation 'Turn on BitLocker for the system drive with a TPM protector and escrow the recovery key.' } default { return New-Result -Id 'SC-03' -Status Unknown -Observed ("BitLocker state not reported ({0}). Run elevated for a definite answer." -f $state) -Expected 'Encrypted, protection on' } } } $script:Checks['SC-04'] = { if (-not $script:IsAdmin) { return New-NeedsAdmin 'SC-04' 'XtsAes128 or XtsAes256' } $vol = Get-BitLockerVolume -MountPoint $env:SystemDrive -ErrorAction Stop if ($vol.VolumeStatus -eq 'FullyDecrypted') { return New-Result -Id 'SC-04' -Status NotApplicable -Observed 'The system drive is not encrypted (see SC-03).' } if ([string]$vol.EncryptionMethod -match '^XtsAes') { return New-Result -Id 'SC-04' -Status Pass -Observed ("Encryption method: {0}." -f $vol.EncryptionMethod) -Expected 'XTS-AES' } New-Result -Id 'SC-04' -Status Warn -Observed ("Encryption method: {0}." -f $vol.EncryptionMethod) -Expected 'XTS-AES 128 or 256' -Remediation 'Set "Choose drive encryption method and cipher strength" to XTS-AES 256 for new encryption; re-encrypt to change an existing drive.' } $script:Checks['SC-05'] = { $v = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy' 'Enabled' if ($v -eq 1) { return New-Result -Id 'SC-05' -Status Pass -Observed 'FIPS mode is on.' -Expected 'On' } New-Result -Id 'SC-05' -Status Warn -Observed 'FIPS mode is off.' -Expected 'On where CUI is processed' -Remediation 'Enable "System cryptography: Use FIPS compliant algorithms for encryption, hashing, and signing" after testing your applications. Windows'' validated modules satisfy 3.13.11 even without this switch only if nothing else negotiates non-FIPS algorithms.' } $script:Checks['SC-06'] = { $base = 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols' $issues = @() foreach ($proto in @('SSL 3.0', 'TLS 1.0', 'TLS 1.1')) { foreach ($side in @('Server', 'Client')) { $enabled = Get-RegValue "$base\$proto\$side" 'Enabled' $disabledByDefault = Get-RegValue "$base\$proto\$side" 'DisabledByDefault' # Off only when Enabled=0, or Enabled is absent and DisabledByDefault=1. # Any other non-zero Enabled (1, 0xFFFFFFFF) is on. $off = ($null -ne $enabled -and [int64]$enabled -eq 0) -or ($null -eq $enabled -and $disabledByDefault -eq 1) if (-not $off -and $null -eq $enabled -and $null -eq $disabledByDefault) { # SSL 3.0 has been off by default in SChannel since 2015. TLS 1.0/1.1 left # at the OS default are not enforced off, so they are reported. if ($proto -eq 'SSL 3.0') { $off = $true } else { $issues += "$proto $side (OS default, not disabled by policy)"; continue } } if (-not $off) { $issues += "$proto $side" } } } if ($issues.Count -eq 0) { return New-Result -Id 'SC-06' -Status Pass -Observed 'SSL 3.0, TLS 1.0 and TLS 1.1 are off.' -Expected 'Off' } New-Result -Id 'SC-06' -Status Fail -Observed ("Still enabled: " + ($issues -join ', ')) -Expected 'Off (TLS 1.2 and 1.3 only)' -Remediation 'Set Enabled=0 and DisabledByDefault=1 under SCHANNEL\Protocols for each listed protocol, then restart.' } $script:Checks['SC-07'] = { $srv = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters' 'RequireSecuritySignature' $cli = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters' 'RequireSecuritySignature' $observed = "Server requires signing: {0}; client requires signing: {1}" -f ($srv -eq 1), ($cli -eq 1) if ($srv -eq 1 -and $cli -eq 1) { return New-Result -Id 'SC-07' -Status Pass -Observed $observed -Expected 'Both required' } New-Result -Id 'SC-07' -Status Fail -Observed $observed -Expected 'Both required' -Remediation 'Enable "Microsoft network server: Digitally sign communications (always)" and the matching client setting.' } $script:Checks['SC-08'] = { $deny = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' 'fDenyTSConnections' if ($deny -eq 1 -and -not $script:IsAvdHost) { return New-Result -Id 'SC-08' -Status NotApplicable -Observed 'Remote Desktop is turned off.' } $pol = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' $rdp = 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' $layer = Get-RegValue $pol 'SecurityLayer'; if ($null -eq $layer) { $layer = Get-RegValue $rdp 'SecurityLayer' } $enc = Get-RegValue $pol 'MinEncryptionLevel'; if ($null -eq $enc) { $enc = Get-RegValue $rdp 'MinEncryptionLevel' } $observed = "SecurityLayer={0} (2 = TLS); MinEncryptionLevel={1} (3 = High)" -f $layer, $enc if ($layer -eq 2 -and $enc -ge 3) { return New-Result -Id 'SC-08' -Status Pass -Observed $observed -Expected 'SecurityLayer=2, MinEncryptionLevel>=3' } New-Result -Id 'SC-08' -Status Warn -Observed $observed -Expected 'SecurityLayer=2, MinEncryptionLevel>=3' -Remediation 'Set "Require use of specific security layer for remote (RDP) connections" = SSL and "Set client connection encryption level" = High Level.' } $script:Checks['SC-09'] = { $officeRoot = 'HKCU:\Software\Policies\Microsoft\Office\16.0' $installed = (Test-Path 'HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration') -or (Test-Path 'HKLM:\SOFTWARE\Microsoft\Office\16.0') if (-not $installed) { return New-Result -Id 'SC-09' -Status NotApplicable -Observed 'Microsoft 365 Apps / Office 2016+ is not installed.' } $apps = @('Word', 'Excel', 'PowerPoint') $missing = @() foreach ($a in $apps) { $v = Get-RegValue "$officeRoot\$a\Security" 'blockcontentexecutionfrominternet' if ($v -ne 1) { $missing += $a } } if ($missing.Count -eq 0) { return New-Result -Id 'SC-09' -Status Pass -Observed ("Word, Excel and PowerPoint block macros in internet files by policy (user policy read for {0})." -f $env:USERNAME) -Expected 'Blocked by policy' } New-Result -Id 'SC-09' -Status Warn -Observed ("No blocking policy for: " + ($missing -join ', ') + ' (Office''s built-in default blocks them, but a user setting can override it).') -Expected 'Blocked by policy' -Remediation 'Enable "Block macros from running in Office files from the Internet" for each app (Group Policy, Intune or Cloud Policy).' } $script:Checks['SC-10'] = { if (-not $script:IsAdmin) { return New-NeedsAdmin 'SC-10' 'TPM 2.0 present and ready' } $tpm = Get-Tpm -ErrorAction Stop if (-not $tpm.TpmPresent) { return New-Result -Id 'SC-10' -Status Fail -Observed 'No TPM found.' -Expected 'TPM 2.0 present and ready' -Remediation 'Enable the TPM in firmware (on Azure, use Trusted Launch with vTPM).' } if (-not $tpm.TpmReady) { return New-Result -Id 'SC-10' -Status Warn -Observed 'TPM is present but not ready.' -Expected 'Ready' -Remediation 'Initialize the TPM (Initialize-Tpm) or clear and re-provision it.' } $ver = '' try { $ver = (Get-CimInstance -Namespace 'root\cimv2\Security\MicrosoftTpm' -ClassName Win32_Tpm -ErrorAction Stop).SpecVersion.Split(',')[0] } catch { } if (-not $ver) { return New-Result -Id 'SC-10' -Status Unknown -Observed 'TPM present and ready, but its version could not be read.' -Expected 'TPM 2.0 present and ready' } if ($ver -notlike '2.*') { return New-Result -Id 'SC-10' -Status Warn -Observed ("TPM {0} present and ready." -f $ver) -Expected 'TPM 2.0' -Remediation 'Replace or reconfigure for TPM 2.0 (required by Windows 11 and modern BitLocker and Credential Guard protections).' } New-Result -Id 'SC-10' -Status Pass -Observed ("TPM {0} present and ready." -f $ver) -Expected 'TPM 2.0 present and ready' } $script:Checks['SC-11'] = { $dg = Get-DeviceGuardState if (-not $dg) { return New-Result -Id 'SC-11' -Status Unknown -Observed 'Device Guard status is not available on this system.' -Expected 'HVCI running' } if (@($dg.SecurityServicesRunning) -contains 2) { return New-Result -Id 'SC-11' -Status Pass -Observed 'Memory integrity (hypervisor-protected code integrity) is running.' -Expected 'Running' } New-Result -Id 'SC-11' -Status Fail -Observed 'Memory integrity is not running.' -Expected 'Running' -Remediation 'Turn on Memory integrity (Core isolation) or "Virtualization Based Protection of Code Integrity" by policy.' } $script:Checks['SC-12'] = { $v4 = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters' 'DisableIPSourceRouting' $v6 = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters' 'DisableIPSourceRouting' $observed = "IPv4 DisableIPSourceRouting={0}; IPv6 DisableIPSourceRouting={1}" -f $v4, $v6 if ($v4 -eq 2 -and $v6 -eq 2) { return New-Result -Id 'SC-12' -Status Pass -Observed $observed -Expected '2 for both' } New-Result -Id 'SC-12' -Status Warn -Observed $observed -Expected '2 for both (highest protection)' -Remediation 'Set "MSS: (DisableIPSourceRouting)" and its IPv6 counterpart to "Highest protection, source routing is completely disabled".' } # System and Information Integrity -------------------------------------------- function Get-ThirdPartyAv { if ($script:IsServer) { return @() } try { return @(Get-CimInstance -Namespace 'root\SecurityCenter2' -ClassName AntiVirusProduct -ErrorAction Stop | Where-Object { $_.displayName -notmatch 'Windows Defender|Microsoft Defender' }) } catch { return @() } } $script:Checks['SI-01'] = { Get-DefenderState if ($script:MpStatus -and $script:MpStatus.RealTimeProtectionEnabled -and (Test-DefenderActive)) { return New-Result -Id 'SI-01' -Status Pass -Observed 'Microsoft Defender Antivirus real-time protection is on.' -Expected 'On' } $other = Get-ThirdPartyAv # productState bit 0x1000 = on. $onOther = @($other | Where-Object { ($_.productState -band 0x1000) -ne 0 }) if ($onOther.Count -gt 0) { return New-Result -Id 'SI-01' -Status Pass -Observed ("Real-time protection by: " + (($onOther | ForEach-Object { $_.displayName }) -join ', ')) -Expected 'On' } if (-not $script:MpStatus -and $other.Count -eq 0) { return New-Result -Id 'SI-01' -Status Unknown -Observed 'Could not read antivirus status (Defender cmdlets unavailable and no product registered with Security Center).' -Expected 'On' } New-Result -Id 'SI-01' -Status Fail -Observed 'No antivirus with real-time protection on was found.' -Expected 'On' -Remediation 'Turn on Microsoft Defender Antivirus real-time protection or confirm your third-party antivirus is running.' } $script:Checks['SI-02'] = { Get-DefenderState if (-not $script:MpStatus -or -not (Test-DefenderActive)) { if ((Get-ThirdPartyAv).Count -gt 0) { return New-Result -Id 'SI-02' -Status Unknown -Observed 'A third-party antivirus is in use; check its signature age in its own console.' -Expected 'Less than 3 days old' } return New-Result -Id 'SI-02' -Status Unknown -Observed 'Microsoft Defender Antivirus is not active.' -Expected 'Less than 3 days old' } $age = $script:MpStatus.AntivirusSignatureAge $observed = "Signatures {0} (version {1}), {2} day(s) old." -f $script:MpStatus.AntivirusSignatureLastUpdated, $script:MpStatus.AntivirusSignatureVersion, $age if ($age -lt 3) { return New-Result -Id 'SI-02' -Status Pass -Observed $observed -Expected 'Less than 3 days old' } if ($age -le 7) { return New-Result -Id 'SI-02' -Status Warn -Observed $observed -Expected 'Less than 3 days old' -Remediation 'Check that Defender can reach its update source; run Update-MpSignature.' } New-Result -Id 'SI-02' -Status Fail -Observed $observed -Expected 'Less than 3 days old' -Remediation 'Signatures are over a week old: check the update source and run Update-MpSignature.' } $script:Checks['SI-03'] = { Get-DefenderState if (-not $script:MpStatus -or -not (Test-DefenderActive)) { return New-Result -Id 'SI-03' -Status Unknown -Observed 'Microsoft Defender Antivirus is not active; check scan history in your antivirus console.' -Expected 'A scan in the last 7 days' } $q = $script:MpStatus.QuickScanAge $f = $script:MpStatus.FullScanAge $newest = @($q, $f) | Where-Object { $null -ne $_ -and $_ -ne 4294967295 } | Sort-Object | Select-Object -First 1 if ($null -ne $newest -and $newest -le 7) { return New-Result -Id 'SI-03' -Status Pass -Observed ("Last scan {0} day(s) ago." -f $newest) -Expected '7 days or less' } New-Result -Id 'SI-03' -Status Fail -Observed ("Quick scan age: {0}; full scan age: {1} days." -f $q, $f) -Expected '7 days or less' -Remediation 'Schedule a daily quick scan and weekly full scan (Defender scan schedule policy).' } $script:Checks['SI-04'] = { Get-DefenderState if (-not $script:MpStatus -or -not (Test-DefenderActive)) { return New-Result -Id 'SI-04' -Status NotApplicable -Observed 'Microsoft Defender Antivirus is not the active antivirus.' } if ($script:MpStatus.PSObject.Properties['IsTamperProtected'] -and $script:MpStatus.IsTamperProtected) { return New-Result -Id 'SI-04' -Status Pass -Observed 'Tamper protection is on.' -Expected 'On' } New-Result -Id 'SI-04' -Status Fail -Observed 'Tamper protection is off.' -Expected 'On' -Remediation 'Turn on tamper protection from Microsoft Defender XDR or Intune.' } $script:Checks['SI-05'] = { Get-DefenderState if (-not $script:MpPref -or -not $script:MpStatus -or -not (Test-DefenderActive)) { return New-Result -Id 'SI-05' -Status NotApplicable -Observed 'Microsoft Defender Antivirus is not the active antivirus.' } $maps = $script:MpPref.MAPSReporting $pua = $script:MpPref.PUAProtection $observed = "Cloud protection (MAPS): {0}; PUA protection: {1}" -f $maps, $pua if ($maps -ge 1 -and $pua -eq 1) { return New-Result -Id 'SI-05' -Status Pass -Observed $observed -Expected 'MAPS on, PUA block' } New-Result -Id 'SI-05' -Status Warn -Observed $observed -Expected 'MAPSReporting 1 or 2, PUAProtection 1 (block)' -Remediation 'Enable cloud-delivered protection and set PUA protection to Block (Set-MpPreference -MAPSReporting Advanced -PUAProtection Enabled, or by policy).' } $script:Checks['SI-06'] = { Get-DefenderState if (-not $script:MpPref -or -not $script:MpStatus -or -not (Test-DefenderActive)) { return New-Result -Id 'SI-06' -Status NotApplicable -Observed 'Microsoft Defender Antivirus is not the active antivirus.' } $ids = @($script:MpPref.AttackSurfaceReductionRules_Ids) $actions = @($script:MpPref.AttackSurfaceReductionRules_Actions) if ($ids.Count -eq 0 -or ($ids.Count -eq 1 -and -not $ids[0])) { if (-not $script:IsAdmin) { return New-NeedsAdmin 'SI-06' 'ASR rules in Block or Warn' } return New-Result -Id 'SI-06' -Status Fail -Observed 'No attack surface reduction rules are configured.' -Expected 'Standard protection rules in Block mode' -Remediation 'Deploy the ASR "standard protection" rules in Audit, review, then Block (Intune endpoint security or Group Policy).' } $block = 0; $audit = 0 for ($i = 0; $i -lt $ids.Count; $i++) { if ($actions[$i] -eq 1 -or $actions[$i] -eq 6) { $block++ } elseif ($actions[$i] -eq 2) { $audit++ } } $observed = "{0} rule(s) configured: {1} block/warn, {2} audit." -f $ids.Count, $block, $audit if ($block -ge 3) { return New-Result -Id 'SI-06' -Status Pass -Observed $observed -Expected 'Rules in Block or Warn' } New-Result -Id 'SI-06' -Status Warn -Observed $observed -Expected 'Rules in Block or Warn' -Remediation 'Move audited ASR rules to Block once the audit events are reviewed.' } $script:Checks['SI-07'] = { Get-DefenderState if (-not $script:MpPref -or -not $script:MpStatus -or -not (Test-DefenderActive)) { return New-Result -Id 'SI-07' -Status NotApplicable -Observed 'Microsoft Defender Antivirus is not the active antivirus.' } $np = $script:MpPref.EnableNetworkProtection if ($np -eq 1) { return New-Result -Id 'SI-07' -Status Pass -Observed 'Network protection is in block mode.' -Expected 'Block' } if ($np -eq 2) { return New-Result -Id 'SI-07' -Status Warn -Observed 'Network protection is in audit mode.' -Expected 'Block' -Remediation 'Move network protection to block mode.' } New-Result -Id 'SI-07' -Status Fail -Observed 'Network protection is off.' -Expected 'Block' -Remediation 'Enable network protection (Set-MpPreference -EnableNetworkProtection Enabled, or by policy).' } $script:Checks['SI-08'] = { $known = @( @{ Name = 'Sense'; Label = 'Microsoft Defender for Endpoint' } @{ Name = 'CSFalconService'; Label = 'CrowdStrike Falcon' } @{ Name = 'SentinelAgent'; Label = 'SentinelOne' } @{ Name = 'CylanceSvc'; Label = 'Cylance' } @{ Name = 'CbDefense'; Label = 'Carbon Black' } @{ Name = 'cyserver'; Label = 'Cortex XDR' } @{ Name = 'HuntressAgent'; Label = 'Huntress' } @{ Name = 'TmCCSF'; Label = 'Trend Micro' } @{ Name = 'SophosHealth'; Label = 'Sophos' } @{ Name = 'elastic-agent'; Label = 'Elastic Defend' } ) $running = @() foreach ($k in $known) { $svc = Get-Service -Name $k.Name -ErrorAction SilentlyContinue if ($svc -and $svc.Status -eq 'Running') { $running += $k.Label } } if ($running -contains 'Microsoft Defender for Endpoint') { $onboard = Get-RegValue 'HKLM:\SOFTWARE\Microsoft\Windows Advanced Threat Protection\Status' 'OnboardingState' if ($onboard -ne 1) { return New-Result -Id 'SI-08' -Status Warn -Observed 'The Defender for Endpoint service is running but the device is not onboarded.' -Expected 'An EDR sensor running and reporting' -Remediation 'Onboard the device to Microsoft Defender for Endpoint.' } } if ($running.Count -gt 0) { return New-Result -Id 'SI-08' -Status Pass -Observed ("Running: " + ($running -join ', ')) -Expected 'An EDR sensor running' } New-Result -Id 'SI-08' -Status Warn -Observed 'No known EDR sensor service is running (your product may not be in this script''s list).' -Expected 'An EDR sensor running' -Remediation 'Deploy an endpoint detection and response sensor that alerts on suspicious activity.' } $script:Checks['SI-09'] = { $last = $null try { $session = New-Object -ComObject 'Microsoft.Update.Session' $searcher = $session.CreateUpdateSearcher() $count = $searcher.GetTotalHistoryCount() if ($count -gt 0) { # ResultCode 2 = succeeded, 3 = succeeded with errors; Operation 1 = install. $last = $searcher.QueryHistory(0, [math]::Min($count, 200)) | Where-Object { $_.Operation -eq 1 -and ($_.ResultCode -eq 2 -or $_.ResultCode -eq 3) -and $_.Title -match 'Cumulative Update|Security Update|Security Monthly Quality Rollup' -and $_.Title -notmatch 'KB2267602|Security Intelligence|Definition Update|Antimalware platform' } | Sort-Object Date -Descending | Select-Object -First 1 } } catch { } $date = $null $what = $null if ($last) { $date = $last.Date.ToLocalTime(); $what = $last.Title } else { $hf = Get-HotFix -ErrorAction SilentlyContinue | Where-Object { $_.InstalledOn } | Sort-Object InstalledOn -Descending | Select-Object -First 1 if ($hf) { $date = $hf.InstalledOn; $what = $hf.HotFixID } } if (-not $date) { return New-Result -Id 'SI-09' -Status Unknown -Observed 'No update installation history was found.' -Expected 'Within 35 days' } $days = [int]((Get-Date) - $date).TotalDays $observed = "Last update installed {0:yyyy-MM-dd} ({1} days ago): {2}" -f $date, $days, $what if ($days -le 35) { return New-Result -Id 'SI-09' -Status Pass -Observed $observed -Expected 'Within 35 days' } if ($days -le 60) { return New-Result -Id 'SI-09' -Status Warn -Observed $observed -Expected 'Within 35 days' -Remediation 'Install the latest cumulative update.' } New-Result -Id 'SI-09' -Status Fail -Observed $observed -Expected 'Within 35 days' -Remediation 'This device has missed at least one Patch Tuesday: install the latest cumulative update and check its update policy.' } $script:Checks['SI-10'] = { $reasons = @() if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending') { $reasons += 'component servicing' } if (Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired') { $reasons += 'Windows Update' } $pfro = Get-RegValue 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager' 'PendingFileRenameOperations' if ($pfro) { $reasons += 'pending file renames' } $boot = $null if ($script:OsInfo) { $boot = $script:OsInfo.LastBootUpTime } $uptime = '' if ($boot) { $uptime = (" Up {0} days." -f [int]((Get-Date) - $boot).TotalDays) } if ($reasons.Count -eq 0) { return New-Result -Id 'SI-10' -Status Pass -Observed ("No reboot pending.$uptime") -Expected 'None pending' } if ($reasons -contains 'component servicing' -or $reasons -contains 'Windows Update') { return New-Result -Id 'SI-10' -Status Warn -Observed ("Reboot pending: " + ($reasons -join ', ') + ".$uptime") -Expected 'None pending' -Remediation 'Restart to finish installing updates.' } New-Result -Id 'SI-10' -Status Info -Observed ("Pending file renames only (often harmless).$uptime") -Expected 'None pending' } $script:Checks['SI-11'] = { $v = Get-RegValue 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\System' 'EnableSmartScreen' $edge = Get-RegValue 'HKLM:\SOFTWARE\Policies\Microsoft\Edge' 'SmartScreenEnabled' $explorer = Get-RegValue 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer' 'SmartScreenEnabled' $observed = "Windows SmartScreen policy: {0}; Edge SmartScreen policy: {1}; Explorer setting: {2}" -f $v, $edge, $explorer if ($v -eq 0 -or $edge -eq 0 -or $explorer -eq 'Off') { return New-Result -Id 'SI-11' -Status Fail -Observed $observed -Expected 'On' -Remediation 'Enable "Configure Windows Defender SmartScreen" and the Microsoft Edge SmartScreen policy.' } if ($v -eq 1 -and $edge -ne 0) { return New-Result -Id 'SI-11' -Status Pass -Observed $observed -Expected 'On by policy' } New-Result -Id 'SI-11' -Status Warn -Observed ($observed + ' (on by default, not enforced by policy).') -Expected 'On by policy' -Remediation 'Enforce SmartScreen by policy so users cannot turn it off.' } # Azure Virtual Desktop session hosts ----------------------------------------- $script:Checks['AVD-01'] = { if (-not $script:IsAvdHost) { return New-Result -Id 'AVD-01' -Status NotApplicable -Observed 'Not an Azure Virtual Desktop session host.' } $v = Get-RegValue 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' 'fEnableScreenCaptureProtect' if ($v -ge 1) { return New-Result -Id 'AVD-01' -Status Pass -Observed ("Screen capture protection is on (mode {0})." -f $v) -Expected 'On' } New-Result -Id 'AVD-01' -Status Fail -Observed 'Screen capture protection is off.' -Expected 'On' -Remediation 'Enable "Enable screen capture protection" (Azure Virtual Desktop administrative template).' } $script:Checks['AVD-02'] = { if (-not $script:IsAvdHost) { return New-Result -Id 'AVD-02' -Status NotApplicable -Observed 'Not an Azure Virtual Desktop session host.' } $v = Get-RegValue 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' 'fEnableWatermarking' if ($v -eq 1) { return New-Result -Id 'AVD-02' -Status Pass -Observed 'Watermarking is on.' -Expected 'On' } New-Result -Id 'AVD-02' -Status Warn -Observed 'Watermarking is off.' -Expected 'On where CUI is displayed' -Remediation 'Enable "Enable watermarking" (Azure Virtual Desktop administrative template).' } $script:Checks['AVD-03'] = { if (-not $script:IsAvdHost) { return New-Result -Id 'AVD-03' -Status NotApplicable -Observed 'Not an Azure Virtual Desktop session host.' } $p = 'HKLM:\SOFTWARE\FSLogix\Profiles' $enabled = Get-RegValue $p 'Enabled' $vhd = Get-RegValue $p 'VHDLocations' $ccd = Get-RegValue $p 'CCDLocations' if ($enabled -eq 1 -and ($vhd -or $ccd)) { return New-Result -Id 'AVD-03' -Status Pass -Observed 'FSLogix profile containers are enabled with a storage location.' -Expected 'Enabled' } New-Result -Id 'AVD-03' -Status Warn -Observed 'FSLogix profile containers are not enabled (user data may persist on the host).' -Expected 'Enabled' -Remediation 'Enable FSLogix profile containers on access-controlled, encrypted storage so CUI does not persist on pooled hosts.' } # -- Run ---------------------------------------------------------------------- $started = Get-Date $results = New-Object System.Collections.Generic.List[object] $i = 0 foreach ($c in $script:Catalogue) { $i++ Write-Progress -Activity 'Atlas AVD endpoint assessment' -Status ("{0} {1}" -f $c.Id, $c.Title) -PercentComplete ([int](100 * $i / $script:Catalogue.Count)) $r = $null try { $r = & $script:Checks[$c.Id] } catch { $r = New-Result -Id $c.Id -Status Unknown -Observed ("Check could not run: {0}" -f $_.Exception.Message) } if ($null -eq $r) { $r = New-Result -Id $c.Id -Status Unknown -Observed 'Check returned no result.' } $r = @($r)[-1] $results.Add([pscustomobject]@{ Id = $c.Id Family = $c.Family Practice = $c.Practice Title = $c.Title Status = $r.Status Observed = $r.Observed Expected = $r.Expected Remediation = $r.Remediation NeedsAdmin = $c.Admin }) } Write-Progress -Activity 'Atlas AVD endpoint assessment' -Completed $counts = [ordered]@{} foreach ($s in @('Pass', 'Fail', 'Warn', 'Unknown', 'Info', 'NotApplicable')) { $counts[$s] = @($results | Where-Object Status -eq $s).Count } $scored = $counts['Pass'] + $counts['Fail'] + $counts['Warn'] $score = 0 if ($scored -gt 0) { $score = [math]::Round(100 * ($counts['Pass'] + 0.5 * $counts['Warn']) / $scored) } # -- Console summary ---------------------------------------------------------- $colors = @{ Pass = 'Green'; Fail = 'Red'; Warn = 'Yellow'; Unknown = 'DarkGray'; Info = 'Cyan'; NotApplicable = 'DarkGray' } Write-Host '' Write-Host ('Atlas AVD Endpoint Controls Assessment v{0}' -f $script:AssessmentVersion) -ForegroundColor White Write-Host ('{0} | {1} | elevated: {2}' -f $env:COMPUTERNAME, $(if ($script:OsInfo) { $script:OsInfo.Caption } else { 'Windows' }), $script:IsAdmin) -ForegroundColor Gray Write-Host '' $currentFamily = '' foreach ($r in $results) { if ($r.Family -ne $currentFamily) { $currentFamily = $r.Family Write-Host '' Write-Host $currentFamily -ForegroundColor White } $tag = $r.Status if ($tag -eq 'NotApplicable') { $tag = 'N/A' } Write-Host (' [{0,-7}] ' -f $tag) -ForegroundColor $colors[$r.Status] -NoNewline Write-Host ('{0,-6} {1}' -f $r.Id, $r.Title) if ($r.Status -in @('Fail', 'Warn')) { Write-Host (' {0}' -f $r.Observed) -ForegroundColor DarkGray } } Write-Host '' Write-Host ('Score: {0}% Pass {1} Fail {2} Warn {3} Unknown {4} Info {5} N/A {6}' -f $score, $counts['Pass'], $counts['Fail'], $counts['Warn'], $counts['Unknown'], $counts['Info'], $counts['NotApplicable']) -ForegroundColor White if (-not $script:IsAdmin) { Write-Host 'Run from an elevated prompt to answer the checks reported as Unknown.' -ForegroundColor Yellow } # -- Reports ------------------------------------------------------------------ if (-not $NoReport) { if (-not (Test-Path $OutputDirectory)) { New-Item -ItemType Directory -Path $OutputDirectory -Force | Out-Null } $stamp = $started.ToString('yyyyMMdd-HHmmss') $base = Join-Path $OutputDirectory ("AtlasEndpointAssessment-{0}-{1}" -f $env:COMPUTERNAME, $stamp) $meta = [ordered]@{ tool = 'Atlas AVD Endpoint Controls Assessment' version = $script:AssessmentVersion computer = $env:COMPUTERNAME os = $(if ($script:OsInfo) { $script:OsInfo.Caption } else { $null }) osBuild = $(if ($script:OsInfo) { $script:OsInfo.Version } else { $null }) elevated = $script:IsAdmin avdSessionHost = $script:IsAvdHost startedAt = $started.ToString('o') score = $score counts = $counts practices = $(if ($script:Filtered) { @($script:Catalogue | ForEach-Object { $_.Practice } | Select-Object -Unique) } else { $null }) } # JSON: everything, including the software inventory. [ordered]@{ assessment = $meta; results = $results; softwareInventory = $script:Inventory } | ConvertTo-Json -Depth 5 | Set-Content -Path "$base.json" -Encoding UTF8 # CSV: one row per control, ready for a POA&M or spreadsheet. $results | Select-Object Id, Family, Practice, Title, Status, Observed, Expected, Remediation, NeedsAdmin | Export-Csv -Path "$base.csv" -NoTypeInformation -Encoding UTF8 # HTML: self-contained, no external resources. function Enc([object]$s) { [System.Net.WebUtility]::HtmlEncode([string]$s) } $rows = New-Object System.Text.StringBuilder $fam = '' foreach ($r in $results) { if ($r.Family -ne $fam) { $fam = $r.Family [void]$rows.AppendLine(('{0}' -f (Enc $fam))) } $statusLabel = $r.Status; if ($statusLabel -eq 'NotApplicable') { $statusLabel = 'N/A' } $detail = (Enc $r.Observed) if ($r.Expected) { $detail += ('
Expected: {0}
' -f (Enc $r.Expected)) } if ($r.Remediation -and $r.Status -in @('Fail', 'Warn', 'Info')) { $detail += ('
Fix: {0}
' -f (Enc $r.Remediation)) } [void]$rows.AppendLine(('{0}{2}{3}
{4}
{5}' -f (Enc $r.Id), $r.Status.ToLower(), (Enc $statusLabel), (Enc $r.Title), (Enc $r.Practice), $detail)) } $html = @" Endpoint assessment: $(Enc $env:COMPUTERNAME)

Endpoint controls assessment: $(Enc $env:COMPUTERNAME)

$(Enc $meta.os) · run $(Enc $started.ToString('yyyy-MM-dd HH:mm')) · elevated: $($script:IsAdmin) · v$($script:AssessmentVersion)

$score%Score
$($counts['Pass'])Pass
$($counts['Fail'])Fail
$($counts['Warn'])Warn
$($counts['Unknown'])Unknown
$($counts['NotApplicable'])N/A
$($rows.ToString())
IDStatusControlWhat we found
"@ Set-Content -Path "$base.html" -Value $html -Encoding UTF8 Write-Host '' Write-Host 'Reports written:' -ForegroundColor White Write-Host (" {0}.html" -f $base) Write-Host (" {0}.json" -f $base) Write-Host (" {0}.csv" -f $base) } Write-Host '' Write-Host 'Atlas AVD checks these controls continuously across every session host: https://www.atlasavd.com/tools/cmmc-readiness' -ForegroundColor DarkCyan if ($PassThru) { $results }