Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Registry operations
📖 Scenario: You are managing Windows system settings using the registry. You want to automate reading and updating registry keys to configure system behavior.
🎯 Goal: Build a PowerShell script that reads a registry key value, sets a new value, and then verifies the change by reading the key again.
📋 What You'll Learn
Use PowerShell to read a registry key value
Create a variable to hold the registry path
Set a new value for a registry key
Read and display the updated registry key value
💡 Why This Matters
🌍 Real World
Automating registry changes helps system administrators configure multiple computers quickly and consistently.
💼 Career
Knowing how to script registry operations is useful for IT support, system administration, and automation roles.
Progress0 / 4 steps
1
Create a variable for the registry path
Create a variable called $regPath and set it to the string 'HKCU:\Software\MyApp'.
PowerShell
Hint
Use single quotes around the registry path string.
2
Create a variable for the registry value name
Create a variable called $valueName and set it to the string 'Setting1'.
PowerShell
Hint
Use single quotes around the value name string.
3
Read the current registry value
Use Get-ItemProperty with $regPath to read the registry key, and store the value of $valueName in a variable called $currentValue.
PowerShell
Hint
Use parentheses to get the property object, then access the property by .$valueName.
4
Set a new registry value and display it
Use Set-ItemProperty with $regPath, $valueName, and the new value 'Enabled'. Then read the updated value into $updatedValue and print it using Write-Output.
PowerShell
Hint
Use Set-ItemProperty to update the value, then read it again and print it.
Practice
(1/5)
1. What PowerShell cmdlet is used to read a value from the Windows registry?
Using New-Item or Remove-Item which manage keys, not values
Trying to read with Remove-Item
2. Which of the following is the correct syntax to set a registry value named TestValue to 123 under HKCU:\Software\MyApp?
easy
A. Get-ItemProperty -Path 'HKCU:\Software\MyApp' -Name 'TestValue' -Value 123
B. Set-ItemProperty -Path 'HKCU:\Software\MyApp' -Value 'TestValue' -Name 123
C. Set-ItemProperty -Path 'HKCU:\Software\MyApp' -Name 'TestValue' -Value 123
D. New-Item -Path 'HKCU:\Software\MyApp' -Name 'TestValue' -Value 123
Solution
Step 1: Identify correct cmdlet and parameters
Set-ItemProperty sets a registry value. The parameters are -Path for key, -Name for value name, and -Value for the data.
Step 2: Check parameter order and names
Set-ItemProperty -Path 'HKCU:\Software\MyApp' -Name 'TestValue' -Value 123 correctly uses -Path, -Name, and -Value in proper order. Other options mix parameters or use wrong cmdlets.
Final Answer:
Set-ItemProperty -Path 'HKCU:\Software\MyApp' -Name 'TestValue' -Value 123 -> Option C