Function returns the employee name and 3 dates, one for each last site visit. I need to show the name along with whichever date is the most recent of the 3.
$results = get-SiteVisits -Properties Name,Site1,Site2,Site3
$results | ForEach-Object {$_ | Select-Object -Property *, @{Name='MaxValue';Expression={($_.PSObject.Properties.Value | Measure-Object -Maximum).Maximum}}}
What I am looking for...
Name : MARTHA
Site1 : 4/24/2023
Site2 : 4/23/2023
Site3 : 4/25/2023
MaxValue : 4/25/2023
Name : JOHN
Site1 : 4/18/2023
Site2 : 4/24/2023
Site3 : 4/21/2023
MaxValue : 4/24/2023
What I am getting...
Name : MARTHA
Site1 : 4/24/2023
Site2 : 4/23/2023
Site3 : 4/25/2023
MaxValue : MARTHA
Name : JOHN
Site1 : 4/18/2023
Site2 : 4/24/2023
Site3 : 4/21/2023
MaxValue : JOHN
How do I exclude the Name from the MaxValue expression, so I just get the most recent date?