The discipline
terminal / powershell
param([string] $Out = "$env:USERPROFILE\Desktop\hkcu-audit.txt")
$sections = [ordered]@{
'Startup entries' = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run'
'Startup approvals' = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run'
'Visual performance' = 'HKCU:\Control Panel\Desktop'
'Taskbar animations' = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced'
}
$report = foreach ($name in $sections.Keys) {
"## $name"
(Get-ItemProperty $sections[$name] -ErrorAction SilentlyContinue).PSObject.Properties |
Where-Object Name -NotLike 'PS*' | ForEach-Object { "{0} = {1}" -f $_.Name, $_.Value }
}
$report | Set-Content $Out -Encoding utf8What makes it reviewable
- Literal verbs: only
Get-ItemProperty,Set-Contentto a chosen output file. NoSet-/New-/Remove-anywhere near a hive — a reviewer confirms that by inspection in seconds. - Error-bounded:
-ErrorAction SilentlyContinue+ explicit section headers mean a machine lacking one key still gets the rest of the report. - Deterministic order:
[ordered]sections produce a diffable file across days — changes gunshot-locate themselves.
Publish the output as part of any bigger audit; nobody needs to trust your intentions when the verbs give you away.