How to check if an object's property is an object which has more properties

Hello Guys,

I am a powershell newbie learning on V3. I hope I am able to explain this clear.

How will I be able tell if my one of object’s property is another object which has more properties?

For example, in the below case where I am trying to find the ACL of a directory, my desired output is actually stored in $acl.access which seems to be an object and it has several properties. Here $acl is an object and has ‘access’ as it’s one of the property, which indeed is another object and it has some properties too. How can I know such properties(which has sub-properties) just by looking into the member of the parent object ($acl in this case)?

PS C:\> $acl = Get-Acl C:

PS C:\> $acl


Path                                                  Owner                                                 Access                                              
----                                                  -----                                                 ------                                              
C:\                                                   NT SERVICE\TrustedInstaller                           CREATOR OWNER Allow  268435456...                   

PS C:\> $acl | gm -MemberType Properties

   TypeName: System.Security.AccessControl.DirectorySecurity

Name                    MemberType     Definition                                                                                                               
----                    ----------     ----------                                                                                                               
Access                  CodeProperty   System.Security.AccessControl.AuthorizationRuleCollection Access{get=GetAccess;}                                         
CentralAccessPolicyId   CodeProperty   System.Security.Principal.SecurityIdentifier CentralAccessPolicyId{get=GetCentralAccessPolicyId;}                        
CentralAccessPolicyName CodeProperty   System.String CentralAccessPolicyName{get=GetCentralAccessPolicyName;}                                                   
Group                   CodeProperty   System.String Group{get=GetGroup;}                                                                                       
Owner                   CodeProperty   System.String Owner{get=GetOwner;}                                                                                       
Path                    CodeProperty   System.String Path{get=GetPath;}                                                                                         
Sddl                    CodeProperty   System.String Sddl{get=GetSddl;}                                                                                         
PSChildName             NoteProperty   System.String PSChildName=C:\                                                                                            
PSDrive                 NoteProperty   System.Management.Automation.PSDriveInfo PSDrive=C                                                                       
PSParentPath            NoteProperty   System.String PSParentPath=                                                                                              
PSPath                  NoteProperty   System.String PSPath=Microsoft.PowerShell.Core\FileSystem::C:\                                                           
PSProvider              NoteProperty   System.Management.Automation.ProviderInfo PSProvider=Microsoft.PowerShell.Core\FileSystem                                
AccessRightType         Property       type AccessRightType {get;}                                                                                              
AccessRuleType          Property       type AccessRuleType {get;}                                                                                               
AreAccessRulesCanonical Property       bool AreAccessRulesCanonical {get;}                                                                                      
AreAccessRulesProtected Property       bool AreAccessRulesProtected {get;}                                                                                      
AreAuditRulesCanonical  Property       bool AreAuditRulesCanonical {get;}                                                                                       
AreAuditRulesProtected  Property       bool AreAuditRulesProtected {get;}                                                                                       
AuditRuleType           Property       type AuditRuleType {get;}                                                                                                
AccessToString          ScriptProperty System.Object AccessToString {get=$toString = "";...                                                                     
AuditToString           ScriptProperty System.Object AuditToString {get=$toString = "";...                                                                      

PS C:\> $acl.access | ft -AutoSize

           FileSystemRights AccessControlType IdentityReference      IsInherited                InheritanceFlags PropagationFlags
           ---------------- ----------------- -----------------      -----------                ---------------- ----------------
                  268435456             Allow CREATOR OWNER                False ContainerInherit, ObjectInherit      InheritOnly
                FullControl             Allow NT AUTHORITY\SYSTEM          False ContainerInherit, ObjectInherit             None
                FullControl             Allow BUILTIN\Administrators       False ContainerInherit, ObjectInherit             None
                 AppendData             Allow BUILTIN\Users                False                ContainerInherit             None
                CreateFiles             Allow BUILTIN\Users                False                ContainerInherit      InheritOnly
ReadAndExecute, Synchronize             Allow BUILTIN\Users                False ContainerInherit, ObjectInherit             None

PS C:\> $acl.Access | gm

   TypeName: System.Security.AccessControl.FileSystemAccessRule

Name              MemberType Definition                                                              
----              ---------- ----------                                                              
Equals            Method     bool Equals(System.Object obj)                                          
GetHashCode       Method     int GetHashCode()                                                       
GetType           Method     type GetType()                                                          
ToString          Method     string ToString()                                                       
AccessControlType Property   System.Security.AccessControl.AccessControlType AccessControlType {get;}
FileSystemRights  Property   System.Security.AccessControl.FileSystemRights FileSystemRights {get;}  
IdentityReference Property   System.Security.Principal.IdentityReference IdentityReference {get;}    
InheritanceFlags  Property   System.Security.AccessControl.InheritanceFlags InheritanceFlags {get;}  
IsInherited       Property   bool IsInherited {get;}                                                 
PropagationFlags  Property   System.Security.AccessControl.PropagationFlags PropagationFlags {get;}  

PS C:\> $acl.AccessRightType | gm -MemberType Properties

   TypeName: System.RuntimeType

Name                       MemberType Definition                                                                                           
----                       ---------- ----------                                                                                           
Assembly                   Property   System.Reflection.Assembly Assembly {get;}                                                           
AssemblyQualifiedName      Property   string AssemblyQualifiedName {get;}                                                                  
Attributes                 Property   System.Reflection.TypeAttributes Attributes {get;}                                                   
BaseType                   Property   type BaseType {get;}                                                                                 
ContainsGenericParameters  Property   bool ContainsGenericParameters {get;}                                                                
CustomAttributes           Property   System.Collections.Generic.IEnumerable[System.Reflection.CustomAttributeData] CustomAttributes {get;}
DeclaredConstructors       Property   System.Collections.Generic.IEnumerable[System.Reflection.ConstructorInfo] DeclaredConstructors {get;}
DeclaredEvents             Property   System.Collections.Generic.IEnumerable[System.Reflection.EventInfo] DeclaredEvents {get;}            
DeclaredFields             Property   System.Collections.Generic.IEnumerable[System.Reflection.FieldInfo] DeclaredFields {get;}            
DeclaredMembers            Property   System.Collections.Generic.IEnumerable[System.Reflection.MemberInfo] DeclaredMembers {get;}          
DeclaredMethods            Property   System.Collections.Generic.IEnumerable[System.Reflection.MethodInfo] DeclaredMethods {get;}          
DeclaredNestedTypes        Property   System.Collections.Generic.IEnumerable[System.Reflection.TypeInfo] DeclaredNestedTypes {get;}        
DeclaredProperties         Property   System.Collections.Generic.IEnumerable[System.Reflection.PropertyInfo] DeclaredProperties {get;}     
DeclaringMethod            Property   System.Reflection.MethodBase DeclaringMethod {get;}                                                  
DeclaringType              Property   type DeclaringType {get;}                                                                            
FullName                   Property   string FullName {get;}                                                                               
GenericParameterAttributes Property   System.Reflection.GenericParameterAttributes GenericParameterAttributes {get;}                       
GenericParameterPosition   Property   int GenericParameterPosition {get;}                                                                  
GenericTypeArguments       Property   type[] GenericTypeArguments {get;}                                                                   
GenericTypeParameters      Property   type[] GenericTypeParameters {get;}                                                                  
GUID                       Property   guid GUID {get;}                                                                                     
HasElementType             Property   bool HasElementType {get;}                                                                           
ImplementedInterfaces      Property   System.Collections.Generic.IEnumerable[type] ImplementedInterfaces {get;}                            
IsAbstract                 Property   bool IsAbstract {get;}                                                                               
IsAnsiClass                Property   bool IsAnsiClass {get;}                                                                              
IsArray                    Property   bool IsArray {get;}                                                                                  
IsAutoClass                Property   bool IsAutoClass {get;}                                                                              
IsAutoLayout               Property   bool IsAutoLayout {get;}                                                                             
IsByRef                    Property   bool IsByRef {get;}                                                                                  
IsClass                    Property   bool IsClass {get;}                                                                                  
IsCOMObject                Property   bool IsCOMObject {get;}                                                                              
IsConstructedGenericType   Property   bool IsConstructedGenericType {get;}                                                                 
IsContextful               Property   bool IsContextful {get;}                                                                             
IsEnum                     Property   bool IsEnum {get;}                                                                                   
IsExplicitLayout           Property   bool IsExplicitLayout {get;}                                                                         
IsGenericParameter         Property   bool IsGenericParameter {get;}                                                                       
IsGenericType              Property   bool IsGenericType {get;}                                                                            
IsGenericTypeDefinition    Property   bool IsGenericTypeDefinition {get;}                                                                  
IsImport                   Property   bool IsImport {get;}                                                                                 
IsInterface                Property   bool IsInterface {get;}                                                                              
IsLayoutSequential         Property   bool IsLayoutSequential {get;}                                                                       
IsMarshalByRef             Property   bool IsMarshalByRef {get;}                                                                           
IsNested                   Property   bool IsNested {get;}                                                                                 
IsNestedAssembly           Property   bool IsNestedAssembly {get;}                                                                         
IsNestedFamANDAssem        Property   bool IsNestedFamANDAssem {get;}                                                                      
IsNestedFamily             Property   bool IsNestedFamily {get;}                                                                           
IsNestedFamORAssem         Property   bool IsNestedFamORAssem {get;}                                                                       
IsNestedPrivate            Property   bool IsNestedPrivate {get;}                                                                          
IsNestedPublic             Property   bool IsNestedPublic {get;}                                                                           
IsNotPublic                Property   bool IsNotPublic {get;}                                                                              
IsPointer                  Property   bool IsPointer {get;}                                                                                
IsPrimitive                Property   bool IsPrimitive {get;}                                                                              
IsPublic                   Property   bool IsPublic {get;}                                                                                 
IsSealed                   Property   bool IsSealed {get;}                                                                                 
IsSecurityCritical         Property   bool IsSecurityCritical {get;}                                                                       
IsSecuritySafeCritical     Property   bool IsSecuritySafeCritical {get;}                                                                   
IsSecurityTransparent      Property   bool IsSecurityTransparent {get;}                                                                    
IsSerializable             Property   bool IsSerializable {get;}                                                                           
IsSpecialName              Property   bool IsSpecialName {get;}                                                                            
IsUnicodeClass             Property   bool IsUnicodeClass {get;}                                                                           
IsValueType                Property   bool IsValueType {get;}                                                                              
IsVisible                  Property   bool IsVisible {get;}                                                                                
MemberType                 Property   System.Reflection.MemberTypes MemberType {get;}                                                      
MetadataToken              Property   int MetadataToken {get;}                                                                             
Module                     Property   System.Reflection.Module Module {get;}                                                               
Name                       Property   string Name {get;}                                                                                   
Namespace                  Property   string Namespace {get;}                                                                              
ReflectedType              Property   type ReflectedType {get;}                                                                            
StructLayoutAttribute      Property   System.Runtime.InteropServices.StructLayoutAttribute StructLayoutAttribute {get;}                    
TypeHandle                 Property   System.RuntimeTypeHandle TypeHandle {get;}                                                           
TypeInitializer            Property   System.Reflection.ConstructorInfo TypeInitializer {get;}                                             
UnderlyingSystemType       Property   type UnderlyingSystemType {get;}                                                                     

PS C:\> 

Aside from your basic numeric and boolean types, pretty much everything is an object (most of which will have some sort of properties.)

However, you’re already on the right track. Get-Member is an important tool for finding out what’s in an object. You can also take those type names (such as “System.Security.AccessControl.FileSystemAccessRule”) and search for them on the web; your top result should be the MSDN documentation page for that particular class. From there, you can click hyperlinks to the other types referenced in each property and method.