名前 Get-Member 概要 Gets the properties and methods of objects. 構文 Get-Member [[-Name] []] [-Force] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignor e | Suspend}] [-InformationVariable []] [-InputObject []] [-MemberType {AliasProperty | Cod eProperty | Property | NoteProperty | ScriptProperty | Properties | PropertySet | Method | CodeMethod | ScriptMethod | Methods | ParameterizedProperty | MemberSet | Event | Dynamic | All}] [-Static] [-View {Extended | Adapted | Base | All}] [] 説明 The Get-Member cmdlet gets the "members" (properties and methods) of objects. To specify the object, use the InputObject parameter or pipe an object to Get-Member. To retrieve information about static members (members of the class, not of the instance), use the Static parameter. To get only certain types of m embers, such as NoteProperties, use the MemberType parameter. パラメーター -Force [] Adds the intrinsic members (PSBase, PSAdapted, PSObject, PSTypeNames) and the compiler-generated get_ and set_ m ethods to the display. By default, Get-Member gets these properties in all views other than "Base" and "Adapted, " but it does not display them. The following list describes the properties that are added when you use the Force parameter: -- PSBase: The original properties of the .NET Framework object without extension or adaptation. These are the properties defined for the object class and listed in MSDN. -- PSAdapted: The properties and methods defined in the Windows PowerShell extended type system. -- PSExtended: The properties and methods that were added in the Types.ps1xml files or by using the Add-Member c mdlet. -- PSObject: The adapter that converts the base object to a Windows PowerShell PSObject object. -- PSTypeNames: A list of object types that describe the object, in order of specificity. When formatting the ob ject, Windows PowerShell searches for the types in the Format.ps1xml files in the Windows PowerShell installatio n directory ($pshome). It uses the formatting definition for the first type that it finds. 必須 false 位置 named 既定値 none パイプライン入力を許可する false ワイルドカード文字を許可する false -InformationAction [] The following list describes the properties that are added when you use the Force parameter: -- PSBase: The original properties of the .NET Framework object without extension or adaptation. These are the properties defined for the object class and listed in MSDN. -- PSAdapted: The properties and methods defined in the Windows PowerShell extended type system. -- PSExtended: The properties and methods that were added in the Types.ps1xml files or by using the Add-Member c mdlet. -- PSObject: The adapter that converts the base object to a Windows PowerShell PSObject object. -- PSTypeNames: A list of object types that describe the object, in order of specificity. When formatting the ob ject, Windows PowerShell searches for the types in the Format.ps1xml files in the Windows PowerShell installatio n directory ($pshome). It uses the formatting definition for the first type that it finds. 必須 false 位置 named 既定値 none パイプライン入力を許可する false ワイルドカード文字を許可する false -InformationVariable [] The following list describes the properties that are added when you use the Force parameter: -- PSBase: The original properties of the .NET Framework object without extension or adaptation. These are the properties defined for the object class and listed in MSDN. -- PSAdapted: The properties and methods defined in the Windows PowerShell extended type system. -- PSExtended: The properties and methods that were added in the Types.ps1xml files or by using the Add-Member c mdlet. -- PSObject: The adapter that converts the base object to a Windows PowerShell PSObject object. -- PSTypeNames: A list of object types that describe the object, in order of specificity. When formatting the ob ject, Windows PowerShell searches for the types in the Format.ps1xml files in the Windows PowerShell installatio n directory ($pshome). It uses the formatting definition for the first type that it finds. 必須 false 位置 named 既定値 none パイプライン入力を許可する false ワイルドカード文字を許可する false -InputObject [] Specifies the object whose members are retrieved. Using the InputObject parameter is not the same as piping an object to Get-Member. The differences are as follow s: -- When you pipe a collection of objects to Get-Member, Get-Member gets the members of the individual objects in the collection, such as the properties of each string in an array of strings. -- When you use InputObject to submit a collection of objects, Get-Member gets the members of the collection, su ch as the properties of the array in an array of strings. 必須 false 位置 named 既定値 none パイプライン入力を許可する true (ByValue) ワイルドカード文字を許可する false -MemberType [] Gets only members with the specified member type. The default is All. The valid values for this parameter are: AliasProperty, All, CodeMethod, CodeProperty, Event, MemberSet, Method, Methods, Noteproperty, ParameterizedProperty, Properties, Property, PropertySet, ScriptMethod, and ScriptProper ty. For information about these values, see "PSMemberTypes Enumeration" in MSDN at http://msdn.microsoft.com/en-us/l ibrary/windows/desktop/system.management.automation.psmembertypes(v=vs.85).aspx. Not all objects have every type of member. If you specify a member type that the object does not have, Windows P owerShell returns a null value. To get related types of members, such as all extended members, use the View parameter. If you use the MemberType parameter with the Static or View parameters, Get-Member gets the members that belong to both sets. 必須 false 位置 named 既定値 none パイプライン入力を許可する false ワイルドカード文字を許可する false -Name [] Specifies the names of one or more properties or methods of the object. Get-Member gets only the specified prope rties and methods. If you use the Name parameter with the MemberType, View, or Static parameters, Get-Member gets only the members that satisfy the criteria of all parameters. To get a static member by name, use the Static parameter with the Name parameter. 必須 false 位置 1 既定値 none パイプライン入力を許可する false ワイルドカード文字を許可する false -Static [] Gets only the static properties and methods of the object. Static properties and methods are defined on the class of objects, not on any particular instance of the class. If you use the Static parameter with the View parameter, the View parameter is ignored. If you use the Static pa rameter with the MemberType parameter, Get-Member gets only the members that belong to both sets. 必須 false 位置 named 既定値 none パイプライン入力を許可する false ワイルドカード文字を許可する false -View [] Gets only particular types of members (properties and methods). Specify one or more of the values. The default i s "Adapted, Extended". Valid values are: -- Base: Gets only the original properties and methods of the .NET Framework object (without extension or adapt ation). -- Adapted: Gets only the properties and methods defined in the Windows PowerShell extended type system. -- Extended: Gets only the properties and methods that were added in the Types.ps1xml files or by using the Add- Member cmdlet. -- All: Gets the members in the Base, Adapted, and Extended views. The View parameter determines the members retrieved, not just the display of those members. To get particular member types, such as script properties, use the MemberType parameter. If you use the MemberTy pe and View parameters in the same command, Get-Member gets the members that belong to both sets. If you use the Static and View parameters in the same command, the View parameter is ignored. 必須 false 位置 named 既定値 none パイプライン入力を許可する false ワイルドカード文字を許可する false このコマンドレットは、次の共通パラメーターをサポートします: Verbose、 Debug、ErrorAction、ErrorVariable、WarningAction、WarningVariable、 OutBuffer, PipelineVariable、および OutVariable。詳細については、 about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216) を参照してください。 入力 System.Management.Automation.PSObject You can pipe any object to Get-Member 出力 Microsoft.PowerShell.Commands.MemberDefinition Get-Member returns an object for each property or method that its gets. メモ You can get information about a collection object either by using the InputObject parameter or by piping the obj ect, preceded by a comma, to Get-Member. You can use the $this automatic variable in script blocks that define the values of new properties and methods. The $this variable refers to the instance of the object to which the properties and methods are being added. For more information about the $this variable, see about_Automatic_Variables. -------------------------- EXAMPLE 1 -------------------------- PS C:\>get-service | get-member TypeName: System.ServiceProcess.ServiceController Name MemberType Definition ---- ---------- ---------- Name AliasProperty Name = ServiceName 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) 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() 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;} This command displays the properties and methods of the process objects (System.ServiceProcess.ServiceController) th at are generated by the Get-Service cmdlet. The command uses the pipeline operator (|) to send the output of a Get-Service command to Get-Member. Because the Get-Member part of the command does not have any parameters, it uses all of the default values. As such, it gets all member types, but it does not get static members and does not display intrinsic members. -------------------------- EXAMPLE 2 -------------------------- PS C:\>get-service | get-member -force PS C:\>(get-service -schedule).psbase This example gets all of the members (properties and methods) of the service objects (System.ServiceProcess.ServiceC ontroller) retrieved by the Get-Service cmdlet, including the intrinsic members, such as PSBase and PSObject, and th e get_ and set_ methods. The first command uses the Get-Service cmdlet to get objects that represent the services on the system. It uses a pi peline operator (|) to pass the service objects to the Get-Member cmdlet. The Get-Member command uses the Force parameter to add the intrinsic members and compiler-generated members of the o bjects to the display. Get-Member gets these members, but it hides them by default. You can use these properties and methods in the same way that you would use an adapted method of the object. The sec ond command shows how to display the value of the PSBase property of the Schedule service. -------------------------- EXAMPLE 3 -------------------------- PS C:\>get-service| get-member -view extended TypeName: System.ServiceProcess.ServiceController Name MemberType Definition ---- ---------- ---------- Name AliasProperty Name = ServiceName This command gets the methods and properties of service objects that were extended by using the Types.ps1xml file or the Add-Member cmdlet. The Get-Member command uses the View parameter to get only the extended members of the service objects. In this case , the extended member is the Name property, which is an alias property of the ServiceName property. -------------------------- EXAMPLE 4 -------------------------- PS C:\>get-eventlog -log system | gm -membertype scriptproperty TypeName: System.Diagnostics.EventLogEntry Name MemberType Definition ---- ---------- ---------- EventID ScriptProperty System.Object EventID {get=$this.get_EventID() -band 0xFFFF;} This command gets the script properties of event log objects in the System log in Event Viewer. In this case, the on ly script property is the EventID. -------------------------- EXAMPLE 5 -------------------------- PS C:\>get-eventlog -log system | get-member -membertype scriptproperty TypeName: System.Diagnostics.EventLogEntry Name MemberType Definition ---- ---------- ---------- EventID ScriptProperty System.Object EventID {get=$this.get_EventID() -band 0xFFFF;} This command gets the script properties of event log objects in the System log in Event Viewer. The command uses the MemberType parameter to get only objects with a value of AliasProperty for their MemberType pro perty. The command returns the EventID property of the EventLog object. -------------------------- EXAMPLE 6 -------------------------- PS C:\>$a = "get-process", "get-service", "get-culture", "get-psdrive", "get-executionpolicy" PS C:\>foreach ($cmdlet in $a) {invoke-command $cmdlet | get-member -name machinename} TypeName: System.Diagnostics.Process Name MemberType Definition ---- ---------- ---------- MachineName Property System.String MachineName {get;} TypeName: System.ServiceProcess.ServiceController Name MemberType Definition ---- ---------- ---------- MachineName Property System.String MachineName {get;set;} This command gets objects that have a MachineName property from a list of cmdlets. The first command stores the names of several cmdlets in the $a variable. The second command uses a ForEach statement to invoke each command, send the results to Get-Member, and limit the re sults from Get-Member to members that have the name "MachineName." The results show that only process objects (System.Diagnostics.Process) and service objects (System.ServiceProcess.S erviceController) have a MachineName property. -------------------------- EXAMPLE 7 -------------------------- PS C:\>$a = get-member -inputobject @(1) PS C:\>$a.count 1 PS C:\>$a = get-member -inputobject 1,2,3 TypeName: System.Object[] Name MemberType Definition ---- ---------- ---------- Count AliasProperty Count = Length Address Method System.Object& Address(Int32 ) Clone Method System.Object Clone() ... PS C:\>$a.count 1 This example demonstrates how to find the properties and methods of an array of objects when you have only one objec t of the given type. Because the goal of the command is to find the properties of an array, the first command uses the InputObject parame ter. It uses the "at" symbol (@) to indicate an array. In this case, the array contains only one object, the integer 1. The third command uses the Get-Member cmdlet to get the properties and methods of an array of integers, and the comm and saves them in the $a variable. The fourth command uses the Count property of the array to find the number of objects in the $a variable. -------------------------- EXAMPLE 8 -------------------------- PS C:\>$file = get-item c:\test\textFile.txt PS C:\>$file.psobject.properties | where-object {$_.issettable} | format-table -property name Name ---- PSPath PSParentPath PSChildName PSDrive PSProvider PSIsContainer IsReadOnly CreationTime CreationTimeUtc LastAccessTime LastAccessTimeUtc LastWriteTime LastWriteTimeUtc Attributes PS C:\>[appdomain]::CurrentDomain.GetAssemblies() | foreach-object { $_.getexportedtypes() } | foreach-object {$_.ge tproperties() | where-object {$_.canwrite }} | select-object reflectedtype, name This example shows how to determine which properties of an object can be changed. The example uses a file, but you c an use this command format to find the changeable properties of any object in Windows PowerShell. The first command uses the Get-Item cmdlet to get a text file, and then it saves the file object in the $file variab le. The second command gets all of the changeable properties of the file object in the $file variable and displays the n ames of the properties in a table. The third command gets the changeable properties of all objects in your Windows PowerShell session. -------------------------- EXAMPLE 9 -------------------------- PS C:\>$s = get-service PS C:\>$s | get-member TypeName: System.ServiceProcess.ServiceController Name MemberType Definition ---- ---------- ---------- Name AliasProperty Name = ServiceName RequiredServices AliasProperty RequiredServices = ServicesDependedOn Disposed Event System.EventHandler Disposed(System.Object, System.EventArgs Close Method System.Void Close() Continue Method System.Void Continue() CreateObjRef Method System.Runtime.Remoting.ObjRef CreateObjRef(type requestedTy Dispose Method System.Void Dispose() ... PS C:\>get-member -inputObject $s TypeName: System.Object[] Name MemberType Definition ---- ---------- ---------- Count AliasProperty Count = Length Address Method System.Object&, mscorlib, Version=2.0.0.0, Cultu Clone Method System.Object Clone() CopyTo Method System.Void CopyTo(array array, int index), Syst Equals Method bool Equals(System.Object obj) Get Method System.Object Get(int ) GetEnumerator Method System.Collections.IEnumerator GetEnumerator() GetHashCode Method int GetHashCode() ... This example shows how the InputObject parameter works in the Get-Member cmdlet. When you use the InputObject parame ter to get the members of a collection, Get-Member gets the members of the collection. When you pipe a collection of objects to Get-Member, Get-Member gets the members of each item in the collection. The first command gets the services on the local computer and saves the services in the $s variable. The second command pipes the $s variable to the Get-Member cmdlet. Get-Member gets the types of each member of $s an d the members of that type. In this case, it gets ServiceController objects and lists the members, such as RequiredS ervices and Close. The third command uses the InputObject parameter of Get-Member to submit the $s variable. Get-Member gets the type ( System.Object[]) and the members of the collection (or "array") of ServiceController objects, such as Count and Clon e. 関連するリンク Online Version: http://go.microsoft.com/fwlink/p/?linkid=293971 Add-Member Get-Command Get-Help Get-PSDrive about_Automatic_Variables about_Properties about_Methods about_Objects