I’m using Invoke-Command to read a registry key on a remote computer. I get some deserialized RegistryKey objects back, but can’t seem to access the key properties. The Format-Table cmdlet shows the property names/values, but I can’t find the property I use to access them in my script.
> $k = Invoke-Command -ComputerName ******** -ScriptBlock { Get-ChildItem 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall' }
> $k | Format-Table
Hive: HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
Name Property PSComputerName
---- -------- --------------
{FFC6E93A-B9AD-3F20-9B06-EE20E AuthorizedCDFPrefix : ********
24AAEAF} Comments :
Contact :
DisplayVersion : 11.0.51106
HelpLink : http://go.microsoft.com/fwlink/?LinkId=133405
HelpTelephone :
InstallDate : 20140319
InstallLocation :
InstallSource : C:\ProgramData\Package
Cache\{FFC6E93A-B9AD-3F20-9B06-EE20E24AAEAF}v11.0.51106\packages\vc_librarycore86\
ModifyPath : MsiExec.exe /X{FFC6E93A-B9AD-3F20-9B06-EE20E24AAEAF}
NoModify : 1
NoRepair : 1
Publisher : Microsoft Corporation
Readme :
Size :
EstimatedSize : 704660
SystemComponent : 1
UninstallString : MsiExec.exe /X{FFC6E93A-B9AD-3F20-9B06-EE20E24AAEAF}
URLInfoAbout :
URLUpdateInfo :
VersionMajor : 11
VersionMinor : 0
WindowsInstaller : 1
Version : 184600482
Language : 1033
DisplayName : Microsoft Visual C++ 2012 Core Libraries
However, when I use Get-Member I don’t see any way to get the property values:
> $k | Get-Member * -Force
TypeName: Deserialized.Microsoft.Win32.RegistryKey
Name MemberType Definition
---- ---------- ----------
pstypenames CodeProperty System.Collections.ObjectModel.Collection`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] pstypenames{get=PSTypeNames;}
psadapted MemberSet psadapted {SubKeyCount, View, Handle, ValueCount, Name}
psbase MemberSet psbase {}
psextended MemberSet psextended {ToString, Property, PSPath, PSParentPath, PSChildName, PSDrive, PSProvider, PSIsContainer, PSComputerName, RunspaceId, PSShowComputerName}
psobject MemberSet psobject {BaseObject, Members, Properties, Methods, ImmediateBaseObject, TypeNames, get_Members, get_Properties, get_Methods, get_ImmediateBaseObject, get_BaseObject, get_TypeNames, ToString, Copy, CompareTo, Equals, GetHashCode, G...
ToString Method string ToString(), string ToString(string format, System.IFormatProvider formatProvider), string IFormattable.ToString(string format, System.IFormatProvider formatProvider)
Property NoteProperty Deserialized.System.String[] Property=
PSChildName NoteProperty System.String PSChildName=AddressBook
PSComputerName NoteProperty System.String PSComputerName=build01d-whs-04
PSDrive NoteProperty Deserialized.System.Management.Automation.PSDriveInfo PSDrive=HKLM
PSIsContainer NoteProperty System.Boolean PSIsContainer=True
PSParentPath NoteProperty System.String PSParentPath=Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
PSPath NoteProperty System.String PSPath=Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\AddressBook
PSProvider NoteProperty Deserialized.System.Management.Automation.ProviderInfo PSProvider=Microsoft.PowerShell.Core\Registry
PSShowComputerName NoteProperty System.Boolean PSShowComputerName=True
RunspaceId NoteProperty System.Guid RunspaceId=49c33ad2-07c3-4f9b-aba8-7452e7df86cb
Handle Property System.String {get;set;}
Name Property System.String {get;set;}
SubKeyCount Property System.Int32 {get;set;}
ValueCount Property System.Int32 {get;set;}
View Property System.String {get;set;}
Does anyone know how I can read the property values of a deserialized Microsoft.Win32.RegistryKey object?