Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 3.0 » Add-Member

Add-Member - Powershell 3.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »

Add-Member

Short description
Adds custom properties and methods to an instance of a Windows PowerShell object.

Syntax


Description
The Add-Member cmdlet lets you add members (properties and methods) to an instance of a Windows PowerShell object. For 
example, you can add a NoteProperty member that contains a description of the object or a ScriptMethod member that runs
 a script to change the object.


To use Add-Member, pipe the object to Add-Member, or use the InputObject parameter to specify the object. Use the Membe
rType parameter to specify the type of member that you want to add, use the Name parameter to assign a name to the new 
member, and use the Value parameter to set the value of the member.


The properties and methods that you add are added only to the particular instance of the object that you specify. Add-M
ember does not change the object type. To create a new object type, use the Add-Type cmdlet. You can also use the Expor
t-Clixml cmdlet to save the instance of the object, including the additional members, in a file. Then you can use the I
mport-Clixml cmdlet to re-create the instance of the object from the information that is stored in the exported file.


Beginning in Windows PowerShell 3.0, Add-Member has new features that make it easier to add note properties to objects.
 You can use the NotePropertyName and NotePropertyValue parameters to define a note property or use the NotePropertyMem
bers parameter, which takes a hash table of note property names and values.


Also, beginning in Windows PowerShell 3.0, the PassThru parameter, which generates an output object, is needed less fre
quently. Add-Member now adds the new members directly to the input object of more types. For more information, see the 
PassThru parameter description.