PowerShell/Registry

This lesson introduces PowerShell Registry processing.

Objectives and Skills
After completing this lesson, you will be able to:
 * Describe basic PowerShell Windows Registry concepts.
 * Create PowerShell scripts to manage Registry keys.

Readings

 * 1)  Windows Registry
 * 2)  INI file
 * 3) BonusBits: Mastering PowerShell Chapter 16 - The Registry

Multimedia

 * 1) YouTube: Working With Registry Items In Powershell
 * 2) YouTube: Windows PowerShell - How To - Windows Registry

Get-PSDrive
The Get-PSDrive cmdlet gets the drives available in the current session, including logical mapped network drives and drives exposed by Windows PowerShell providers. Example output:

New-Item
The New-Item cmdlet creates a new item and sets its value.

New-ItemProperty
The New-ItemProperty cmdlet creates a new property for an item and sets its value.

Get-Item
The Get-Item cmdlet gets the item at the specified location.

Get-ItemProperty
The Get-ItemProperty cmdlet gets the properties of a specified item.

Set-ItemProperty
The Set-ItemProperty cmdlet changes the value of the property of the specified item.

Remove-Item
The Remove-Item cmdlet deletes one or more items.

Remove-ItemProperty
The Remove-ItemProperty cmdlet deletes a property and its value from an item.

Activities

 * 1) Review Microsoft TechNet: Use PowerShell to Back Up System State Prior to Making Changes.  Use the Checkpoint-Computer cmdlet to create a system restore point.
 * 2) Review Microsoft TechNet: Using the Get-PSDrive Cmdlet.  Use the Get-PSDrive cmdlet to display available drives.  Identify the drive names supported by the Registry provider.  Use a foreach loop and the Get-ChildItem (alias Dir) cmdlet to display the root keys available in the registry drives.
 * 3) Review PowerShell.com: The Registry.  Create a script that uses a foreach loop to display all Registry entries that contain the word 'PowerShell' in the key or the value.
 * 4) Review CrucialSecurityBlog: Typed URLs. Create a script that uses a foreach loop to display Internet Explorer history (Internet Explorer Typed Urls).
 * 5) Review Microsoft MSDN: Run and RunOnce Registry Keys.  Create a script to add a RunOnce item to automatically run either PowerShell or PowerShell ISE (your choice) at the next logon.
 * 6) Review AskVG.com: How to Enable “Open Command Window Here” Option in Context Menu in Windows Vista and 7.  Create a script to delete the 'Extended' item property from the following keys.  Be sure to use the -Confirm option and carefully confirm that only the Extended property will be removed.  Use Windows Explorer to confirm that 'Open command window here' now appears on the context menu without holding down the Shift key.
 * 7) * HKLM:\SOFTWARE\Classes\Directory\shell\cmd
 * 8) * HKLM:\SOFTWARE\Classes\Drive\shell\cmd

Lesson Summary

 * The Windows Registry is a hierarchical database that stores configuration settings and options on Microsoft Windows operating systems.
 * The Registry supports strongly-typed data values, while INI files are text only.
 * Regedit.exe is the built-in Windows Registry editor.
 * The Registry contains two basic elements: keys and values. Registry keys are container objects similar to folders. Registry values are non-container objects similar to files. Keys may contain values or further keys.
 * Keys are referenced with a syntax similar to Windows' path names, using backslashes to indicate levels of hierarchy. Keys must have a case insensitive name without backslashes.
 * The keys at the root level of the hierarchical database are generally named by their Windows API definitions, which all begin "HKEY".
 * HKEY_LOCAL_MACHINE, abbreviated as HKLM, stores settings that are specific to the local computer.
 * HKEY_CURRENT_USER abbreviated HKCU, stores settings that are specific to the currently logged-in user
 * The INI file format is a simple text file with a basic structure composed of sections, properties, and values used primarily in MS-DOS and 16-bit versions of Windows.
 * Windows NT and later versions of Windows use the Registry for configuration settings.
 * Applications built on the .NET Framework and portable applications often use XML-format configuration files rather than the Registry.
 * The PowerShell Registry provider exposes two registry paths: HKLM for HKEY_LOCAL_MACHINE and HKCU for HKEY_CURRENT_USER.
 * The Get-PSDrive cmdlet gets the drives available in the current session, including logical mapped network drives and drives exposed by Windows PowerShell providers.
 * The New-Item cmdlet creates a new item and sets its value.
 * The New-ItemProperty cmdlet creates a new property for an item and sets its value.
 * The Get-Item cmdlet gets the item at the specified location.
 * The Get-ItemProperty cmdlet gets the properties of a specified item.
 * The Set-ItemProperty cmdlet changes the value of the property of the specified item.
 * The Remove-Item cmdlet deletes one or more items.
 * The Remove-ItemProperty cmdlet deletes a property and its value from an item.

Key Terms

 * hive
 * A logical group of keys, subkeys, and values in the Registry that has a set of supporting files containing backups of its data.

Assessments

 * Flashcards: Quizlet: Windows PowerShell - Registry
 * Quiz: Quizlet: Windows PowerShell - Registry