PowerShell/Scripts/open-dashboards.ps1

34 lines
985 B
PowerShell
Raw Normal View History

2023-03-19 19:07:59 +01:00
<#
.SYNOPSIS
Open dashboards
.DESCRIPTION
This PowerShell script launches the Web browser with some dashboard websites.
.EXAMPLE
PS> ./open-dashboards
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
$stopWatch = [system.diagnostics.stopwatch]::startNew()
2023-04-07 19:24:35 +02:00
Write-Progress "⏳ Loading Data/popular-dashboards.csv..."
2023-04-07 19:13:13 +02:00
$Table = Import-CSV "$PSScriptRoot/../Data/popular-dashboards.csv"
$NumRows = $Table.Length
foreach($Row in $Table) {
2023-04-07 19:24:35 +02:00
$Name = $Row.NAME
$URL = $Row.URL
Write-Progress "⏳ Opening $Name in your browser..."
& "$PSScriptRoot/open-default-browser.ps1" "$URL"
2023-03-30 11:27:50 +02:00
Start-Sleep -milliseconds 100
}
2023-04-07 19:24:35 +02:00
Write-Progress -completed "."
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
2023-04-07 19:13:13 +02:00
"✅ Opened $NumRows Web dashboards in $elapsed sec (use switch-tabs.ps1 to switch the tabs automatically)"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}