[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 }
$LocationAirTemp = ($Location.measuredValue
| Where-Object {$_.index
-eq "101"}).innertext
+ " °C"
$LocationRoadTemp = ($Location.measuredValue
| Where-Object {$_.index
-eq "801"}).innertext
+ " °C"
$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
$a = "<style>"
$a = $a + "BODY{background-color:#FF8000;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:#408080}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}"
$a = $a + "</style>"
$a = $a + '<meta charset="UTF-8">'
$b = "<center>"
$b = $b + "<b><h2>Værstatistikk</b></h2>"
$code = $EndResult|ConvertTo-Html -Head $a -Body $b
$code | Out-File C:\temp\mesta.html
Write-host -fore Yellow "## Starting FTP upload.."
$File = "C:\temp\mesta.html";
$webclient = New-Object -TypeName System.Net.WebClient;
$uri = New-Object -TypeName System.Uri -ArgumentList $ftp;
Write-Host -fore Yellow "## Uploading $File...";
$webclient.UploadFile($uri, $File);