Added open-URL.ps1

This commit is contained in:
Markus Fleschutz 2024-05-29 18:13:34 +02:00
parent b3630a67c0
commit e447641434
2 changed files with 28 additions and 4 deletions

24
scripts/open-URL.ps1 Normal file
View File

@ -0,0 +1,24 @@
<#
.SYNOPSIS
Opens the default browser
.DESCRIPTION
This PowerShell script launches the default Web browser, optional with a given URL.
.PARAMETER URL
Specifies the URL
.EXAMPLE
PS> ./open-default-browser
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$URL = "http://www.fleschutz.de")
try {
Start-Process $URL
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}

View File

@ -1,12 +1,12 @@
try { try {
& "$PSScriptRoot/open-default-browser.ps1" "https://docs.microsoft.com/en-us/powershell" & "$PSScriptRoot/open-URL.ps1" "https://docs.microsoft.com/en-us/powershell"
Start-Sleep -milliseconds 100 Start-Sleep -milliseconds 100
& "$PSScriptRoot/open-default-browser.ps1" "https://github.com/fleschutz/PowerShell/blob/main/docs/FAQ.md" & "$PSScriptRoot/open-URL.ps1" "https://github.com/fleschutz/PowerShell/blob/main/docs/FAQ.md"
Start-Sleep -milliseconds 100 Start-Sleep -milliseconds 100
& "$PSScriptRoot/open-default-browser.ps1" "https://github.com/fleschutz/PowerShell/blob/main/docs/cheat-sheet.md" & "$PSScriptRoot/open-URL.ps1" "https://github.com/fleschutz/PowerShell/blob/main/docs/cheat-sheet.md"
& "$PSScriptRoot/write-typewriter.ps1" "DON'T PANIC and check your brower tabs..." & "$PSScriptRoot/write-typewriter.ps1" "DON'T PANIC and check the new brower tabs..."
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"