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])"