Thursday, April 25, 2024
HomePowershellEvaluating two Objects with Evaluate-Object – SID-500.COM

Evaluating two Objects with Evaluate-Object – SID-500.COM


PowerShell

On this quick weblog publish, I’ll present you evaluate two PowerShell objects to search out variations between them. I may even offer you an instance on create objects for testing functions. Let’s dive in.

Creating Objects

First, I create two objects with the identical attribute names however totally different values.

# Tabelle 1
$tabelle1 = @()
$werte="1803",'1903','1609'
foreach ($w in $werte) {
$tabelle1 += New-Object -TypeName PSObject -Property (@{
    'Microsoft' = $w
})
}

# Tabelle 2
$tabelle2 = @()
$werte="1803",'1903'
foreach ($w in $werte) {
$tabelle2 += New-Object -TypeName PSObject -Property (@{
    'Microsoft' = $w
})
}

Now now we have two objects with totally different values, or extra exactly, one worth is totally different.

Evaluating Objects

Subsequent, we’ll begin evaluating these two objects to search out variations.

I’ll use the Evaluate-Object cmdlet for this sort of activity.

Evaluate-Object `
-ReferenceObject $Tabelle1 `
-DifferenceObject $Tabelle2  `
-PassThru

Honest sufficient. That’s it for as we speak. Comparability profitable.

Revealed by Patrick Gruenauer

Microsoft MVP on PowerShell [2018-2023], IT-Coach, IT-Advisor, MCSE: Cloud Platform and Infrastructure, Cisco Licensed Academy Teacher.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments