Updated open-URL.ps1 and open-help.ps1

This commit is contained in:
Markus Fleschutz
2024-06-18 09:19:46 +02:00
parent 12e55dca97
commit b218b25be1
2 changed files with 35 additions and 7 deletions

View File

@ -5,6 +5,8 @@
This PowerShell script launches a new tab in the default Web browser with the given URL.
.PARAMETER URL
Specifies the URL
.PARAMETER text
Specifies the text to write to the console
.EXAMPLE
PS> ./open-URL.ps1 https://cnn.com
.LINK
@ -13,11 +15,17 @@
Author: Markus Fleschutz | License: CC0
#>
param([string]$URL = "")
param([string]$URL = "", [string]$text = "")
try {
if ($URL -eq "") { $URL = Read-Host "Enter the URL" }
if ($text -ne "") {
Write-Host $text -noNewline
Write-Host $URL -foregroundColor blue
}
Start-Process $URL
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"