mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 21:07:40 +02:00
Updated open-URL.ps1
This commit is contained in:
@ -1,24 +1,25 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Opens the default browser
|
||||
Opens an URL in the default browser
|
||||
.DESCRIPTION
|
||||
This PowerShell script launches the default Web browser, optional with a given URL.
|
||||
This PowerShell script launches a new tab in the default Web browser with the given URL.
|
||||
.PARAMETER URL
|
||||
Specifies the URL
|
||||
.EXAMPLE
|
||||
PS> ./open-default-browser
|
||||
PS> ./open-URL.ps1 https://cnn.com
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$URL = "http://www.fleschutz.de")
|
||||
param([string]$URL = "")
|
||||
|
||||
try {
|
||||
if ($URL -eq "") { $URL = Read-Host "Enter the URL" }
|
||||
Start-Process $URL
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ Error: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
|
||||
exit 1
|
||||
}
|
||||
|
Reference in New Issue
Block a user