PowerShell Genie

New-Object

Use New-Object to create .NET objects, COM objects, and custom PSObjects — from web clients and lists to script-defined objects.

Command 4 min read PowerShell 7 on Windows

Documentation: Microsoft Learn — new-object

Syntax

1PS> New-Object [-TypeName] <String> [[-ArgumentList] <Object[]>] [-Property <Hashtable>] [-ComObject <String>] [<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

Create a growable list

1PS> $list = New-Object System.Collections.ArrayList $list.Add('server01') | Out-Null $list.Add('server02') | Out-Null $list
Show reference output

Illustrative output · values vary by environment

server01
server02

Download a file with a .NET web client

1PS> $wc = New-Object System.Net.WebClient $wc.DownloadFile('https://example.com/report.csv', 'C:\Temp\report.csv')
Show reference output

Illustrative output · values vary by environment

(file downloaded to C:\Temp\report.csv)

Build a custom object with properties

1PS> $server = New-Object PSObject -Property @{ Name = 'SRV01'; Role = 'Database'; Status = 'Online' } $server
Show reference output

Illustrative output · values vary by environment

Name   Role      Status
----   ----      ------
SRV01  Database  Online

Parameters

Parameter definitions:

  • -TypeName — The full .NET type name, such as System.Net.WebClient.
  • -ArgumentList — Arguments passed to the type's constructor.
  • -Property — A hashtable of property names and values set on the new object.
  • -ComObject — The ProgID of a COM component to create, such as WScript.Shell. Windows only.

Microsoft Learn — new-object

Prefer the modern syntax for new code

In PowerShell 5 and later, [System.Collections.ArrayList]::new() and [pscustomobject]@{ Name = 'x' } do the same jobs as New-Object with less typing and better performance. New-Object still matters for COM objects and for scripts that must run on older versions.

COM automation with -ComObject is Windows-only and needs the target application installed. It is also the classic way malware abuses PowerShell, so expect endpoint protection to flag scripts that create COM objects such as WScript.Shell or Shell.Application.

When adding items to an ArrayList, the Add() method returns the index of the new item, which pollutes your output. Pipe it to Out-Null or assign it to $null to keep the console clean.

Add properties to objects with Add-Member

Inspect object members with Get-Member

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

Recap

New-Object Use New-Object to create .NET objects, COM objects, and custom PSObjects — from web clients and lists to script-defined objects.

Next: Get Eventlog
Genie guideNew-Object

New-Object creates instances of .NET classes and COM components: download a file with WebClient, build a growable list, automate an application through COM, or assemble a custom object for a report. The console below is pre-loaded — run it, then change a value and run it again.