Skip to content

Commit 78a132d

Browse files
shanehoeySean Wheeler
authored andcommitted
Update Add-Member.md example layouts (#2055)
* Update Add-Member.md fixed layout of examples 1,2 ,3 * fixed format of example 5
1 parent cf5f956 commit 78a132d

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

reference/6/Microsoft.PowerShell.Utility/Add-Member.md

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ For more information, see the *PassThru* parameter description.
7070
PS C:\> $A = dir c:\ps-test\test.txt
7171
PS C:\> $A | Add-Member -NotePropertyName Status -NotePropertyValue Done
7272
PS C:\> $A | Add-Member Status Done
73-
PS C:\> $A.StatusDone
73+
PS C:\> $A.Status
74+
Done
7475
```
7576

7677
These commands add the Status note property with a value of "Done" to the FileInfo object that represents the Test.txt file.
@@ -89,7 +90,8 @@ As the output shows, the value is "Done".
8990
```
9091
PS C:\> $A = dir c:\ps-test\test.txt
9192
PS C:\> $A | Add-Member -MemberType AliasProperty -Name FileLength -Value Length
92-
PS C:\> $A.FileLength2394
93+
PS C:\> $A.FileLength
94+
2394
9395
```
9496

9597
These commands add the FileLength alias property to the object that represents the Test.txt file.
@@ -104,7 +106,8 @@ The third command uses dot notation to get the value of the new FileLength prope
104106
### Example 3: Add a StringUse note property to a string
105107
```
106108
PS C:\> $A = "A string"PS C:\> $A = $A | Add-Member @{StringUse="Display"} -PassThru
107-
PS C:\> $A.StringUseDisplay
109+
PS C:\> $A.StringUse
110+
Display
108111
```
109112

110113
These commands add the **StringUse** note property to a string.
@@ -144,28 +147,16 @@ The third command uses dot notation to call the new PadBoth script method on the
144147
PS C:\> $Event = Get-EventLog -LogName System -Newest 1
145148
PS C:\> $Event.TimeWritten | Get-MemberTypeName: System.DateTime
146149
Name MemberType Definition
147-
148-
149150
---- ---------- ----------
150-
151-
152151
Add Method System.DateTime Add(System.TimeSpan value)
153-
154-
155152
AddDays Method System.DateTime AddDays(double value)
156-
157-
158153
AddHours Method System.DateTime AddHours(double value)
159-
160-
161154
AddMilliseconds Method System.DateTime AddMilliseconds(double value)
162-
163-
164155
AddMinutes Method System.DateTime AddMinutes(double value)...
165156
166-
167157
PS C:\> Add-Member -InputObject $Event -MemberType AliasProperty -Name When -Value TimeWritten -SecondValue System.String
168158
PS C:\> $Event.When | Get-MemberTypeName: System.String
159+
169160
Name MemberType Definition
170161
---- ---------- ----------
171162
Clone Method System.Object Clone()
@@ -492,18 +483,16 @@ When you use the *PassThru* parameter, this cmdlet returns the newly-extended ob
492483
Otherwise, this cmdlet does not generate any output.
493484
494485
## NOTES
495-
* You can add members only to PSObject objects. To determine whether an object is a PSObject object, use the "is" operator. For instance, to test an object stored in the $obj variable, type `$obj -is \[PSObject\]`.
486+
You can add members only to PSObject objects. To determine whether an object is a PSObject object, use the "is" operator. For instance, to test an object stored in the $obj variable, type `$obj -is \[PSObject\]`.
496487

497-
The names of the *MemberType*, *Name*, *Value*, and *SecondValue* parameters are optional.
488+
The names of the *MemberType*, *Name*, *Value*, and *SecondValue* parameters are optional.
498489
If you omit the parameter names, the unnamed parameter values must appear in this order: *MemberType*, *Name*, *Value*, and *SecondValue*.
499490
If you include the parameter names, the parameters can appear in any order.
500491

501-
You can use the $this automatic variable in script blocks that define the values of new properties and methods.
492+
You can use the $this automatic variable in script blocks that define the values of new properties and methods.
502493
The $this variable refers to the instance of the object to which the properties and methods are being added.
503494
For more information about the $this variable, see about_Automatic_Variables.
504495

505-
*
506-
507496
## RELATED LINKS
508497

509498
[Export-Clixml](Export-Clixml.md)

0 commit comments

Comments
 (0)