# Picking out a record in a DataTable

**URL:** <https://forums.powershell.org/t/picking-out-a-record-in-a-datatable/16376>\
**Category:** PowerShell Help\
**Created:** [April 29, 2021, 12:01pm UTC](https://forums.powershell.org/t/picking-out-a-record-in-a-datatable/16376 "2021-04-29T12:01:10Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [April 29, 2021, 4:14pm UTC](https://forums.powershell.org/t/picking-out-a-record-in-a-datatable/16376/5 "2021-04-29T16:14:32Z")

</div>

> [@cxmelga](#):
>
> The above is slow, I want to remove the ‘where’ and find the item in $B directly where the sAMAccountName matches a string (e.g. $item.UniqueID) without going through all the records each time in the loop

Did you try the code suggestion I gave in the other thread?

> [@Speeding up comparision of two CSV file imports](https://forums.powershell.org/t/speeding-up-comparision-of-two-csv-file-imports/16352/10):
>
> Why don’t you start with something easier to understand? wink smiley $A = import-csv c:\data\file1.csv $B = import-csv c:\data\file2.csv | Select-Object -Property \*, @{Name = 'Name'; Expression = { $\_.'here you should provide the property you want to compare' }} Compare-Object -ReferenceObject $A -DifferenceObject $B -Property Name -IncludeEqual -PassThru Assumed you have the data set with the property to compare with the name “Name” in the CSV file “file1.csv” and the data set with the…

---

_[View the full topic](https://forums.powershell.org/t/picking-out-a-record-in-a-datatable/16376)._
