From a90b6caeeded666c9468aeff08fc695809040180 Mon Sep 17 00:00:00 2001 From: fukusuket <41001169+fukusuket@users.noreply.github.com> Date: Thu, 12 Feb 2026 23:35:55 +0900 Subject: [PATCH] fix: improve module logging path checks in WELA.ps1 --- WELA.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/WELA.ps1 b/WELA.ps1 index 8d351a93..da261d0c 100644 --- a/WELA.ps1 +++ b/WELA.ps1 @@ -5717,7 +5717,8 @@ function ConfigureAuditSettings { try { $moduleLoggingPath = "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\PowerShell\ModuleLogging\ModuleNames" $currentValue = "Not Set" - if (Test-Path $moduleLoggingPath) { + $pathExists = Test-Path $moduleLoggingPath + if ($pathExists) { $prop = Get-ItemProperty -Path $moduleLoggingPath -Name "*" -ErrorAction SilentlyContinue if ($prop) { $currentValue = $prop."*" @@ -5739,7 +5740,10 @@ function ConfigureAuditSettings { } if ($response -eq "" -or $response -eq "Y" -or $response -eq "y") { - New-Item -Path $moduleLoggingPath -Force | Out-Null + if (-not $pathExists) + { + New-Item -Path $moduleLoggingPath -Force | Out-Null + } Set-ItemProperty -Path $moduleLoggingPath -Name "*" -Value "*" -Type String Write-Host "[OK] Module logging enabled for all modules" -ForegroundColor Green }