I’m trying to compare an hashtable to multiple output from Pipeline, in he shortest way ( one line if possible).
Each output will contains at minimum same Property as Key in hashtable, but could have more Property that I don’t care.
An example ( not exactly what I need but for the idea ):
$hash = @{
Name = Name1
CreationTime = DateC1
LastWriteTime = DateW1
}
$Result = Get-Item -Path "Path to Check"
Output1 :
Name : Name1
CreationTime : DateC1
LastWriteTime : DateW1
Mode :
LinkType :
Target :
Output2 :
Name : Name1
CreationTime : DateC1
LastWriteTime : DateW2
Mode :
LinkType :
Target :
Output3 :
Name : Name1
CreationTime : DateC2
LastWriteTime : DateW1
Mode :
LinkType :
Target :
Output4 :
Name : Name2
CreationTime : DateC1
LastWriteTime : DateW1
Mode :
LinkType :
Target :
How to return only the first output that match hashtable ?
I tryed the basic way, compare each Property like :
Get-Item -Path "Path to Check" | ?{ ($_.Name -eq $hash.Name) -and ($_.CreationTime -eq $hash.CreationTime) -and ($_.LastWriteTime -eq $hash.LastWriteTime) }
But I think there must be other solutions, especially if there are more properties