Bird
0
0

Which PowerShell command correctly enables script block logging by setting the registry key?

easy📝 Configuration Q12 of 15
PowerShell - Scripting Best Practices
Which PowerShell command correctly enables script block logging by setting the registry key?
ASet-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy ScriptBlockLogging
BEnable-ScriptBlockLogging -Value 1
CNew-Item -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell' -Name 'ScriptBlockLogging' -Value 1
DSet-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -Value 1
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct registry path and property

    The registry path for script block logging is under HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging with property EnableScriptBlockLogging.
  2. Step 2: Match command syntax

    Set-ItemProperty sets a registry value correctly. Set-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -Value 1 uses correct path, property, and value 1 to enable logging.
  3. Final Answer:

    Set-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name 'EnableScriptBlockLogging' -Value 1 -> Option D
  4. Quick Check:

    Set-ItemProperty + correct path = enable logging [OK]
Quick Trick: Use Set-ItemProperty with full registry path to enable logging [OK]
Common Mistakes:
  • Using non-existent cmdlets like Enable-ScriptBlockLogging
  • Incorrect registry paths
  • Confusing execution policy with logging

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes