[xml]$Weather = Get-Content "C:\Users\Morten\Downloads\GetMeasuredWeatherData.xml" $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 $LocationRoadTemp = ($Location.measuredValue | Where-Object {$_.index -eq "801"}).innertext $LocationPrecipitation = ($Location.measuredValue | Where-Object {$_.index -eq "2501"}).innertext + " mm/h" $Place = $place -replace "206","Lygna" -replace "207","Bekkehallum" $Resultname = [PSCustomObject][ordered]@{ Lokasjon = $place Lufttemperatur = $LocationAirTemp Veibanetemperatur = $LocationRoadTemp Nedbørintensitet = $LocationPrecipitation } $EndResult += $ResultName } $EndResult $fragments = @() $fragments+= "

Værstatistikk

" [xml]$html = $EndResult | convertto-html -Fragment for ($i=1;$i -le $html.table.tr.count-1;$i++) { if ([int]$html.table.tr[$i].td[1] -le 0) { $class = $html.CreateAttribute("class") $class.value = 'minus' $html.table.tr[$i].childnodes[1].attributes.append($class) #| out-null $html.table.tr[$i].childnodes[1].'#text' = ($html.table.tr[$i].childnodes[1].'#text') + " °C" } else { $class = $html.CreateAttribute("class") $class.value = 'pluss' $html.table.tr[$i].childnodes[2].attributes.append($class) #| out-null $html.table.tr[$i].childnodes[1].'#text' = ($html.table.tr[$i].childnodes[1].'#text') + " °C" } } for ($i=1;$i -le $html.table.tr.count-1;$i++) { if ([int]$html.table.tr[$i].td[2] -le 0) { $class = $html.CreateAttribute("class") $class.value = 'minus' $html.table.tr[$i].childnodes[2].attributes.append($class) #| out-null $html.table.tr[$i].childnodes[2].'#text' = ($html.table.tr[$i].childnodes[2].'#text') + " °C" } else { $class = $html.CreateAttribute("class") $class.value = 'pluss' $html.table.tr[$i].childnodes[2].attributes.append($class) #| out-null $html.table.tr[$i].childnodes[2].'#text' = ($html.table.tr[$i].childnodes[2].'#text') + " °C" } } $fragments += $html.InnerXml $fragments += "Here there be stuff, kanskje kamera?
Andre kameraer?" $fragments += "" $convertParams = @{ head = @" Mesta Værstatistikk "@ body = $fragments } convertto-html @convertParams | out-file c:\temp\mesta.html Write-host -fore Yellow "## Starting FTP upload.." $File = "C:\temp\mesta.html"; $ftp = "ftp://morten:redacted@web.home.zyrex.org//home/httpd/sites/zyrex.org/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);