ⓟrogramming/PowerShell

개체 (Object)

뚱땡이 우주인 2018. 6. 23. 01:28
# 개체 Get-Member Type type1, type2 ....
# gps | member   == Get-Process | Get-Meber
# 운영체제의 프로세스 개체에서 속성과 메서드만 표시하고 싶은 경우
PS > Get-Process | get-Member -MemberType property, method                                                                                                             


   TypeName: System.Diagnostics.Process

Name                       MemberType Definition                                                             
----                       ---------- ----------                                                             
BeginErrorReadLine         Method     void BeginErrorReadLine()                                              
BeginOutputReadLine        Method     void BeginOutputReadLine()                                             
CancelErrorRead            Method     void CancelErrorRead()                                                 
CancelOutputRead           Method     void CancelOutputRead()                                                
Close                      Method     void Close()                                                           
CloseMainWindow            Method     bool CloseMainWindow()                                                 
Dispose                    Method     void Dispose(), void IDisposable.Dispose()                             
Equals                     Method     bool Equals(System.Object obj)                                         
GetHashCode                Method     int GetHashCode()                                                      
GetLifetimeService         Method     System.Object GetLifetimeService()                                     
GetType                    Method     type GetType()                                                         
InitializeLifetimeService  Method     System.Object InitializeLifetimeService()                              
Kill                       Method     void Kill()                                                            
Refresh                    Method     void Refresh()                                                         
Start                      Method     bool Start()                                                           
ToString                   Method     string ToString()                                                     
....


# 모든 유형의 속성을 표시하고 싶은 경우
PS > Get-Process | get-Member -MemberType properties
Name                       MemberType     Definition                                                                         
----                       ----------     ----------                                                                         
Handles                    AliasProperty  Handles = Handlecount                                                              
Name                       AliasProperty  Name = ProcessName                                                                 
NPM                        AliasProperty  NPM = NonpagedSystemMemorySize64                                                   
PM                         AliasProperty  PM = PagedMemorySize64                                                             
SI                         AliasProperty  SI = SessionId                                                                     
VM                         AliasProperty  VM = VirtualMemorySize64                                                           
WS                         AliasProperty  WS = WorkingSet64                                                                  
Parent                     CodeProperty   System.Object Parent{get=GetParentProcess;}                                        
__NounName                 NoteProperty   string __NounName=Process                                                          
BasePriority               Property       int BasePriority {get;}                                                            
Container                  Property       System.ComponentModel.IContainer Container {get;}                                  
EnableRaisingEvents        Property       bool EnableRaisingEvents {get;set;}                                                
ExitCode                   Property       int ExitCode {get;}             
...


# Users 루트에 잇는 폴더와 파일 객체에 대한 멤버를 확인
# -Hidden 은 숨길 파일도 표시하는 스위치다.
PS > Get-ChildItem -Path /Users -Hidden | Get-Member                                                                                                                           


   TypeName: System.IO.DirectoryInfo

Name                      MemberType     Definition                                                                                                                                 
----                      ----------     ----------                                                                                                                                 
LinkType                  CodeProperty   System.String LinkType{get=GetLinkType;}                                                                                                   
Mode                      CodeProperty   System.String Mode{get=Mode;}                                                                                                              
Target                    CodeProperty   System.Collections.Generic.IEnumerable`1[[System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85...
Create                    Method         void Create()