[xml]$Weather = Get-Content "C:\Users\Morten\Downloads\GetMeasuredWeatherData.xml" $IDLygna = "206" $IDBekkehallum = "207" $EndResult = @() $IDs = "206","207" Foreach ($place in $IDs) { $Location = $Weather.d2LogicalModel.payloadPublication.siteMeasurements | Where-Object { $_.measurementsitereference.id -eq $place } $LocationPrecipitation = ($Location.measuredValue | Where-Object {$_.index -eq "2501"}).innertext + " mm/h" $Place = $place -replace "206","Lygna" -replace "207","Bekkehallum" $Resultname = new-object psobject -Property @{ Lokasjon = $place Lufttemperatur = $LocationAirTemp Veibanetemperatur = $LocationRoadTemp Nedbørintensitet = $LocationPrecipitation } $EndResult += $ResultName } $EndResult