Skip to content

Merge Example 4 and 5 in Get-Member.md #1874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions reference/3.0/Microsoft.PowerShell.Utility/Get-Member.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,33 +102,22 @@ This command gets the methods and properties of service objects that were extend
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
```powershell
PS C:\> Get-EventLog -Log System | Get-Member -MemberType ScriptProperty

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 only script property is the EventID.
### Example 5
```
PS C:\> get-eventlog -log system | get-member -membertype scriptproperty
TypeName: System.Diagnostics.EventLogEntry
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 ScriptProperty for their MemberType property.
The command returns the EventID property of the **EventLog** object.

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
### Example 5
```
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}
Expand All @@ -152,7 +141,7 @@ 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 members that have the name "MachineName."

The results show that only process objects (System.Diagnostics.Process) and service objects (System.ServiceProcess.ServiceController) have a MachineName property.
### Example 7
### Example 6
```
PS C:\> $a = get-member -inputobject @(1)
PS C:\> $a.count
Expand All @@ -179,7 +168,7 @@ 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 variable.

The fourth command uses the Count property of the array to find the number of objects in the $a variable.
### Example 8
### Example 7
```
PS C:\> $file = get-item c:\test\textFile.txt
PS C:\> $file.psobject.properties | where-object {$_.issettable} | format-table -property name
Expand Down Expand Up @@ -212,7 +201,7 @@ The first command uses the Get-Item cmdlet to get a text file, and then it saves
The second command gets all of the changeable properties of the file object in the $file variable and displays the names of the properties in a table.

The third command gets the changeable properties of all objects in your Windows PowerShell session.
### Example 9
### Example 8
```
PS C:\> $s = get-service
PS C:\> $s | get-member
Expand Down
31 changes: 9 additions & 22 deletions reference/4.0/Microsoft.PowerShell.Utility/Get-Member.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,35 +108,22 @@ The Get-Member command uses the View parameter to get only the extended members
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
```powershell
PS C:\> Get-EventLog -Log System | Get-Member -MemberType ScriptProperty

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 only script property is the EventID.

### Example 5
```
PS C:\> get-eventlog -log system | get-member -membertype scriptproperty
TypeName: System.Diagnostics.EventLogEntry
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 ScriptProperty for their MemberType property.
The command returns the EventID property of the **EventLog** object.

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
### Example 5
```
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}
Expand All @@ -161,7 +148,7 @@ The second command uses a ForEach statement to invoke each command, send the res

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

### Example 7
### Example 6
```
PS C:\> $a = get-member -inputobject @(1)
PS C:\> $a.count
Expand Down Expand Up @@ -189,7 +176,7 @@ The third command uses the Get-Member cmdlet to get the properties and methods o

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

### Example 8
### Example 7
```
PS C:\> $file = get-item c:\test\textFile.txt
PS C:\> $file.psobject.properties | where-object {$_.issettable} | format-table -property name
Expand Down Expand Up @@ -223,7 +210,7 @@ The second command gets all of the changeable properties of the file object in t

The third command gets the changeable properties of all objects in your Windows PowerShell session.

### Example 9
### Example 8
```
PS C:\> $s = get-service
PS C:\> $s | get-member
Expand Down