how to filter name/value pairs under a registry key by name and value in PowerShell?
Posted by jpluimers on 2019/09/03
A very concise way for [WayBack] how to filter name/value pairs under a registry key by name and value in PowerShell?:
$path = 'hkcu:\Software\Microsoft\Windows\CurrentVersion\Extensions'
(Get-ItemProperty $path).PSObject.Properties |
Where-Object { $_.Name -match '^xls' ` -or $_.Value -match 'msaccess.exe$' } |
Select-Object Name, Value
Thanks montonero for getting me on that path and pointing me to the hidden PSObject property which by itself has Properties, and making me find these links with background information:
- [WayBack] Enumerate & Search Registry Key values with PowerShell | 9to5IT Searching for registry values with PowerShell is not that easy. This article provides a solution to enumerate & search registry key values via PowerShell.
- [WayBack] Back to Basics: Comparing Values Between PS Custom Objects
- [WayBack] Powershell: Everything you wanted to know about PSCustomObject – a truckload of information
- [WayBack] PowerShell – Iterate over PSObject properties on
PSObjectbeing hidden - [WayBack] Accessing values of object properties in PowerShell
- [WayBack] Why PSObject is hidden? – the
PSObjectis revealed when callingGet-Memberwith the-Forceparameter. - [WayBack] Properties of an object in pipeline $_.???
More in-depth information:
- [WayBack] Get-Member (Microsoft.PowerShell.Utility)
- The
Get-Membercmdlet gets the members, the properties and methods, of objects. To specify the object, use the InputObject parameter or pipe an object to Get-Member. To get information about static members, the members of the class, not of the instance, use the Static parameter. To get only certain types of members, such as NoteProperties, use the MemberType parameter. -
-ForceAdds the intrinsic members (PSBase, PSAdapted, PSObject, PSTypeNames) and the compiler-generated get_ and set_ methods to the display. By default, Get-Member gets these properties in all views other than Base and Adapted, but it does not display them.
The following list describes the properties that are added when you use the Force parameter:
- PSBase: The original properties of the .NET Framework object without extension or adaptation. These are the properties defined for the object class and listed in MSDN.
- PSAdapted. The properties and methods defined in the Windows PowerShell extended type system.
- PSExtended. The properties and methods that were added in the Types.ps1xml files or by using the Add-Member cmdlet.
- PSObject. The adapter that converts the base object to a Windows PowerShell PSObject object.
- PSTypeNames. A list of object types that describe the object, in order of specificity. When formatting the object, Windows PowerShell searches for the types in the Format.ps1xml files in the Windows PowerShell installation directory ($pshome). It uses the formatting definition for the first type that it finds.
- The
- [WayBack] PSObject Class (System.Management.Automation)
- Wraps an object providing alternate views of the available members and ways to extend them. Members can be methods, properties, parameterized properties, etc.
- [WayBack] PSObject.Properties Property (System.Management.Automation)
- Gets the
Propertycollection, or the members that are actually properties.
Is of typePSMemberInfoCollection<PSPropertyInfo>
- Gets the
- [WayBack] PSMemberInfoCollection<T> Class
- Serves as the collection of members in an
PSObjectorMemberSet
- Serves as the collection of members in an
- [WayBack] PSPropertyInfo Class (System.Management.Automation)
- Serves as a base class for all members that behave like properties.
- [WayBack] Difference between PSObject, Hashtable and PSCustomObject
- [WayBack] Combining Objects Efficiently – Use a Hash Table to Index a Collection of Objects
- With objects objects everywhere it may not seem apparent, but hash tables are still needed. When the PowerShell mind sets to work it can be very easy to use where and selects everywhere to get you…
- [Archive.is] Custom objects default display in PowerShell 3.0
- [WayBack] Using PSObject to store data in PowerShell | 9to5IT
- PowerShell’s PSObject is a powerful tool which is used to store, retrieve, sort and export data. Here is how to use PSObject to store data in PowerShell.
–jeroen






Leave a comment