I have a case, where I want to remove a value (at index number 2) from an array and at the same time, I am converting weblinks in the array to the file names. I am using the following code, but it is not working. What I am doing wrong?
From Practical guide to PowerShell Arrays | Sam's Corner
"To remove the 4th and 8th array elements for example regardless of their values, we use an expression similar to:
$c = 0…($c.Length-1) | foreach { if ($PSItem -notin 3,7) { $c[$PSItem] } }
"
In your case, to remove the 2nd array element of the $FilePath1 array:
Thank you! Can you provide me a link where I can get more information about powershell Arraylist and how is different fro an Array. In which circumstances, which is preferable?
Here’s the docs in terms of .net and C#, but you can easily translate it to powershell. It’s good if you want to keep adding and subtracting individual elements. ArrayList Class (System.Collections) | Microsoft Docs For example, $error is an arraylist. And $error[0] is always the most recent one.