PowerShell/Scripts/open-dashboards.ps1

36 lines
1.1 KiB
PowerShell
Raw Normal View History

2023-03-19 19:07:59 +01:00
<#
.SYNOPSIS
Open dashboards
.DESCRIPTION
2023-06-09 09:38:14 +02:00
This PowerShell script launches the Web browser with tabs of popular dashboard websites.
2023-03-19 19:07:59 +01:00
.EXAMPLE
PS> ./open-dashboards
2023-06-01 12:23:20 +02:00
(1/2) Loading Data/popular-dashboards.csv...
2023-06-09 09:38:14 +02:00
(2/2) Launching Web browser with tabs: Toggl Track · Google Calendar · CNN World News...
2023-06-01 12:23:20 +02:00
...
2023-03-19 19:07:59 +01:00
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$stopWatch = [system.diagnostics.stopwatch]::startNew()
2023-05-20 09:53:24 +02:00
Write-Host "⏳ (1/2) Loading Data/popular-dashboards.csv..."
2023-06-09 09:38:14 +02:00
$table = Import-CSV "$PSScriptRoot/../Data/popular-dashboards.csv"
$numRows = $table.Length
Write-Host "⏳ (2/2) Launching Web browser with tabs: " -noNewline
foreach($row in $table) {
Write-Host "$($row.NAME) · " -noNewline
& "$PSScriptRoot/open-default-browser.ps1" "$($row.URL)"
2023-05-22 17:32:08 +02:00
Start-Sleep -milliseconds 50
2023-03-30 11:27:50 +02:00
}
2023-05-20 09:53:24 +02:00
Write-Host ""
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
2023-06-09 09:38:14 +02:00
"✅ Opened $NumRows dashboards in $elapsed sec (Hint: use switch-tabs.ps1 to switch between browser tabs automatically)"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}