PowerShell Genie

Add-Member

Use Add-Member to add a property or method to an existing object — the key to shaping custom output in reports and pipeline results.

Command 4 min read PowerShell 7 on Windows

Documentation: Microsoft Learn — add-member

Syntax

1PS> Add-Member [-InputObject] <PSObject> [-MemberType] <String> [-Name] <String> [-Value <Object>] [-SecondValue <Object>] [-Force] [-PassThru] [<CommonParameters>]

Try it

Windows PowerShell

PowerShell example · browser support is limited.

Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

Interactive simulation · fictional data

Examples

Add a simple note property

1PS> $svc = Get-Service Spooler $svc | Add-Member -MemberType NoteProperty -Name Checked -Value (Get-Date) $svc.Checked
Show reference output

Illustrative output · values vary by environment

24 October 2026 19:10:00

Add a calculated property that updates itself

1PS> $disk = Get-PSDrive C $disk | Add-Member -MemberType ScriptProperty -Name FreeGB -Value { [math]::Round($this.Free / 1GB, 2) } $disk.FreeGB
Show reference output

Illustrative output · values vary by environment

42.18

Add the same property to every object in a pipeline

1PS> Get-Service | Add-Member -MemberType NoteProperty -Name Environment -Value 'Production' -PassThru | Select-Object Name, Environment -First 3
Show reference output

Illustrative output · values vary by environment

Name        Environment
----        -----------
Spooler     Production
WinRM       Production
W32Time     Production

Parameters

Parameter definitions:

  • -MemberType — The kind of member: NoteProperty, ScriptProperty, AliasProperty, ScriptMethod, CodeMethod, or PropertySet.
  • -Name — The name of the new property or method.
  • -Value — For NoteProperty, the value. For ScriptProperty, a script block that runs when the property is read.
  • -SecondValue — For AliasProperty, the real property name it points to.
  • -Force — Overwrites an existing member with the same name instead of throwing an error.
  • -PassThru — Returns the modified object so it can continue down the pipeline.

Microsoft Learn — add-member

Add-Member changes the object, not the pipeline

Without -PassThru, Add-Member modifies the object in place and outputs nothing, so a pipeline after it receives nothing. When you pipe into Add-Member and want objects to keep flowing, always add -PassThru.

For building a brand-new object from scratch, [pscustomobject]@{ Name = 'x'; Value = 1 } is cleaner and faster than New-Object PSObject plus several Add-Member calls. Reserve Add-Member for enriching objects that already exist, such as service or process objects.

Script properties run their script block every time the property is read, and $this inside the block refers to the object itself. That makes them ideal for computed values like free-space percentages, but expensive if the calculation is slow and the property is read often.

Inspect an object's members with Get-Member

Shape output with Select-Object

Updated 25 October 2026. Browser outputs are fictional; check the installed module help for your environment.

Recap

Add-Member Use Add-Member to add a property or method to an existing object — the key to shaping custom output in reports and pipeline results.

Next: New Object
Genie guideAdd-Member

Add-Member adds NoteProperty, ScriptProperty, AliasProperty, and ScriptMethod members to any object. Learn the calculated-property pattern, when to use -Force, and why PSCustomObject is often the cleaner choice. The console below is pre-loaded — run it, then change a value and run it again.