From e4476414342c03f56df8e1043b6a07a9f66cff5a Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Wed, 29 May 2024 18:13:34 +0200 Subject: [PATCH] Added open-URL.ps1 --- scripts/open-URL.ps1 | 24 ++++++++++++++++++++++++ scripts/open-help.ps1 | 8 ++++---- 2 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 scripts/open-URL.ps1 diff --git a/scripts/open-URL.ps1 b/scripts/open-URL.ps1 new file mode 100644 index 00000000..8b0e4028 --- /dev/null +++ b/scripts/open-URL.ps1 @@ -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 +} diff --git a/scripts/open-help.ps1 b/scripts/open-help.ps1 index c3519cbb..2b31c9d0 100644 --- a/scripts/open-help.ps1 +++ b/scripts/open-help.ps1 @@ -1,12 +1,12 @@ 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 - & "$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 - & "$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 } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"