Yes, you create an empty array then use it to initialize the variable. Two other ways (System not needed as its namespace is already loaded): [Collections.ArrayList]$list = @() $list = [Collections.ArrayList]::new() New-Object is useful when you need -ComObject, or to dynamically create a type (typename stored as a string that you may not know when writing). It is the 'older' method before powershell had classes built-in. Also, if you create an 'untyped' variable from a cast, you can change its type later on. The first example I posted enforces the type for that variable, it can only be an arraylist. I recommend using the generic types where you can specify the type: [Collections.Generic.List[String]]$list = @() $list = [Collections.Generic.List[Int]]::new() Also save some typing and use a namespace: using namespace System.Collections.Generic [List[String]]$list = @() $list = [List[Int]]::new() And for speed (enumeration access), if the items are unique, try a HashSet: using namespace System.Collections.Generic [HashSet[String]]$list = @() $list = [HashSet[Int]]::new() You should be measuring speed on insertion/removal and access for real world speed tests. And you'll definitely see different results when you go past milestones like 10, 1000, 10000 items (generics are tailored to large datasets). Answer from chris-a5 on reddit.com
🌐
Reddit
reddit.com › r/powershell › two ways of creating a new system.collections.arraylist object, what's the difference?
r/PowerShell on Reddit: Two ways of creating a new System.Collections.ArrayList object, what's the difference?
April 7, 2023 -

I've come across two ways of creating a new System.Collections.ArrayList object:

$arrA = New-Object System.Collections.ArrayList
$arrB = [System.Collections.ArrayList]@() 

I have two questions:

  1. for arrB, if I'm reading this right, @() is creating an empty array and then it's being cast into [System.Collections.ArrayList]?

  2. Working with the created object is the same for me either way, but are there any differences I may be missing?

I made a quick test and casting was faster, but the difference is only noticeable when creating new arrays reaches the hundreds of thousands to millions (tested on an old A10-7870k). Doesn't really matter when I'm creating one array, but I thought it was mildly interesting.

$max = 100000
$ticksStart = (Get-Date).Ticks
for ($i = 0; $i -lt $max; $i++)
{
	$arrA = New-Object System.Collections.ArrayList
}
$ticksEnd = (Get-Date).Ticks
Write-Host 'arrA (ticks)	: ' ($ticksEnd - $ticksStart)

$ticksStart = (Get-Date).Ticks
for ($i = 0; $i -lt $max; $i++)
{
	$arrB = [System.Collections.ArrayList]@()
}
$ticksEnd = (Get-Date).Ticks
Write-Host  'arrB (ticks)	: ' ($ticksEnd - $ticksStart)
arrA (ticks)	:  64310000
arrB (ticks)	:  3170000
Discussions

How to create an ArrayList from an Array in PowerShell? - Stack Overflow
I've got a list of files in an array. I want to enumerate those files, and remove specific files from it. Obviously I can't remove items from an array, so I want to use an ArrayList. But the follow... More on stackoverflow.com
🌐 stackoverflow.com
Adding arrays to arraylists
I have an object which is of type {system.collections.arraylist] To add a single element I can use the Add method but to add an array I have to use the ‘+=’ method. Does anyone have a technical explanation for this as ‘+=’ doesnt seem to be in the microsoft doco below: I am also assuming ... More on forums.powershell.org
🌐 forums.powershell.org
7
0
July 11, 2022
Powershell ArrayList Formatting
I am trying to format a ‘System.Collections.ArrayList’ into an HTML table for emailing. I don’t really know where to begin so please tell me what information you require. Thank you More on community.spiceworks.com
🌐 community.spiceworks.com
19
3
March 29, 2017
ArrayList - C# vs Powershell - Is it the same thing or not?
Hello, So my question comes because I have heard different definitions of the ArrayList in C# and in Powershell and so I would like to understand this concept a little better. In Powershell an array can be declared as follows: $Array = @() And you can add elements to this array by using the ... More on forums.powershell.org
🌐 forums.powershell.org
0
0
November 1, 2016
🌐
Wit IT
witit.blog › array-vs-arraylist-powershell
Array vs ArrayList (PowerShell) - Wit IT
December 22, 2022 - So let’s say I only wanted to add files and folders with the word SETUP to an array. There are 2 files that contain the word Setup in the name. Before adding them to an Array or an ArrayList, let’s just count ’em and check 0 in the index:
🌐
PowerShell Forums
forums.powershell.org › powershell help
Adding arrays to arraylists - PowerShell Help - PowerShell Forums
July 11, 2022 - I have an object which is of type {system.collections.arraylist] To add a single element I can use the Add method but to add an array I have to use the ‘+=’ method. Does anyone have a technical explanation for this as ‘+=’ doesnt seem to be in the microsoft doco below: I am also assuming ...
🌐
Vexx32
vexx32.github.io › 2020 › 02 › 15 › Building-Arrays-Collections
Building Arrays and Collections in PowerShell
The main type of collection in use in PowerShell is the humble Array, at least in terms of what is often available directly from a script. Behind the murky curtain, PowerShell actually utilises the System.Collections.ArrayList type quite heavily in its pipeline processor.
Find elsewhere
🌐
SharePoint Diary
sharepointdiary.com › sharepoint diary › powershell › powershell tutorials › powershell arraylist – a beginners guide!
PowerShell ArrayList - A Beginners Guide! - SharePoint Diary
September 30, 2025 - The ArrayList is a generic List collection type found in the System.Collections.ArrayList class. You can store ordered collections of any object type, like strings, numbers, custom objects, etc. Unlike the traditional PowerShell array, ArrayList can grow and shrink dynamically, making it ideal for situations where the number of elements is not known in advance or needs to change over time.
🌐
Spiceworks
community.spiceworks.com › programming & development
Powershell ArrayList Formatting - #10 by craigduff - Programming & Development - Spiceworks Community
March 29, 2017 - $array=[System.Collections.ArrayList]@() $array.Add( (New-Object -TypeName PSObject -Property @{"Name" = "List";"Value"="Value"} ) ) $array.Add( (New-Object -TypeName PSObject -Property @{"Name" = "Workflow";"Value"="Value2"} ) ) $body = $array | ConvertTo-Html | Out-String $body Is it something like that, that you want?
🌐
Jamk
ttc2060.pages.labranet.jamk.fi › Powershell › 05-Arrays
Arrays and Hashtables - TTC2060 - Basics of Scripting and Automatization
Please, note that PowerShell commands return arrays. It is possible to get the element of array also with a property name.
🌐
LazyAdmin
lazyadmin.nl › home › how to use powershell array – complete guide
How to Use PowerShell Array - Complete Guide — LazyAdmin
January 19, 2023 - For this, we will need to use the PowerShell ArrayList, which is available in the ‘System.Collections.ArrayList’ class. The advantage of the ArrayList compared to the normal array is that we can add and remove items from the array, without the need of copying the array first.
🌐
Scriptwizards
scriptwizards.net › home › exploring powershell arrays: a comprehensive guide
Exploring PowerShell Arrays: A Comprehensive Guide - ScriptWizards.Net
June 13, 2024 - # Creating an ArrayList $arrayList ... an element $arrayList.Remove(2) # Display the array $arrayList · PowerShell arrays are powerful tools for managing collections of data....
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › scripting › lang-spec › chapter-09
Arrays - PowerShell | Microsoft Learn
March 24, 2025 - PowerShell supports arrays of one or more dimensions with each dimension having zero or more elements. Within a dimension, elements are numbered in ascending integer order starting at zero.
🌐
SPGuides
spguides.com › powershell-array
PowerShell Array - Complete Tutorial
May 6, 2025 - Using ArrayList provides better performance for frequently modified collections. Unlike standard PowerShell arrays, ArrayList is designed for efficient additions and removals.
🌐
Medium
medium.com › @oakhelloworld › powershell-collection-968226024f38
Powershell: Collection. PowerShell provides a variety of data… | by Oak HelloWorld | Medium
September 28, 2023 - $myArrayList = New-Object System.Collections.ArrayList $myArrayList.Add(“String”) $myArrayList.Add(123) 7. Dictionaries (Generic): PowerShell 7 introduced generic dictionaries, which are strongly typed and offer better performance when compared to hash tables.
🌐
Microsoft Certified Professional Magazine
mcpmag.com › articles › 2019 › 04 › 10 › managing-arrays-in-powershell.aspx
Managing Arrays in PowerShell -- Microsoft Certified Professional Magazine Online
PS C:\> $colorPicker = [System.Collections.ArrayList]@('blue','white','yellow','black') We now can use methods on this object to add and remove elements from the array without recreating it. Once we have an ... Remove() methods to add or remove items from the array. I'm using the term "array" loosely here. From now on, a PowerShell array and an object of type
🌐
PowerShell Gallery
powershellgallery.com › packages › ArrayList › 1.1.0 › Content › Public\New-ArrayList.ps1
PowerShell Gallery | Public/New-ArrayList.ps1 1.1.0
This site uses cookies for analytics, personalized content and ads. By continuing to browse this site, you agree to this use. Learn more · ArrayList · 1.1.0 · Public/New-ArrayList.ps1 · Contact Us · Terms of Use · Gallery Status · Feedback · © 2026 Microsoft Corporation
🌐
SPGuides
spguides.com › powershell-arraylist
PowerShell ArrayList [Create and Use]
March 26, 2025 - An ArrayList in PowerShell is a dynamic collection that allows you to store and manipulate a list of objects.
🌐
IDERA
idera.com › home › using efficient lists in powershell
Using Efficient Lists in PowerShell | IDERA
April 22, 2025 - Learn how to handle dynamic lists efficiently in PowerShell using System. Collections.ArrayList and generic lists instead of default object.
🌐
PowerShell Forums
forums.powershell.org › powershell help
ArrayList - C# vs Powershell - Is it the same thing or not? - PowerShell Help - PowerShell Forums
November 1, 2016 - Hello, So my question comes because I have heard different definitions of the ArrayList in C# and in Powershell and so I would like to understand this concept a little better. In Powershell an array can be declared as follows: $Array = @() And you can add elements to this array by using the += operator $Array=1 $Array+=2 $Array+=3 I used to use this method a lot, but then I heard that this method was costly because under the hood what is happening is that Powershell is actually copying all...
🌐
Spiceworks
community.spiceworks.com › programming & development
Powershell ArrayList Formatting - Programming & Development - Spiceworks Community
March 29, 2017 - I am trying to format a ‘System.Collections.ArrayList’ into an HTML table for emailing. I don’t really know where to begin so please tell me what information you require. Thank you