PowerShell + Registry + PSDrive: Removing a registry value

I had to remove a registry value this morning to reverse a change I made last year, and instead of firing up the GUI to do so, I decided I’d make myself a New Year’s resolution on my first day back at work;

If you’re going to do something, try doing it in PowerShell first.

I fired up a PowerShell window (WIN+X+I, if you’ve configured Windows 8.x correctly) and decided to use the HKCU PSDrive:

cd hkcu:softwareMicrosoftoffice15.0OutlookSetup

Here’s where the PowerShell registry provider doesn’t work as you’d expect. If you did a ‘dir’, ‘ls’, or Get-ChildItem, you wouldn’t see anything listed. The cmdlet you need to use is Get-ItemProperty, and then pass in the current path.

Get-ItemProperty -Path $pwd

($pwd is an automatic variable that holds the current path)

PowerShell window showing the contents of a registry location as a result of using the Get-ItemProperty cmdlet. A value named ImportPRF is highlighted, as that's the one I wish to remove.

To remove the registry value, I did the following:

Remove-ItemProperty -Name ImportPRF -Path $pwd -WhatIf

Note: I always use the –whatif parameter first, to see what’s going to happen. Remove it once you’ve tested and are happy with the results of the command. Add –verbose for even more information.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s