# Compare a .csv list of computer names against what's present in Azure

**URL:** <https://forums.powershell.org/t/compare-a-csv-list-of-computer-names-against-whats-present-in-azure/22861>\
**Category:** PowerShell Help\
**Created:** [September 8, 2023, 8:05pm UTC](https://forums.powershell.org/t/compare-a-csv-list-of-computer-names-against-whats-present-in-azure/22861 "2023-09-08T20:05:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bacjac38](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@bacjac38](https://forums.powershell.org/u/bacjac38)\
**Post date:** [September 8, 2023, 8:05pm UTC](https://forums.powershell.org/t/compare-a-csv-list-of-computer-names-against-whats-present-in-azure/22861/1 "2023-09-08T20:05:07Z")

</div>

I have a list of computers in a .csv file (over 200) from our local AD and want to compare it to current Azure devices if they are present and export the result as a csv file

Using $list = Import-csv - I’m not sure how to compare it to and active Azure device list and never used the Compare-Object cmdlet. Any assistance would be appreciated - thanks in advance

---

<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:** [September 8, 2023, 8:33pm UTC](https://forums.powershell.org/t/compare-a-csv-list-of-computer-names-against-whats-present-in-azure/22861/2 "2023-09-08T20:33:05Z")

</div>

What have you tried so far? Please show your code. I assume `$list = Import-csv` is not all you have. 😉

A general recommendation: You should always read the help for the cmdlets you’re about to use COMPLETELY INCLUDING THE EXAMPLES to learn how to use them:

> **[Compare-Object (Microsoft.PowerShell.Utility) - PowerShell](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/compare-object?view=powershell-7.3)**
>
> The Compare-Object cmdlet compares two sets of objects. One set of objects is the reference, and the other set of objects is the difference. Compare-Object checks for available methods of comparing a whole object. If it can't find a suitable method,...

---

<div class="post-metadata">

**Author:** ![bacjac38](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@bacjac38](https://forums.powershell.org/u/bacjac38)\
**Post date:** [September 11, 2023, 11:57am UTC](https://forums.powershell.org/t/compare-a-csv-list-of-computer-names-against-whats-present-in-azure/22861/3 "2023-09-11T11:57:12Z")

</div>

```auto
$File1 = Import-Csv -Path "C:\AD.csv"
$File2 = Import-Csv -Path "C:\Azure.csv"
 
$Results = Compare-Object $File1 $File2 -Property computer -IncludeEqual
 
$Array = @()       
Foreach($R in $Results)
{
    If( $R.sideindicator -eq "==" )
    {
        $Object = [pscustomobject][ordered] @{
 
            Computer = $R.computer
            "Compare indicator" = $R.sideindicator
 
        }
        $Array += $Object
    }
}
 
($Array | sort-object computer | Select-Object * -Unique).count
 
$Array

```

---

<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:** [September 11, 2023, 12:26pm UTC](https://forums.powershell.org/t/compare-a-csv-list-of-computer-names-against-whats-present-in-azure/22861/4 "2023-09-11T12:26:49Z")

</div>

You did not share any sample data from the input files.

But apart from the fact that I don’t understand why you need a loop - what’s the issue? What’s your question?

---

<div class="post-metadata">

**Author:** ![bacjac38](https://avatars.discourse-cdn.com/v4/letter/b/9dc877/32.png) [@bacjac38](https://forums.powershell.org/u/bacjac38)\
**Post date:** [September 11, 2023, 12:36pm UTC](https://forums.powershell.org/t/compare-a-csv-list-of-computer-names-against-whats-present-in-azure/22861/5 "2023-09-11T12:36:15Z")

</div>

Thank you for your responses. Have a nice day.

---

<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:** [September 11, 2023, 1:04pm UTC](https://forums.powershell.org/t/compare-a-csv-list-of-computer-names-against-whats-present-in-azure/22861/6 "2023-09-11T13:04:57Z")

</div>

I don’t get it. 🤷🏼‍♂️

Did you solve your isssue? 🤔

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:14pm UTC](https://forums.powershell.org/t/compare-a-csv-list-of-computer-names-against-whats-present-in-azure/22861/7 "2024-05-16T20:14:40Z")

</div>


