Open-Url
Opens an URL in the default browser
#requires -version 5.1
param([string]$URL = "", [string]$text = "")
try {
if ($URL -eq "") { $URL = Read-Host "Enter the URL" }
if ($IsLinux -or $IsMacOS) {
Write-Host $text -noNewline
Write-Host $URL -foregroundColor blue -noNewline
Write-Host " (open link with: <Ctrl> <click>)"
} else {
Start-Process $URL
Write-Host "? Launching Web browser with $text" -noNewline
Write-Host $URL -foregroundColor blue
}
exit 0 # success
} catch {
"?? ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
exit 1
}Specifies the URL
Specifies the text to write to the console