0
0
PowerShellscripting~20 mins

Registry operations in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Registry Operations Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of this PowerShell command?
Given the following command, what will it output if the registry key HKCU:\Software\MyApp contains a string value Version set to 1.2.3?
PowerShell
Get-ItemProperty -Path 'HKCU:\Software\MyApp' -Name Version | Select-Object -ExpandProperty Version
AHKCU:\Software\MyApp
BVersion
C1.2.3
DGet-ItemProperty
Attempts:
2 left
💡 Hint
The command extracts the value of the property named 'Version' from the registry key.
📝 Syntax
intermediate
1:30remaining
Which option correctly creates a new registry key?
You want to create a new registry key HKCU:\Software\MyApp\Settings. Which command is syntactically correct?
ANew-ItemProperty -Path 'HKCU:\Software\MyApp\Settings'
BNew-RegistryKey -Path 'HKCU:\Software\MyApp\Settings'
CCreate-Item -Path 'HKCU:\Software\MyApp\Settings'
DNew-Item -Path 'HKCU:\Software\MyApp\Settings'
Attempts:
2 left
💡 Hint
The cmdlet to create a new registry key is similar to creating a new item in a provider path.
🔧 Debug
advanced
2:00remaining
Why does this script fail to set a registry value?
This script tries to set a string value Theme to Dark under HKCU:\Software\MyApp but fails with an error. What is the cause?
Set-ItemProperty -Path 'HKCU:\Software\MyApp' -Name Theme -Value Dark
AThe -Value parameter requires a string in quotes.
BThe registry key 'HKCU:\Software\MyApp' does not exist.
CSet-ItemProperty cannot set string values.
DThe -Name parameter should be omitted.
Attempts:
2 left
💡 Hint
Check if the registry key exists before setting a property.
🚀 Application
advanced
2:00remaining
How to delete a registry value safely?
You want to delete the registry value Theme under HKCU:\Software\MyApp only if it exists. Which script snippet correctly does this?
ARemove-ItemProperty -Path 'HKCU:\Software\MyApp' -Name Theme -ErrorAction SilentlyContinue
BRemove-ItemProperty -Path 'HKCU:\Software\MyApp' -Name Theme
CRemove-ItemProperty -Path 'HKCU:\Software\MyApp' -Name Theme -Force
DRemove-Item -Path 'HKCU:\Software\MyApp\Theme'
Attempts:
2 left
💡 Hint
Use error handling to avoid errors if the value does not exist.
🧠 Conceptual
expert
2:30remaining
What is the effect of this PowerShell script on the registry?
Consider this script:
$keyPath = 'HKCU:\Software\MyApp'
if (-not (Test-Path $keyPath)) {
  New-Item -Path $keyPath | Out-Null
}
Set-ItemProperty -Path $keyPath -Name 'LastRun' -Value (Get-Date).ToString('yyyy-MM-dd')
What does this script do?
ACreates the key if missing and sets 'LastRun' value to today's date in yyyy-MM-dd format.
BDeletes the key if it exists and sets 'LastRun' value to current time.
COnly sets 'LastRun' value without creating the key if missing.
DCreates a new key every time without setting any value.
Attempts:
2 left
💡 Hint
Check the logic: it tests for key existence, creates if missing, then sets a value.