PowerShell Logo Small

Get-Member



This is the built-in help made by Microsoft for the command 'Get-Member', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Gets the properties and methods of objects.

SYNTAX


Get-Member [[-Name] <string[]>] [-Force] [-InputObject <psobject>] [-MemberType {AliasProperty | CodeProperty | Property | NoteProperty | ScriptP
roperty | Properties | PropertySet | Method | CodeMethod | ScriptMethod | Methods | ParameterizedProperty | MemberSet | Event | All}] [-Static] [
-View {Extended | Adapted | Base | All}] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


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 th
e class, not of the instance), use the Static parameter. To get only certain types of members, such as NoteProperties, use the MemberType paramet
er.



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=113322
Add-Member
Get-Help
Get-Command
Get-PSDrive

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>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;}



Description
-----------
This command displays the properties and methods of the process objects (System.ServiceProcess.ServiceController) that are generated by the Get-S
ervice 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, bu
t it does not get static members and does not display intrinsic members.








-------------------------- EXAMPLE 2 --------------------------

C:\PS>get-service | get-member -force

C:\PS> (get-service -schedule).psbase



Description
-----------
This example gets all of the members (properties and methods) of the service objects (System.ServiceProcess.ServiceController) retrieved by the G
et-Service cmdlet, including the intrinsic members, such as PSBase and PSObject, and the 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 pipeline operator (|) to pass t
he 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 objects to the display. Get-Me
mber 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 second command shows how to disp
lay the value of the PSBase property of the Schedule service.








-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-service | get-member -view extended

TypeName: System.ServiceProcess.ServiceController

Name MemberType Definition
---- ---------- ----------
Name AliasProperty Name = ServiceName



Description
-----------
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 --------------------------

C:\PS>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;}



Description
-----------
This command gets the script properties of event log objects in the System log in Event Viewer. In this case, the only script property is the Eve
ntID.








-------------------------- EXAMPLE 5 --------------------------

C:\PS>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;}



Description
-----------
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 property.

The command returns the EventID property of the EventLog object.








-------------------------- EXAMPLE 6 --------------------------

C:\PS>$a = "get-process", "get-service", "get-culture", "get-psdrive", "get-executionpolicy"

C:\PS> foreach ($cmdlet in $a) {invoke-expression $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;}



Description
-----------
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 results from Get-Member to memb
ers that have the name "MachineName."

The results show that only process objects (System.Diagnostics.Process) and service objects (System.ServiceProcess.ServiceController) have a Mach
ineName property.








-------------------------- EXAMPLE 7 --------------------------

C:\PS>$a = get-member -inputobject @(1)

C:\PS>$a.count

1

C:\PS> $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()
...

C:\PS>$a.count
1



Description
-----------
This example demonstrates how to find the properties and methods of an array of objects when you have only one object of the given type.

Because the goal of the command is to find the properties of an array, the first command uses the InputObject parameter. 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 command saves them in the $a vari
able.

The fourth command uses the Count property of the array to find the number of objects in the $a variable.