Exclude Unwanted Registry Values

by May 7, 2010

When you query the values of a registry key, PowerShell will add a bunch of artifacts to the results. You'll get some new properties that all start with "PS":

$regkey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
Get-ItemProperty $regkey | Select-Object *

You should use -exclude like this to get rid of them:

Get-ItemProperty $regkey | Select-Object * -exclude PS*

This will exclude any property starting with "PS." You should try a more precise approach that lists the unwanted property names:

Get-ItemProperty $regkey | Select-Object * -exclude PSPath,
PSParentPath, PSChildName, PSProvider, PSDrive

Twitter This Tip! ReTweet this Tip!