PowerShell: (Get-ChildItem | Get-Member | ? { $_.Name -eq "Mode"}).Definition

I was curious about that *nix like mode for the item ('d----')

[13] gci

    Directory: Microsoft.PowerShell.Core\FileSystem::C:\Users\yvesdolc

Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 9/27/2007 6:38 PM Tracing

So I did

[14] gci | gm

   TypeName: System.IO.DirectoryInfo

Name MemberType Definition
---- ---------- ----------
Create Method System.Void Create(), System.Void Create(DirectorySecurity directorySecurity)
CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(Type requestedType)
CreateSubdirectory Method System.IO.DirectoryInfo CreateSubdirectory(String path), System.IO.DirectoryInfo CreateSubdirectory(String path, Di...
Delete Method System.Void Delete(), System.Void Delete(Boolean recursive)
Equals Method System.Boolean Equals(Object obj)
GetAccessControl Method System.Security.AccessControl.DirectorySecurity GetAccessControl(), System.Security.AccessControl.DirectorySecurity...
GetDirectories Method System.IO.DirectoryInfo[] GetDirectories(), System.IO.DirectoryInfo[] GetDirectories(String searchPattern), System....
GetFiles Method System.IO.FileInfo[] GetFiles(String searchPattern), System.IO.FileInfo[] GetFiles(String searchPattern, SearchOpti...
GetFileSystemInfos Method System.IO.FileSystemInfo[] GetFileSystemInfos(String searchPattern), System.IO.FileSystemInfo[] GetFileSystemInfos()
GetHashCode Method System.Int32 GetHashCode()
GetLifetimeService Method System.Object GetLifetimeService()
GetObjectData Method System.Void GetObjectData(SerializationInfo info, StreamingContext context)
GetType Method System.Type GetType()
get_Attributes Method System.IO.FileAttributes get_Attributes()
get_CreationTime Method System.DateTime get_CreationTime()
get_CreationTimeUtc Method System.DateTime get_CreationTimeUtc()
get_Exists Method System.Boolean get_Exists()
get_Extension Method System.String get_Extension()
get_FullName Method System.String get_FullName()
get_LastAccessTime Method System.DateTime get_LastAccessTime()
get_LastAccessTimeUtc Method System.DateTime get_LastAccessTimeUtc()
get_LastWriteTime Method System.DateTime get_LastWriteTime()
get_LastWriteTimeUtc Method System.DateTime get_LastWriteTimeUtc()
get_Name Method System.String get_Name()
get_Parent Method System.IO.DirectoryInfo get_Parent()
get_Root Method System.IO.DirectoryInfo get_Root()
InitializeLifetimeService Method System.Object InitializeLifetimeService()
MoveTo Method System.Void MoveTo(String destDirName)
Refresh Method System.Void Refresh()
SetAccessControl Method System.Void SetAccessControl(DirectorySecurity directorySecurity)
set_Attributes Method System.Void set_Attributes(FileAttributes value)
set_CreationTime Method System.Void set_CreationTime(DateTime value)
set_CreationTimeUtc Method System.Void set_CreationTimeUtc(DateTime value)
set_LastAccessTime Method System.Void set_LastAccessTime(DateTime value)
set_LastAccessTimeUtc Method System.Void set_LastAccessTimeUtc(DateTime value)
set_LastWriteTime Method System.Void set_LastWriteTime(DateTime value)
set_LastWriteTimeUtc Method System.Void set_LastWriteTimeUtc(DateTime value)
ToString Method System.String ToString()
PSChildName NoteProperty System.String PSChildName=Tracing
PSDrive NoteProperty System.Management.Automation.PSDriveInfo PSDrive=C
PSIsContainer NoteProperty System.Boolean PSIsContainer=True
PSParentPath NoteProperty System.String PSParentPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\yvesdolc
PSPath NoteProperty System.String PSPath=Microsoft.PowerShell.Core\FileSystem::C:\Users\yvesdolc\Tracing
PSProvider NoteProperty System.Management.Automation.ProviderInfo PSProvider=Microsoft.PowerShell.Core\FileSystem
Attributes Property System.IO.FileAttributes Attributes {get;set;}
CreationTime Property System.DateTime CreationTime {get;set;}
CreationTimeUtc Property System.DateTime CreationTimeUtc {get;set;}
Exists Property System.Boolean Exists {get;}
Extension Property System.String Extension {get;}
FullName Property System.String FullName {get;}
LastAccessTime Property System.DateTime LastAccessTime {get;set;}
LastAccessTimeUtc Property System.DateTime LastAccessTimeUtc {get;set;}
LastWriteTime Property System.DateTime LastWriteTime {get;set;}
LastWriteTimeUtc Property System.DateTime LastWriteTimeUtc {get;set;}
Name Property System.String Name {get;}
Parent Property System.IO.DirectoryInfo Parent {get;}
Root Property System.IO.DirectoryInfo Root {get;}
Mode ScriptProperty System.Object Mode {get=$catr = "";...

And was wondering how I could see that ScriptProperty... I don't know, I just tried a couple of things and the first one to work was this:

[11] (gci|gm|?{$_.Name -eq "Mode"}).Definition
System.Object Mode {get=$catr = "";
if ( $this.Attributes -band 16 ) { $catr += "d" } else { $catr += "z" };
if ( $this.Attributes -band 32 ) { $catr += "a" } else { $catr += "-" } ;
if ( $this.Attributes -band 1 ) { $catr += "r" } else { $catr += "-" } ;
if ( $this.Attributes -band 2 ) { $catr += "h" } else { $catr += "-" } ;
if ( $this.Attributes -band 4 ) { $catr += "s" } else { $catr += "-" } ;
$catr;}

 

I'm sure there's an easier way but this one worked for me. Have a nice week-end et bonne fin de semaine y buen fin de semana.