If you use the Get-PSDrive cmdlet you'll notice that HKCU and HKLM appear as drives. This allows us to use item cmdlets to manage items in the HKLM: and HKCU: drives.
To change your location to the HKCU: drive use either Set-Location HKCU: or cd HKCU:
To navigate through the registry drive: you can use cd the same way you would use it to navigate through directories in the command prompt. You can also use Set-Location
Example to navigate to HKCU/Control Panel/Desktop
PS HKCU:\> Set-Location "HKCU:/control panel/desktop"
or
PS HKCU:\> cd "HKCU:/control panel/desktop"
To view subkeys: Use either dir or Get-ChildItem
To create a new registry key:
To create a new registry key within a subkey we can use the New-Item cmdlet
For example, to create a key named PUNKISNAIL under hkcu/control panel/desktop
PS HKCU:\control panel\desktop> New-Item PUNKISNAIL
To delete a registry key:
Here we can use the remove-item cmdlet.
For example to delete the key PUNKISNAIL which we created under hkcu/control panel/desktop use:
PS HKCU:\control panel\desktop> remove-item PUNKISNAIL
If you're in a different drive you can use the following to delete the key:
PS C:\>remove-item -path "hkcu:/control panel/desktop/punkisnail"
To get the registry entries in a key:
Here we can use the Get-ItemProperty cmdlet.
To get the properties for menushowdelay found in HKCU/Control Panel/Desktop use: Get-ItemProperty -path "hkcu:/control panel/desktop" -name menushowdelay
To create a registry entry use:
new-itemproperty -path somepath -name someEntryName -value AnyValue -propertyType SomeType Example: new-itemproperty -path "HKCU:/control panel/desktop/punkisnail" -name MyNameIs -value "Shane Lobo" -propertyType string
possible property types are: String, ExpandString, Binary, DWord, MultiString, QWord, Unknown
To clear the value of a registry entry use:
Clear-ItemProperty Clear-ItemProperty -path SomePath -name SomeEntryName
To delete a registry entry use:
remove-ItemProperty remove-ItemProperty -path SomePath -name SomeEntryName
No comments:
Post a Comment