You can cast to void to ignore the return value from the Add method:

[void]$myArrayList.Add("test") 

Another option is to redirect to $null:

$myArrayList.Add("test") > $null
Answer from Keith Hill on Stack Overflow
Discussions

ArrayList.Add Method
Pretty sure you have a typo and you've written $table.Add instead of $tables.Add .. ? More on reddit.com
🌐 r/PowerShell
15
2
December 8, 2017
powershell - Add an array to an array list - Stack Overflow
OK, I am going to rephrase the question to be both more generic and more complete. But I am leaving the original post at the bottom. Given: a variable $queue, which I want to add different kinds and More on stackoverflow.com
🌐 stackoverflow.com
How to merge two ArrayList while keeping the Arraylist type?
Can't you just do? $Combined.AddRange($First) $Combined.AddRange($Second) More on reddit.com
🌐 r/PowerShell
2
9
December 14, 2017
Two ways of creating a new System.Collections.ArrayList object, what's the difference?
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). More on reddit.com
🌐 r/PowerShell
11
27
April 7, 2023
🌐
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 ...
🌐
Reddit
reddit.com › r/powershell › arraylist.add method
r/PowerShell on Reddit: ArrayList.Add Method
December 8, 2017 -

Hey guys

I am trying to add Table Objects into an ArrayList. This always worked but suddenly I am getting an error.

#create table class
class Table
{
    [String] $table_name
    [String] $content_type
    [String] $finishedOn  
}

I add the Table-Objects like this:

 $tables = New-Object System.Collections.ArrayList
 while ($reader.Read())
    {
        $table = New-Object Table
        $table.table_name = $reader["table_name"];
        $table.content_type = $reader["content_type"];
        $table.finishedOn = $LoadDate;
        [void]$tables.Add($table);
    }

The error I'm getting is:

System.Management.Automation.RuntimeException
Method invocation failed because [Table] does not contain a 
method named 'Add'.

I don't really get why PS gives me this error, since I'm using the Add-Method of the ArrayList, and am adding a Table-Object. As far as I know I don't need an add-Method for Table-Objects. Also it's very strange that I never got this error before while trying out my script, but now it's appearing every time.

Do I need to create an Add-Method for my Table-Class? And if so, how would I go about this?

EDIT: Fuck this. When I use Get-Member -InputObject $tables It sometimes tells me $tables is an array, sometimes it tells me it's an arraylist and sometimes it tells me it's a table. It's infuriating (though interesting). I'll try if I can pinpoint where it changes its object-type.

EDIT2: Thanks everyone! I'm really happy there is such a nice and active PowerShell community here on reddit. I hope I can come back to you if I got any other questions and as I'm learning more, hopefully I'll be able to answer some questions of other users! :)

🌐
SharePoint Diary
sharepointdiary.com › sharepoint diary › powershell › powershell tutorials › powershell arraylist – a beginners guide!
PowerShell ArrayList - A Beginners Guide! - SharePoint Diary
September 30, 2025 - This approach also works for AddRange() and Insert() if you want to keep things clean while adding multiple or specific elements. ... You can access elements just like a standard PowerShell array. ... This iterates through each element sequentially. You can also use a for loop with Count: ... For($i=0; $i -lt $Arraylist.Count; $i++) { # Do something with $element $element = $arraylist[$i] Write-host $Element }
🌐
Tachytelic
tachytelic.net › home › add items to a powershell array
Add items to a Powershell Array
September 4, 2019 - $names = New-Object System.Collections.ArrayList $names.Add("Paul") $names.Add("John") $names.Add("Simon") $names.Remove("Paul") This method makes it much easier to work with dynamically sized arrays. If you still require a standard PowerShell array you can do:
Find elsewhere
🌐
Learn Powershell
learn-powershell.net › 2014 › 09 › 21 › quick-hits-adding-items-to-an-array-and-a-look-at-performance
Quick Hits: Adding Items to an Array and a Look at Performance | Learn Powershell | Achieve More
September 23, 2014 - ... A late comment … it might be obvious, but it is not the data type but the operation which makes the difference.. you can declare a System.Collections.ArrayList and add items with += and the times are much the same as when you use += with ...
🌐
| How
pipe.how › new-arraylist
PowerShell Collections: ArrayList | How
January 17, 2020 - PipeHow:\Blog> $ArrayList = New-Object System.Collections.ArrayList PipeHow:\Blog> $ArrayList = [System.Collections.ArrayList]::new() One uses New-Object and the other calls the constructor of the class. You’re free to use whichever you prefer, although when sharing scripts it might be worth considering that people that are just getting into PowerShell and learning commands may be confused at the second one.
🌐
Netwrix
blog.netwrix.com › home › resources › how to use powershell arrays
How to Use PowerShell Arrays | Netwrix
December 13, 2024 - Now let’s use an ArrayList to remove an item from an array. First let’s create an array. $array5 = "one", "two", "three", "four", "five" $array5.gettype() Now we will add it to an ArrayList so we can easily modify it.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-add-remove-values-in-the-array-in-powershell
How to add/remove values in the array in PowerShell?
At line:1 char:1 + $array.Add("Hi") + ~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : NotSupportedException · This is because the array size is fixed. You can check if the array is a fixed size or not by using the below method. ... When you check the type of this array, it is an object, not the list. To deal with the above problem, we need to use System.Collection.ArrayList instead.
🌐
Stack Overflow
stackoverflow.com › questions › 61756527 › add-an-array-to-an-array-list
powershell - Add an array to an array list - Stack Overflow
The problem with Adamt8's answer is the implicit type coercion. The appended-to $arrList2 in his example becomes an Array, and you end up losing all the advantages of an ArrayList. The answer is <ArrayList>.addRange(<ICollection>).
🌐
YouTube
youtube.com › watch
PowerShell 7 Tutorial 7: Introduction to Array and ArrayList - YouTube
In our last two tutorials (Tutorial 5 and 6), we covered Variables in PowerShell. In this tutorial, I introduce you to Arrays and ArrayLists (or Array Lists)...
Published   February 20, 2023
🌐
PowerShell Test-Path
powershellfaqs.com › add-values-to-an-array-in-powershell
How to Add Values to an Array in PowerShell?
October 3, 2024 - By using either the += operator or the ArrayList class within a ForEach loop, you can efficiently add values to an array in PowerShell.
🌐
Reddit
reddit.com › r/powershell › how to merge two arraylist while keeping the arraylist type?
r/PowerShell on Reddit: How to merge two ArrayList while keeping the Arraylist type?
December 14, 2017 -

I have 2 Arraylists. What I want to do is to merge them, but whatever I do the combined arraylist gets wrapped into Object[].

It does not make sense for my current uderstanding on the topic.

$first = New-Object System.Collections.ArrayList($null)
$second = New-Object System.Collections.ArrayList($null)
$combined = New-Object System.Collections.ArrayList($null)

[void]$first.add("I")
[void]$first.add("want to join")
[void]$first.add("the first arraylist")
[void]$second.add("and the second arraylist")
[void]$second.add("together")

It gets wrapped into Object[]...

$combined.add($first)
$combined.add($second)

The same with this method:

$combined += $first
$combined += $second

I want to keep the original arraylist format and just add the elements within then into a 3rd arraylist. It's sad, but my google skills failed me...

I found many mentions of .AddAll method, but unfortunately it does not exist in PS :D

🌐
Wit IT
witit.blog › array-vs-arraylist-powershell
Array vs ArrayList (PowerShell) - Wit IT
December 22, 2022 - You add to it by using the Add() method (and remove using the Remove() method): style=”display:block” data-ad-client=”ca-pub-3397982927006466″ data-ad-slot=”6462285589″ data-ad-format=”auto” data-full-width-responsive=”true”> ...
🌐
The Tech Platform
thetechplatform.com › post › how-to-create-and-use-powershell-arraylist
How to create and use PowerShell ArrayList
May 18, 2023 - In this example, we added three string objects to the ArrayList $myArrayList. To access elements in an ArrayList, you can use the indexing operator []. ArrayLists in PowerShell are zero-indexed, meaning the first element is at index 0.
🌐
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
🌐
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