try Something like this:

Copy$array1=import-csv "C:\temp\log.csv"
$array2=import-csv "C:\temp\log2.csv"

#modify founded and output not founded
$toadd=$array2 | %{
$current=$_
$founded=$array1 | where pc -eq $current.pc | %{$_.date=$current.date;$_}

    if ($founded -eq $null)
    {
      $current.city='UNKNOW' 
      $current 
    }
}

#output of $array1 modified and elements to add
$array1, $toadd
Answer from Esperento57 on Stack Overflow
🌐
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 code will check if the ArrayList contains the element “apple” and print a message if it does. You can easily convert between ArrayList and standard PowerShell arrays:
🌐
Microsoft
devblogs.microsoft.com › dev blogs › scripting blog [archived] › powertip: does powershell array contain a value?
PowerTip: Does PowerShell Array Contain a Value? - Scripting Blog [archived]
June 8, 2014 - Summary: Learn how to verify if a Windows PowerShell array contains a value. I have an array that contains various numbers and I want to see if one of the array elements contains a specific number. Is there an easy way to use Windows PowerShell so I don’t have to […]
🌐
Itechguides
itechguides.com › home › technology explained › windows powershell explained › powershell -contains operator and .contains() method explained
PowerShell -Contains Operator and .Contains() Method Explained - Itechguides
March 21, 2024 - I want to check if any two substrings are on the array list. If any of the substrings exists in the array list (string), PowerShell will return True, otherwise, it returns False. $ArrayList1.Contains("Document") -or $ArrayList1.Contains("Bin")
🌐
Varonis
varonis.com › blog › powershell-array
PowerShell Array Guide: How to Use and Create
June 9, 2022 - Arrays in PowerShell can contain one or more items. An item can be a string, an integer, an object, or even another array, and one array can contain any combination of these items.
Top answer
1 of 2
2

try Something like this:

Copy$array1=import-csv "C:\temp\log.csv"
$array2=import-csv "C:\temp\log2.csv"

#modify founded and output not founded
$toadd=$array2 | %{
$current=$_
$founded=$array1 | where pc -eq $current.pc | %{$_.date=$current.date;$_}

    if ($founded -eq $null)
    {
      $current.city='UNKNOW' 
      $current 
    }
}

#output of $array1 modified and elements to add
$array1, $toadd
2 of 2
0

Here is a sample I created that might help. Note: I use List types instead of ArrayList ones. Also, it assumes only one possible matching PC name in the data to be updated. You'll have to alter it to update the file since it merely updates the first List variable. Let me know how it goes.

Copy[PSCustomObject]
{
[string] $pc,
[string] $name,
[string] $date,
[string] $city
}

[System.Collections.Generic.List[PSCustomObject]] $list1 = Import-Csv "C:\SOSamples\log.csv";
[System.Collections.Generic.List[PSCustomObject]] $list2 = Import-Csv "C:\SOSamples\log2.csv";
[PSCustomObject] $record = $null;
[PSCustomObject] $match = $null;

foreach($record in $list2)
{
    # NOTE: This only retrieves the FIRST MATCHING item using a CASE-INSENSITIVE comparison       
    $match = $list1 | Where { $_.pc.ToLower() -eq $record.pc.ToLower() } | Select -First 1;

    if($match -eq $null)
    {
        Write-Host "Not Found!";
        $list1.Add($record);
    }
    else 
    {
        Write-Host "Found!";
        $match.date = $record.date;
    }
}

Write-Host "--------------------------------------------------------------------"

foreach($record in $list1)
{
    Write-Host $record
}
🌐
LazyAdmin
lazyadmin.nl › home › powershell array contains explained
PowerShell Array Contains Explained — LazyAdmin
October 16, 2024 - To check if a value exists in an array, we can use the -Contains operator in PowerShell. This will return return true if the value exists.
🌐
SPGuides
spguides.com › powershell-arraylist
PowerShell ArrayList [Create and Use] – Learn SharePoint, Microsoft Power Platform and SPFx Tutorials – SPGuides
December 6, 2024 - Let’s remove “Florida” from ... contains only “California” and “Texas”. To check if an element exists in an ArrayList, you can use the Contains() method....
🌐
PowerShell Test-Path
powershellfaqs.com › array-contains-in-powershell
Array Contains in PowerShell [With Examples]
February 14, 2025 - Learn how to check if an array contains a value in PowerShell with examples. Follow simple steps to use the -contains operator and streamline your data handling.
Find elsewhere
🌐
Powershell Commands
powershellcommands.com › powershell-array-list
Mastering PowerShell Array List: A Quick Guide
June 14, 2024 - if ($arrayList.Contains("Second Item")) { Write-Host "Item found!" } This checks if "Second Item" exists in the list and prints a message accordingly. If you need a regular array instead of an array list, PowerShell allows you to convert it seamlessly:
🌐
| How
pipe.how › new-arraylist
PowerShell Collections: ArrayList | How
January 17, 2020 - The collection on today’s topic is however not strongly typed, and therefore it can inherently contain anything. Diving a little deeper, we saw earlier that ArrayList inherits directly from System.Object while Object[] had System.Array as it’s base type.
🌐
SharePoint Diary
sharepointdiary.com › sharepoint diary › powershell › how to use powershell “contains” – a quick guide!
How to use PowerShell "Contains" - A Quick Guide! - SharePoint Diary
August 8, 2025 - The Contains method in PowerShell helps you see if a specified string or character exists within a string. The PowerShell operator -Contains lets you check if a collection of objects, such as an array, contains a specific object or value.
🌐
Adam the Automator
adamtheautomator.com › powershell-array
PowerShell Arrays, ArrayLists & Collections: Best Practices
Below you can see that you need to explicitly create an ArrayList object using the New-Object cmdlet or by casting a standard array to an ArrayList object. Notice that in this case the BaseType is an object whereas the above examples have BaseTypes of Arrays which exhibit inheritance from the Object class. Ultimately, PowerShell is providing access to the .NET type system.
Published   April 22, 2025
🌐
EDUCBA
educba.com › home › data science › data science tutorials › powershell tutorial › powershell array of strings
PowerShell Array of Strings | Guide to PowerShell Array of Strings
May 19, 2023 - New-Object -TypeName ... $arrlist.Add("PowerCLI") $arrlist.Add("DevOps") ... We must use the Contains() method to check if the string array contains any specific string....
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Computer Performance
computerperformance.co.uk › home › powershell
PowerShell Basics -Contains, -CContains & -NotContains | Code Examples
January 21, 2019 - A feature of -Contains is that usually returns “True” or “False. If you are looking for a command to return a list of values, then employ -Match or -Like. # PowerShell -Contains Operator Clear-Host $ArraySimple =@("House","Flat","Bungalow") $ArraySimple -Contains "Flat" # Result PS> True
🌐
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
July 20, 2024 - By default, an array in PowerShell is created as a [psobject[]] type. This allows it to contain any type of object or value.
🌐
Powershellexplained
powershellexplained.com › 2018-10-15-Powershell-arrays-Everything-you-wanted-to-know
Everything you wanted to know about arrays - Powershell
October 15, 2018 - Unlike the ArrayList, there is no return value on the Add method so we don’t have to void it. ... And we can still access the elements like other arrays. ... You can have a list of any type, but when you don’t know the type of objects, you can use [List[PSObject]] to contain them.
🌐
Java2Blog
java2blog.com › home › powershell › powershell array › check if array contains element in powershell
Check if Array Contains Element in PowerShell [5 Ways] - Java2Blog
November 21, 2023 - In this article, we will see different ways to check if array contains element in PowerShell using -contains operator, Contains() method, Where-Object cmdlet,
🌐
SS64
ss64.com › ps › syntax-arrays.html
Create and use PowerShell Arrays
A PowerShell array holds a list of data items. The data elements of a PowerShell array need not be of the same type, unless the data type is declared (strongly typed). To create an Array just separate the elements with commas. Create an array named $myArray containing elements with a mix of ...
🌐
PowerShell Forums
forums.powershell.org › powershell help
System.Collection.Arraylists containing objects - PowerShell Help - PowerShell Forums
December 31, 2011 - by Lembasts at 2013-02-13 15:14:49 Greetings, Having been persuaded to use the system.collections.arraylist class instead of boring old arrays, I had a look at the methods and was wondering how to use some of these when your arraylist contains objects. For example, how do I sort on a property ...
🌐
Reddit
reddit.com › r/powershell › how to check if an array contains a string (exact match)
How to check if an array contains a string (exact match) : r/PowerShell
September 4, 2020 - $TestArray = ( 'one two three', 'four five six seven', 'eight nine ten' ) $TestArray -eq 'one two three' $TestArray -contains 'one two three' $TestArray -contains 'One Two Three' $TestArray -ccontains 'One Two Three' '' $TestArray -eq 'five six' $TestArray -contains 'five six'