You enabled script block logging but no events appear in the Windows PowerShell log. What is a likely cause?
medium📝 Troubleshoot Q14 of 15
PowerShell - Scripting Best Practices
You enabled script block logging but no events appear in the Windows PowerShell log. What is a likely cause?
AThe registry key was set under the wrong registry hive
BPowerShell script execution is disabled
CThe event log service is stopped
DThe script block logging feature is only for PowerShell 5.0 and above
Step-by-Step Solution
Solution:
Step 1: Check registry hive correctness
Script block logging requires setting the key under HKLM (local machine). Setting it under HKCU or wrong hive causes no logging.
Step 2: Evaluate other options
PowerShell execution policy does not block logging; event log service stopping would affect all logs; script block logging works in PowerShell 5.0+ but question assumes correct version.
Final Answer:
The registry key was set under the wrong registry hive -> Option A
Quick Check:
Wrong registry hive = no logs [OK]
Quick Trick:Always set registry keys under HKLM for script block logging [OK]
Common Mistakes:
Setting keys under HKCU instead of HKLM
Assuming execution policy blocks logging
Ignoring event log service status
Master "Scripting Best Practices" in PowerShell
9 interactive learning modes - each teaches the same concept differently