How can I get the Top 100 Uptime report to come out as a csv file instead of a pdf?
3 Replies
Unfortunately, it's not possible to create CSV reports for those, as they lack the necessary data files.
Kind regards,
Stephan Linke, Tech Support Team
I guess I must to do something like this:
$date = Get-Date $day = $date.DayOfWeek switch($day) { "Monday" { $dateModifier = -1 } "Tuesday" { $dateModifier = -2 } "Wednesday" { $dateModifier = -3 } "Thursday" { $dateModifier = -4 } "Friday" { $dateModifier = -5 } "Saturday" { $dateModifier = -6 } "Sunday" { $dateModifier = -7 } } [datetime]$previousSunday = (Get-Date).AddDays($dateModifier) $endstring = "$($previousSunday.Year)-$($previousSunday.Month)-$($previousSunday.Day)-23-59-00" $startstring = "$($previousSunday.AddDays(-7).Year)-$($previousSunday.AddDays(-7).Month)-$($previousSunday.AddDays(-7).Day)-00-00-00" $url = "https://myprtg/api/genreport.htm?id=93216&repstart=$startstring&repend=$endstring&$auth" Write-Host -ForegroundColor Cyan "VERBOSE: $url" $request = Invoke-WebRequest -Uri $url -MaximumRedirection 0 -ErrorAction Ignore $elements = $request.ParsedHtml.getElementsByTagName("td") $items = @() $i = 0 foreach($e in $elements) { $items += ($elements[$i].innerText).TrimEnd() $i++ } $i = 1 $report = @() do { $report += [PSCustomObject]@{ Sensor = $items[(($i * 12) - 10)] Device = $items[(($i * 12) - 9)] Group = $items[(($i * 12) - 8)] "Uptime %" = $items[(($i * 12) - 7)] "Uptime T" = $items[(($i * 12) - 6)] "Downtime %" = $items[(($i * 12) - 4)] "Downtime T" = $items[(($i * 12) - 3)] } $i++ }until($i -eq ((($items.Count)-2)/12)) $report | Export-Csv
Created on Jun 5, 2018 3:49:50 PM by
Matthew Lawson
(180)
●2
●1
Last change on Jun 5, 2018 6:36:11 PM by
Dariusz Gorka [Paessler Support]
If it returns what you need? :)
Kind regards,
Stephan Linke, Tech Support Team
Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.
Add comment