Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Get-KeyProperty
- # Actually this is a powershell function
- # While you explore a registry key using Powershell Get-ItemProperty CMDLet, There are annoying PS* properties
- # Then you can add this function to your $PROFILE and now use this CMDLet instead of Get-ItemProperty
- # PS* properties will be removed
- # Usage: Get-KeyProperty "Registry Key path"
- Function Get-KeyProperty {
- [CmdletBinding()]
- Param(
- [Parameter(Mandatory=$True)]
- [ValidateScript({Test-Path $_})]
- [String]$RegPath
- )
- $Values = New-Object PSObject
- Get-ItemProperty "$RegPath" |
- Get-Member -MemberType NoteProperty |
- Where-Object {$_.Name -notlike "PS*"} | Foreach {
- $_ | Select-Object -ExpandProperty Name | Foreach {
- $Value = Get-ItemProperty "$RegPath" -Name "$_"
- $Values |
- Add-Member -MemberType NoteProperty -Name "$_" -Value "$($Value."$_")"
- }
- }
- Return $Values
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement