명령이 반환하는 .NET Framework 개체에 대한 정보를 표시하는 Get-Member는 가장 유용한 cmdlet 중 하나입니다. 정보에는 개체의 유형, 속성 및 메서드가 포함됩니다.
Get-Member를 사용하려면 파이프라인 연산자(|)를 사용하여 명령의 결과를 Get-Member로 보냅니다. 예를 들면 다음과 같습니다.
get-service | get-member
이 명령은 Get-Service가 실제로 컴퓨터의 각 서비스마다 하나의 System.ServiceProcess.ServiceController 개체 집합을 반환함을 나타냅니다.
TypeName: System.ServiceProcess.ServiceController Name MemberType Definition ---- ---------- ---------- Name AliasProperty Name = ServiceName add_Disposed Method System.Void add_Disposed(EventHandler value) Close Method System.Void Close() Continue Method System.Void Continue() CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(Type requestedType) Dispose Method System.Void Dispose() Equals Method System.Boolean Equals(Object obj) ExecuteCommand Method System.Void ExecuteCommand(Int32 command) get_CanPauseAndContinue Method System.Boolean get_CanPauseAndContinue() get_CanShutdown Method System.Boolean get_CanShutdown() get_CanStop Method System.Boolean get_CanStop() get_Container Method System.ComponentModel.IContainer get_Container() get_DependentServices Method System.ServiceProcess.ServiceController[] get_DependentServices() get_DisplayName Method System.String get_DisplayName() get_MachineName Method System.String get_MachineName() get_ServiceHandle Method System.Runtime.InteropServices.SafeHandle get_ServiceHandle() get_ServiceName Method System.String get_ServiceName() get_ServicesDependedOn Method System.ServiceProcess.ServiceController[] get_ServicesDependedOn() get_ServiceType Method System.ServiceProcess.ServiceType get_ServiceType() get_Site Method System.ComponentModel.ISite get_Site() get_Status Method System.ServiceProcess.ServiceControllerStatus get_Status() GetHashCode Method System.Int32 GetHashCode() GetLifetimeService Method System.Object GetLifetimeService() GetType Method System.Type GetType() InitializeLifetimeService Method System.Object InitializeLifetimeService() Pause Method System.Void Pause() Refresh Method System.Void Refresh() remove_Disposed Method System.Void remove_Disposed(EventHandler value) set_DisplayName Method System.Void set_DisplayName(String value) set_MachineName Method System.Void set_MachineName(String value) set_ServiceName Method System.Void set_ServiceName(String value) set_Site Method System.Void set_Site(ISite value) Start Method System.Void Start(), System.Void Start(String[] args) Stop Method System.Void Stop() ToString Method System.String ToString() WaitForStatus Method System.Void WaitForStatus(ServiceControllerStatus desiredStatus), System.Voi... CanPauseAndContinue Property System.Boolean CanPauseAndContinue {get;} CanShutdown Property System.Boolean CanShutdown {get;} CanStop Property System.Boolean CanStop {get;} Container Property System.ComponentModel.IContainer Container {get;} DependentServices Property System.ServiceProcess.ServiceController[] DependentServices {get;} DisplayName Property System.String DisplayName {get;set;} MachineName Property System.String MachineName {get;set;} ServiceHandle Property System.Runtime.InteropServices.SafeHandle ServiceHandle {get;} ServiceName Property System.String ServiceName {get;set;} ServicesDependedOn Property System.ServiceProcess.ServiceController[] ServicesDependedOn {get;} ServiceType Property System.ServiceProcess.ServiceType ServiceType {get;} Site Property System.ComponentModel.ISite Site {get;set;} Status Property System.ServiceProcess.ServiceControllerStatus Status {get;}
이 정보는 매우 기술적으로 보이지만 실제로는 매우 실용적인 내용입니다.
-
typename(예: "System.ServiceProcess.ServiceController")은 cmdlet이 반환하는 .NET 개체의 유형을 알려 줍니다. 이 .NET 클래스의 개체에 대한 정보를 보려면 MSDN의 검색 입력란에 유형 이름을 붙여 넣습니다. 연관된 MSDN 항목에서는 Get-Service가 반환하는 개체를 포함하여 이 클래스에 포함된 개체의 속성 및 메서드에 대한 정보를 제공합니다.
-
Property 유형은 개체의 속성을 나타냅니다. 각 속성 값은 서비스 개체에 대한 정보입니다. 예를 들어 ServiceController 개체에는 CanPauseAndContinue 속성이 있습니다. MSDN의 속성 설명에서는 이 속성이 서비스를 일시 중단하고 다시 시작할 수 있는지 여부를 나타낸다고 설명합니다.
특정 서비스의 속성 값을 나열하려면 다음과 같이 입력하십시오.
예를 들면 다음과 같습니다.(get-service <service-name>).<property-name>
경고 서비스의 CanPauseAndContinue 속성에 대한 이름 및 값 목록을 표시하려면 다음과 같이 입력하십시오.(get-service alerter).canpauseandcontinue
경고 서비스의 모든 속성 값 목록을 표시하려면 다음과 같이 입력하십시오.get-service alerter | format-list -property name, CanPauseAndContinue
모든 서비스의 CanPauseAndContinue 속성에 대한 이름 및 값 테이블을 표시하려면 다음과 같이 입력하십시오.get-service alerter | format-list -property *
get-service | format-table -property name, CanPauseAndContinue
-
Method 유형은 개체의 메서드, 즉 개체에서 수행할 수 있는 작업을 나타냅니다. 예를 들어 ServiceController 개체에는 서비스를 중지할 수 있는 Stop 메서드가 있습니다.
서비스 개체의 메서드를 호출하려면 다음 형식을 사용합니다. (괄호를 포함해야 합니다.)
(get-service <service-name>).<method-name>() For example, (get-service schedule).stop()
Get-Member 명령에 대한 자세한 내용을 보려면 다음과 같이 입력하십시오.
get-help get-member -detailed