Dmitry Porotnikov / PowerShell: Automating Windows Crash Control Configuration

Created Wed, 20 Sep 2023 14:29:42 +0000 Modified Wed, 20 Sep 2023 14:29:42 +0000
171 Words

PowerShell: Automating Windows Crash Control Configuration

This script aims to automate the task of configuring several settings under the Windows CrashControl registry path. The configurations include specifying memory dump paths, enabling auto-reboot, setting logging levels, and more.

Reference documentation:
https://learn.microsoft.com/en-us/troubleshoot/windows-client/performance/generate-a-kernel-or-complete-crash-dump

$dumpFilePath = 'D:\MEMORY.DMP'
$minidumpDir = '%SystemRoot%\Minidump'
$registryPath = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl"

try
{
Set-ItemProperty -Path $registryPath -Name "AutoReboot" -Value 1
Set-ItemProperty -Path $registryPath -Name "CrashDumpEnabled" -Value 1
Set-ItemProperty -Path $registryPath -Name "DisableEmoticon" -Value 1
Set-ItemProperty -Path $registryPath -Name "DumpFile" -Value $dumpFilePath
Set-ItemProperty -Path $registryPath -Name "DumpLogLevel" -Value 0
Set-ItemProperty -Path $registryPath -Name "EnableLogFile" -Value 1
Set-ItemProperty -Path $registryPath -Name "LogEvent" -Value 1
Set-ItemProperty -Path $registryPath -Name "MinidumpDir" -Value $minidumpDir

Set-ItemProperty -Path $registryPath -Name "MinidumpsCount" -Value 5
Set-ItemProperty -Path $registryPath -Name "Overwrite" -Value 1
#Set-ItemProperty -Path $registryPath -Name "DumpFilters" -Value "dumpfve.sys"
Set-ItemProperty -Path $registryPath -Name "AlwaysKeepMemoryDump" -Value 1
Set-ItemProperty -Path $registryPath -Name "NMICrashDump" -Value 1
Set-ItemProperty -Path $registryPath -Name "IgnorePagefileSize" -Value 1
Write-Output "Registry values have been set successfully."
}
catch
{

Write-Output "Something went wrong. Are you running the script as Admin?"
}