It should only taky seconds Get-Content -Path .\netlogon.log | ForEach-Object { if ($_ -match 'NO_CLIENT_SITE:') { ($_ -split ' ')[-1] } } | Sort-Object -Unique Of course this code should run on the same machine where the log file is. Please do not access the log file … Answer from Olaf on forums.powershell.org
🌐
Reddit
reddit.com › r/powershell › has arraylist been deprecated?
r/PowerShell on Reddit: has ArrayList been deprecated?
November 23, 2016 -

howdy y'all,

i vaguely recall seeing a post in this subreddit some time back that said the ArrayList had been deprecated. now i can't find it. [blush] the only things that show up on a net search are a couple of posts aimed at C# from several years ago.

so, am i misremembering things again?

take care,
lee


-ps
found the reason ... but i don't really understand it. lookee ...
ArrayList vs List<> in C# - Stack Overflow

  • http://stackoverflow.com/questions/2309694/arraylist-vs-list-in-c-sharp
    lee-

🌐
| How
pipe.how › new-arraylist
PowerShell Collections: ArrayList | How
January 17, 2020 - Last time we took a look at the most basic type of collection in PowerShell, and explored how we could specify exactly what type of array we wanted. It turned out that arrays are extremely slow when modifying size, as they are actually static structures that need to be re-created every time we add an element. This post will look at the first alternative to arrays that one usually encounters: ArrayList. A disclaimer before diving into the ArrayList, however, is that it is deprecated and the recommendation from Microsoft is that it should not be used for any new development.
🌐
Stack Overflow
stackoverflow.com › questions › 78311235 › is-arraylist-old-and-should-never-be-use-if-it-is-what-should-i-use-instead-wi
powershell - Is ArrayList old and should never be use? If it is, what should I use instead with .Remove() method? - Stack Overflow
I want to push back a bit on this ... new Powershell users into the mindset that they should always use generics, and imho, that’s not necessarily a good thing as ArrayList is fine for a lot of scenarios… 2024-04-12T17:49:25.793Z+00:00 ... @mclayton I'm a new user and I've been told to never/avoid use Array List and use generic lists instead haha 2024-04-12T17:55:45.413Z+00:00 ... @mclayton to be fairt, that's what Microsoft itself says. For all purposes and intents they deprecated ArrayList ...
🌐
Reddit
reddit.com › r/powershell › when to use array vs array list vs list
r/PowerShell on Reddit: When to use array vs array list vs list
April 25, 2022 - An obvious example of this would be running a command like $Data = Get-ChildItem, a less obvious example would be the output from a loop: $Data = foreach ($Item in $Collection) or even an if/else statement $Data = if ($true) {"Hello"} else ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › scripting › learn › deep-dives › everything-about-arrays
Everything you wanted to know about arrays - PowerShell | Microsoft Learn
It's common to see people move to ArrayList from arrays. But it comes from a time where C# didn't have generic support. The ArrayList is deprecated in support for the generic List[]
🌐
Vexx32
vexx32.github.io › 2020 › 02 › 15 › Building-Arrays-Collections
Building Arrays and Collections in PowerShell
Oftentimes older blog posts or code examples will have ArrayList as their collection of choice. Personally, I've never liked using ArrayList directly. As I mentioned above, PowerShell uses it behind the scenes extensively — but I'd be willing to bet that if they had the time available, more than a few people on the PowerShell team would love to replace it with something more modern.
🌐
Wit IT
witit.blog › array-vs-arraylist-powershell
Array vs ArrayList (PowerShell) - Wit IT - witit
December 22, 2022 - So now that we know some of the key differences and a common way that ArrayLists can trip us up if you’re used to using Arrays, let’s talk efficiency. First, let’s build some data to test with. My WinSxS folder has 15k child items. For this example, let’s compare the speed of adding each name to an Array vs Arraylist using Measure-Command:
🌐
GitHub
github.com › PowerShell › PowerShell › issues › 17362
ArrayList is not accepted as a "Mandatory" parameter to a function if one of its elements is $null · Issue #17362 · PowerShell/PowerShell
May 17, 2022 - Refer to Differences between Windows PowerShell 5.1 and PowerShell. I found, after half an hour of pure confusion, that an instance of System.Collections.ArrayList is not accepted as a parameter that is marked as Mandatory if one of its elements is $null.
Author   PowerShell
Find elsewhere
🌐
Spiceworks
community.spiceworks.com › programming & development
PowerShell - modifying and comparing dates - #11 by gary-m-g - Programming & Development - Spiceworks Community
March 9, 2021 - Also, powershell - ArrayList .Add vs .AddRange vis-a-vis the Pipeline - Stack Overflow suggests ArrayList is deprecated. Instead, use generic.list
🌐
Stack Overflow
stackoverflow.com › questions › 61756527 › add-an-array-to-an-array-list
powershell - Add an array to an array list - Stack Overflow
The examples I have seen all mention List only. Well, or they mention [arralylist], which I hear is deprecated, so I am trying to avoid that too. ... If $list is an ArrayLIst it doesn't matter - if, on the other hand $list is a generic collection, it'll generally accept any IEnumerable<T>, including flats arrays, so you can make due with $list.AddRange([string[]]$array), or if your don't know the type parameter: $list.AddRange($array -as "$($list.GetType().GenericTypeArguments[0])[]").
🌐
IDERA
idera.com › home › using efficient lists in powershell
Using Efficient Lists in PowerShell | IDERA
April 22, 2025 - And ArrayLists are not type-specific. They can store any data type which makes them flexible but not very efficient. Generic lists are so much better, and using them is just a matter of using a different type instead. For one, generic lists can be restricted to a given type, so they can store data in the most efficient way and provide type safety. Here is an example for a string list:
🌐
SPGuides
spguides.com › powershell-arraylist
PowerShell ArrayList [Create and Use] – Learn SharePoint, Microsoft Power Platform and SPFx Tutorials – SPGuides
December 6, 2024 - If you have an existing array and want to convert it to an ArrayList, you can use the AddRange() method. Here’s an example and the complete PowerShell:
🌐
Reddit
reddit.com › r/powershell › arraylist obsoletion -- do we care?
r/PowerShell on Reddit: ArrayList obsoletion -- do we care?
July 25, 2024 -

I'm fully aware that ArrayList is not recommended for new development. That being said, do you still use it when you are writing PowerShell? I wish I could add a Poll to solicit the responses more easily, but Poll option is greyed out.

I've been roasted for using it before, but it's just so much more familiar and convenient to instantiate, for me.

[System.Collections.ArrayList]$list = @()

Slim and sexy, concise, looks like other PS syntax I'm used to.

[System.Collections.Generic.List[object]]::new()

Newfangled, unwieldy, uses C# constructor, ugly. Requires me to think about what types I'll have in my list. Smug.

(Obviously I'm feeling a little silly here / tongue in cheek, but I really do feel like I just don't want to bother getting used to the new way.)

EDIT: Some of the advice is helpful, but mostly what I was hoping to find out was whether I'm alone or whether you all use ArrayList. It's kind of like, I know I'm supposed to drink 8 glasses of water today, but I have a suspicion that few people actually do. So that's why I'm asking.

FINAL EDIT: After seeing that most people don't use ArrayLists anymore, I think I'm going to learn Lists and do things properly. Turns out I'm in the minority, at least on this sub. Thanks for the discussion everyone.

🌐
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
🌐
Adam the Automator
adamtheautomator.com › powershell-array
PowerShell Arrays, ArrayLists & Collections: Best Practices
An example is shown below. ... Since an ArrayList isn’t fixed, you can remove elements from them using the Remove() method. This is one scenario in which using an ArrayList may benefit you if you plan to be frequently adding/removing items.
Published   April 22, 2025
🌐
PowerShell Test-Path
powershellfaqs.com › powershell-array-vs-arraylist
PowerShell Array vs ArrayList [Complete Guide]
February 3, 2024 - Understanding the differences and how to use each type effectively is crucial for writing efficient PowerShell scripts. In this post, we’ve covered the basics of arrays and ArrayLists, with examples to help beginners understand how to work with these collections.
🌐
ScriptRunner
scriptrunner.com › blog-admin-architect › powershell-array-types
Exploring PowerShell Array Types: A Comprehensive Guide
May 22, 2025 - The example above can now be rewritten to avoid using +=. Keep in mind that this example is meant to illustrate the issue; with just 10 iterations, as shown here, you could likely get away with using +=. However, remember the examples from the previous section where += would hang Windows PowerShell. Here is the rewritten example using a generic list: # new empty string array [System.Collections.Generic.List[string]]$names = [System.Collections.Generic.List[string]]::new() # let user enter 10 names for ($x=1; $x-le10;$x++) { $userinput = Read-Host -Prompt "Enter $x. Name" $names.Add($userinput) } $names.Count · Notice that generic lists do not return anything when you add new data. Unlike [System.Collections.ArrayList], there is no need to assign the result to $null this time.