I’m trying to script going through the registry and handing back key,value,data, but I get a weird error around hklm:\software\classes.
I know it’s running
get-itemproperty -path Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Classes* -name AlwaysShowExtbut why?
PS C:\users\admin> .\get-reg HKLM:\SOFTWARE\Classes\
get-itemproperty -path Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Classes\* -name AlwaysShowExt
get-itemproperty : Property AlwaysShowExt does not exist at path HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.386.
At C:\users\ccfadmin\get-reg.ps1:36 char:15
+ $data = get-itemproperty -path $path -name $name | select -expa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (AlwaysShowExt:String) [Get-ItemProperty], PSArgumentException
+ FullyQualifiedErrorId : System.Management.Automation.PSArgumentException,Microsoft.PowerShell.Commands.GetItemPr
opertyCommand
Here’s the script:
# get-reg.ps1
Param($key)
Get-ChildItem -Recurse $key | foreach { # won't process top key
$path = $_.PSPath
$_.Property | foreach {
$name = $_
"get-itemproperty -path $path -name $name"
$data = get-itemproperty -path $path -name $name | select -expand $name
[pscustomobject]@{key=$path; value=$name; data=$data}
}
}