0
0
PowerShellscripting~10 mins

Script block logging in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable script block logging in PowerShell.

PowerShell
Set-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name [1] -Value 1
Drag options to blanks, or click blank then click option'
AEnableScriptBlockLogging
BScriptBlockLog
CEnableLogging
DEnableScriptLogging
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect registry property names like 'EnableLogging' or 'ScriptBlockLog'.
Forgetting to set the value to 1 to enable logging.
2fill in blank
medium

Complete the command to check if script block logging is enabled.

PowerShell
Get-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name [1]
Drag options to blanks, or click blank then click option'
AEnableScriptBlockLogging
BEnableScriptLogging
CEnableLogging
DScriptBlockLog
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong property names that do not exist in the registry path.
Confusing script block logging with other logging features.
3fill in blank
hard

Fix the error in the command to enable script block logging.

PowerShell
Set-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name [1] -Value 1
Drag options to blanks, or click blank then click option'
AScriptBlockLog
BEnableLogging
CEnableScriptBlockLogging
DEnableScriptLogging
Attempts:
3 left
💡 Hint
Common Mistakes
Setting the value as a string 'true' instead of integer 1.
Using incorrect property names.
4fill in blank
hard

Fill both blanks to create a script block logging policy and enable it.

PowerShell
New-Item -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell' -Name [1] -Force; Set-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\[2]' -Name EnableScriptBlockLogging -Value 1
Drag options to blanks, or click blank then click option'
AScriptBlockLogging
BLogging
CScriptBlockLog
DScriptLogging
Attempts:
3 left
💡 Hint
Common Mistakes
Using different names for the new item and the path in Set-ItemProperty.
Using incorrect folder names that do not exist.
5fill in blank
hard

Fill all three blanks to enable script block logging and start PowerShell transcription.

PowerShell
Set-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging' -Name [1] -Value 1; Start-Transcript -Path [2]; Write-Output [3]
Drag options to blanks, or click blank then click option'
AEnableScriptBlockLogging
B'C:\Logs\PowerShellTranscript.txt'
C'Script block logging started'
DEnableLogging
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names or values.
Not quoting the file path or message string properly.
Forgetting to start transcription.