From b97098fc42a93b01372ef5325f1cbecaf8d55a8c Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Thu, 15 Jul 2021 15:51:22 +0200 Subject: [PATCH] Add datatype to param() --- Scripts/MD5.ps1 | 5 +++-- Scripts/SHA1.ps1 | 5 +++-- Scripts/SHA256.ps1 | 5 +++-- Scripts/add-memo.ps1 | 2 +- Scripts/alert.ps1 | 8 +++----- Scripts/check-drive-space.ps1 | 2 +- Scripts/check-file-system.ps1 | 2 +- Scripts/check-ipv4-address.ps1 | 2 +- Scripts/check-ipv6-address.ps1 | 2 +- Scripts/check-mac-address.ps1 | 2 +- Scripts/check-symlinks.ps1 | 2 +- Scripts/check-weather.ps1 | 2 +- Scripts/check-xml-file.ps1 | 8 +++----- Scripts/cherry-picker.ps1 | 10 +++++----- Scripts/clean-repo.ps1 | 2 +- Scripts/clean-repos.ps1 | 2 +- Scripts/clone-repos.ps1 | 2 +- Scripts/close-program.ps1 | 18 +++++++++--------- Scripts/configure-git.ps1 | 9 +++++---- Scripts/convert-csv2txt.ps1 | 5 +++-- Scripts/convert-mysql2csv.ps1 | 13 +++++++------ Scripts/convert-ps2bat.ps1 | 5 +++-- Scripts/convert-sql2csv.ps1 | 13 +++++++------ Scripts/convert-txt2wav.ps1 | 7 ++++--- Scripts/create-branch.ps1 | 5 +++-- Scripts/create-shortcut.ps1 | 9 +++++---- Scripts/create-symlink.ps1 | 9 +++++---- Scripts/create-tag.ps1 | 5 +++-- Scripts/download-dir.ps1 | 5 +++-- Scripts/download-file.ps1 | 5 +++-- Scripts/edit.ps1 | 2 +- Scripts/encrypt-file.ps1 | 2 +- Scripts/fetch-repo.ps1 | 2 +- Scripts/fetch-repos.ps1 | 2 +- Scripts/generate-qrcode.ps1 | 7 ++++--- Scripts/inspect-exe.ps1 | 8 +++----- Scripts/install-signal-cli.ps1 | 5 +++-- Scripts/list-anagrams.ps1 | 2 +- Scripts/list-branches.ps1 | 2 +- Scripts/list-commits.ps1 | 2 +- Scripts/list-dir-tree.ps1 | 2 +- Scripts/list-dir.ps1 | 2 +- Scripts/list-empty-dirs.ps1 | 2 +- Scripts/list-empty-files.ps1 | 8 +++----- Scripts/list-files.ps1 | 5 +++-- Scripts/list-fritzbox-calls.ps1 | 3 ++- Scripts/list-fritzbox-devices.ps1 | 3 ++- Scripts/list-hidden-files.ps1 | 2 +- Scripts/list-latest-tag.ps1 | 2 +- Scripts/list-news.ps1 | 2 +- Scripts/list-os-updates.ps1 | 2 +- Scripts/list-submodules.ps1 | 2 +- Scripts/list-tags.ps1 | 2 +- Scripts/list-unused-files.ps1 | 2 +- Scripts/list-weather.ps1 | 2 +- Scripts/locate-city.ps1 | 5 +++-- Scripts/locate-ipaddress.ps1 | 5 +++-- Scripts/locate-zip-code.ps1 | 7 ++++--- Scripts/make-repo.ps1 | 2 +- Scripts/make-repos.ps1 | 2 +- Scripts/new-email.ps1 | 2 +- Scripts/open-browser.ps1 | 2 +- Scripts/play-files.ps1 | 2 +- Scripts/play-m3u.ps1 | 5 +++-- Scripts/play-mp3.ps1 | 5 +++-- Scripts/pull-repo.ps1 | 2 +- Scripts/pull-repos.ps1 | 2 +- Scripts/query-smart-data.ps1 | 2 +- Scripts/reboot-fritzbox.ps1 | 2 +- Scripts/remove-empty-dirs.ps1 | 5 +++-- Scripts/search-files.ps1 | 7 ++++--- Scripts/send-tcp.ps1 | 9 +++++---- Scripts/send-udp.ps1 | 9 +++++---- Scripts/set-timer.ps1 | 3 ++- Scripts/set-wallpaper.ps1 | 2 +- Scripts/simulate-presence.ps1 | 5 +++-- Scripts/smart-data2csv.ps1 | 2 +- Scripts/speak-checklist.ps1 | 5 +++-- Scripts/speak-english.ps1 | 5 +++-- Scripts/speak-epub.ps1 | 2 +- Scripts/speak-file.ps1 | 5 +++-- Scripts/speak-german.ps1 | 3 ++- Scripts/speak-text.ps1 | 5 +++-- Scripts/switch-branch.ps1 | 5 +++-- Scripts/switch-shelly1.ps1 | 9 +++++---- Scripts/sync-repo.ps1 | 2 +- Scripts/take-screenshot.ps1 | 2 +- Scripts/take-screenshots.ps1 | 2 +- Scripts/translate-file.ps1 | 10 +++++----- Scripts/translate-files.ps1 | 5 +++-- Scripts/translate-text.ps1 | 5 +++-- Scripts/upload-file.ps1 | 22 +++++++++++----------- Scripts/wakeup.ps1 | 7 ++++--- Scripts/weather-report.ps1 | 2 +- Scripts/weather.ps1 | 2 +- Scripts/what-is.ps1 | 5 +++-- Scripts/write-big.ps1 | 2 +- Scripts/write-blue.ps1 | 2 +- Scripts/write-braille.ps1 | 2 +- Scripts/write-green.ps1 | 3 ++- Scripts/write-lowercase.ps1 | 3 ++- Scripts/write-marquee.ps1 | 2 +- Scripts/write-morse-code.ps1 | 2 +- Scripts/write-red.ps1 | 1 + Scripts/write-rot13.ps1 | 2 +- Scripts/write-typewriter.ps1 | 2 +- Scripts/write-uppercase.ps1 | 3 ++- Scripts/write-vertical.ps1 | 5 +++-- Scripts/zip-dir.ps1 | 7 ++++--- 109 files changed, 256 insertions(+), 216 deletions(-) diff --git a/Scripts/MD5.ps1 b/Scripts/MD5.ps1 index acdeb4c5..97f7c776 100755 --- a/Scripts/MD5.ps1 +++ b/Scripts/MD5.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($File = "") -if ($File -eq "" ) { $File = read-host "Enter path to file" } +param([string]$File = "") try { + if ($File -eq "" ) { $File = read-host "Enter path to file" } + $Result = get-filehash $File -algorithm MD5 "MD5 hash is" $Result.Hash exit 0 diff --git a/Scripts/SHA1.ps1 b/Scripts/SHA1.ps1 index 237462a6..2dff3f98 100755 --- a/Scripts/SHA1.ps1 +++ b/Scripts/SHA1.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($File = "") -if ($File -eq "" ) { $File = read-host "Enter the filename" } +param([string]$File = "") try { + if ($File -eq "" ) { $File = read-host "Enter the filename" } + $Result = get-filehash $File -algorithm SHA1 write-output "SHA1 hash is" $Result.Hash exit 0 diff --git a/Scripts/SHA256.ps1 b/Scripts/SHA256.ps1 index 8e8e5235..44017076 100755 --- a/Scripts/SHA256.ps1 +++ b/Scripts/SHA256.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($File = "") -if ($File -eq "" ) { $File = read-host "Enter the filename" } +param([string]$File = "") try { + if ($File -eq "" ) { $File = read-host "Enter the filename" } + $Result = get-filehash $File -algorithm SHA256 write-output "SHA256 hash is:" $Result.Hash exit 0 diff --git a/Scripts/add-memo.ps1 b/Scripts/add-memo.ps1 index 5f66d6e4..b3811d12 100755 --- a/Scripts/add-memo.ps1 +++ b/Scripts/add-memo.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "") +param([string]$Text = "") if ($Text -eq "" ) { $Text = read-host "Enter the memo text to add" } try { diff --git a/Scripts/alert.ps1 b/Scripts/alert.ps1 index 56fd9ec3..4fe96d98 100755 --- a/Scripts/alert.ps1 +++ b/Scripts/alert.ps1 @@ -11,13 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($Message = "") - -if ($Message -eq "" ) { - $URL = read-host "Enter alert message" -} +param([string]$Message = "") try { + if ($Message -eq "" ) { $URL = read-host "Enter alert message" } + echo "ALERT: $Message" curl --header "Access-Token: o.PZl5XCp6SBl4F5PpaNXGDfFpUJZKAlEb" --header "Content-Type: application/json" --data-binary '{"type": "note", "title": "ALERT", "body": "$Message"}' --request POST https://api.pushbullet.com/v2/pushes diff --git a/Scripts/check-drive-space.ps1 b/Scripts/check-drive-space.ps1 index dc6a135b..8231398c 100755 --- a/Scripts/check-drive-space.ps1 +++ b/Scripts/check-drive-space.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Drive = "", [int]$MinLevel = 20) # minimum level in GB +param([string]$Drive = "", [int]$MinLevel = 20) # minimum level in GB if ($Drive -eq "" ) { $Drive = read-host "Enter drive to check" } diff --git a/Scripts/check-file-system.ps1 b/Scripts/check-file-system.ps1 index f1cec0aa..c6d6b1ac 100755 --- a/Scripts/check-file-system.ps1 +++ b/Scripts/check-file-system.ps1 @@ -13,7 +13,7 @@ #Requires -RunAsAdministrator -param($Drive = "") +param([string]$Drive = "") if ($Drive -eq "" ) { $Drive = read-host "Enter drive (letter) to check" diff --git a/Scripts/check-ipv4-address.ps1 b/Scripts/check-ipv4-address.ps1 index 31bbc3ec..5f5183a9 100755 --- a/Scripts/check-ipv4-address.ps1 +++ b/Scripts/check-ipv4-address.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Address = "") +param([string]$Address = "") function IsIPv4AddressValid { param([string]$IP) $RegEx = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" diff --git a/Scripts/check-ipv6-address.ps1 b/Scripts/check-ipv6-address.ps1 index 2e0c24c5..3e5c561f 100755 --- a/Scripts/check-ipv6-address.ps1 +++ b/Scripts/check-ipv6-address.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Address = "") +param([string]$Address = "") function IsIPv6AddressValid { param([string]$IP) $IPv4Regex = '(((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2}))' diff --git a/Scripts/check-mac-address.ps1 b/Scripts/check-mac-address.ps1 index ae421116..6eb46cd9 100755 --- a/Scripts/check-mac-address.ps1 +++ b/Scripts/check-mac-address.ps1 @@ -12,7 +12,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($MAC = "") +param([string]$MAC = "") function IsMACAddressValid { param([string]$mac) $RegEx = "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})|([0-9A-Fa-f]{2}){6}$" diff --git a/Scripts/check-symlinks.ps1 b/Scripts/check-symlinks.ps1 index f721637a..ae3ea695 100755 --- a/Scripts/check-symlinks.ps1 +++ b/Scripts/check-symlinks.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($DirTree = "") +param([string]$DirTree = "") if ($DirTree -eq "" ) { $DirTree = read-host "Enter the path to the directory tree" diff --git a/Scripts/check-weather.ps1 b/Scripts/check-weather.ps1 index 9ae83bfa..e7c80174 100755 --- a/Scripts/check-weather.ps1 +++ b/Scripts/check-weather.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Location = "") # empty means determine automatically +param([string]$Location = "") # empty means determine automatically function Check { param([int]$Value, [int]$NormalMin, [int]$NormalMax, [string]$Unit) if ($Value -lt $NormalMin) { diff --git a/Scripts/check-xml-file.ps1 b/Scripts/check-xml-file.ps1 index 6853677a..9bb5fbe0 100755 --- a/Scripts/check-xml-file.ps1 +++ b/Scripts/check-xml-file.ps1 @@ -11,13 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($File = "") - -if ($File -eq "" ) { - $File = read-host "Enter path to XML file" -} +param([string]$File = "") try { + if ($File -eq "" ) { $File = read-host "Enter path to XML file" } + $XmlFile = Get-Item $File $script:ErrorCount = 0 diff --git a/Scripts/cherry-picker.ps1 b/Scripts/cherry-picker.ps1 index 6e8a11c8..eb8a6294 100755 --- a/Scripts/cherry-picker.ps1 +++ b/Scripts/cherry-picker.ps1 @@ -11,13 +11,13 @@ Author: Markus Fleschutz / License: CC0 #> -param($CommitID = "", $CommitMessage = "", $Branches = "", $RepoDir = "$PWD") - -if ($CommitID -eq "" ) { $CommitID = read-host "Enter the commit id to cherry-pick" } -if ($CommitMessage -eq "" ) { $CommitMessage = read-host "Enter the commit message to use" } -if ($Branches -eq "" ) { $Branches = read-host "Enter the target branches separated by spaces" } +param([string]$CommitID = "", [string]$CommitMessage = "", [string]$Branches = "", [string]$RepoDir = "$PWD") try { + if ($CommitID -eq "") { $CommitID = read-host "Enter the commit id to cherry-pick" } + if ($CommitMessage -eq "") { $CommitMessage = read-host "Enter the commit message to use" } + if ($Branches -eq "") { $Branches = read-host "Enter the target branches separated by spaces" } + if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } set-location "$RepoDir" diff --git a/Scripts/clean-repo.ps1 b/Scripts/clean-repo.ps1 index 79569991..95fd04ec 100755 --- a/Scripts/clean-repo.ps1 +++ b/Scripts/clean-repo.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($RepoDir = "$PWD") +param([string]$RepoDir = "$PWD") try { $StopWatch = [system.diagnostics.stopwatch]::startNew() diff --git a/Scripts/clean-repos.ps1 b/Scripts/clean-repos.ps1 index bea2411b..d2d292a0 100755 --- a/Scripts/clean-repos.ps1 +++ b/Scripts/clean-repos.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($ParentDir = "$PWD") +param([string]$ParentDir = "$PWD") try { $StopWatch = [system.diagnostics.stopwatch]::startNew() diff --git a/Scripts/clone-repos.ps1 b/Scripts/clone-repos.ps1 index 4fece3e8..15bc1278 100755 --- a/Scripts/clone-repos.ps1 +++ b/Scripts/clone-repos.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($ParentDir = "$PWD") +param([string]$ParentDir = "$PWD") try { $StopWatch = [system.diagnostics.stopwatch]::startNew() diff --git a/Scripts/close-program.ps1 b/Scripts/close-program.ps1 index e063d262..257eff77 100755 --- a/Scripts/close-program.ps1 +++ b/Scripts/close-program.ps1 @@ -11,17 +11,17 @@ Author: Markus Fleschutz / License: CC0 #> -param($FullProgramName = "", $ProgramName = "", $ProgramAliasName = "") - -if ($ProgramName -eq "") { - get-process | where-object {$_.mainWindowTitle} | format-table Id, Name, mainWindowtitle -AutoSize - $ProgramName = read-host "Enter program name" -} -if ($FullProgramName -eq "") { - $FullProgramName = $ProgramName -} +param([string]$FullProgramName = "", [string]$ProgramName = "", [string]$ProgramAliasName = "") try { + if ($ProgramName -eq "") { + get-process | where-object {$_.mainWindowTitle} | format-table Id, Name, mainWindowtitle -AutoSize + $ProgramName = read-host "Enter program name" + } + if ($FullProgramName -eq "") { + $FullProgramName = $ProgramName + } + $Processes = get-process -name $ProgramName -errorAction 'silentlycontinue' if ($Processes.Count -ne 0) { foreach ($Process in $Processes) { diff --git a/Scripts/configure-git.ps1 b/Scripts/configure-git.ps1 index c6f6b75c..5ba56481 100755 --- a/Scripts/configure-git.ps1 +++ b/Scripts/configure-git.ps1 @@ -11,12 +11,13 @@ Author: Markus Fleschutz / License: CC0 #> -param($FullName = "", $EmailAddress = "", $FavoriteEditor = "") -if ($FullName -eq "") { $FullName = read-host "Enter your full name" } -if ($EmailAddress -eq "") { $EmailAddress = read-host "Enter your e-mail address"} -if ($FavoriteEditor -eq "") { $FavoriteEditor = read-host "Enter your favorite text editor (emacs,nano,vi,vim,...)" } +param([string]$FullName = "", [string]$EmailAddress = "", [string]$FavoriteEditor = "") try { + if ($FullName -eq "") { $FullName = read-host "Enter your full name" } + if ($EmailAddress -eq "") { $EmailAddress = read-host "Enter your e-mail address"} + if ($FavoriteEditor -eq "") { $FavoriteEditor = read-host "Enter your favorite text editor (emacs,nano,vi,vim,...)" } + $Null = (git --version) if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } diff --git a/Scripts/convert-csv2txt.ps1 b/Scripts/convert-csv2txt.ps1 index 2c8d735b..7393e6c6 100755 --- a/Scripts/convert-csv2txt.ps1 +++ b/Scripts/convert-csv2txt.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($Path = "") -if ($Path -eq "" ) { $Path = read-host "Enter path to CSV file" } +param([string]$Path = "") try { + if ($Path -eq "" ) { $Path = read-host "Enter path to CSV file" } + $Table = Import-CSV -path "$Path" -header A,B,C,D,E,F,G,H foreach($Row in $Table) { diff --git a/Scripts/convert-mysql2csv.ps1 b/Scripts/convert-mysql2csv.ps1 index 7dd7ff7e..28442a9d 100755 --- a/Scripts/convert-mysql2csv.ps1 +++ b/Scripts/convert-mysql2csv.ps1 @@ -12,14 +12,15 @@ #> -param($server = "", $database = "", $username = "", $password = "", $query = "") -if ($server -eq "") { $server = read-host "Enter the hostname/IP address of the MySQL server" } -if ($database -eq "") { $database = read-host "Enter the database name" } -if ($username -eq "") { $username = read-host "Enter the database username" } -if ($password -eq "") { $password = read-host "Enter the database user password" } -if ($query -eq "") { $query = read-host "Enter the database query" } +param([string]$server = "", [string]$database = "", [string]$username = "", [string]$password = "", [string]$query = "") try { + if ($server -eq "") { $server = read-host "Enter the hostname/IP address of the MySQL server" } + if ($database -eq "") { $database = read-host "Enter the database name" } + if ($username -eq "") { $username = read-host "Enter the database username" } + if ($password -eq "") { $password = read-host "Enter the database user password" } + if ($query -eq "") { $query = read-host "Enter the database query" } + $csvfilepath = "$PSScriptRoot\mysql_table.csv" $result = Invoke-MySqlQuery -ConnectionString "server=$server; database=$database; user=$username; password=$password; pooling = false; convert zero datetime=True" -Sql $query -CommandTimeout 10000 $result | Export-Csv $csvfilepath -NoTypeInformation diff --git a/Scripts/convert-ps2bat.ps1 b/Scripts/convert-ps2bat.ps1 index eaf28640..5bbe60a9 100644 --- a/Scripts/convert-ps2bat.ps1 +++ b/Scripts/convert-ps2bat.ps1 @@ -11,8 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Pattern = "") -if ($Pattern -eq "") { $Pattern = read-host "Enter path to the PowerShell script(s)" } +param([string]$Pattern = "") function Convert-PowerShellToBatch { @@ -33,6 +32,8 @@ function Convert-PowerShellToBatch } try { + if ($Pattern -eq "") { $Pattern = read-host "Enter path to the PowerShell script(s)" } + $Files = get-childItem -path "$Pattern" foreach ($File in $Files) { Convert-PowerShellToBatch "$File" diff --git a/Scripts/convert-sql2csv.ps1 b/Scripts/convert-sql2csv.ps1 index 025a381a..ad697b57 100755 --- a/Scripts/convert-sql2csv.ps1 +++ b/Scripts/convert-sql2csv.ps1 @@ -11,14 +11,15 @@ Author: Markus Fleschutz / License: CC0 #> -param($server = "", $database = "", $username = "", $password = "", $query = "") -if ($server -eq "") { $server = read-host "Enter the hostname/IP address of the SQL server" } -if ($database -eq "") { $database = read-host "Enter the database name" } -if ($username -eq "") { $username = read-host "Enter the database username" } -if ($password -eq "") { $password = read-host "Enter the database user password" } -if ($query -eq "") { $query = read-host "Enter the database query" } +param([string]$server = "", [string]$database = "", [string]$username = "", [string]$password = "", [string]$query = "") try { + if ($server -eq "") { $server = read-host "Enter the hostname/IP address of the SQL server" } + if ($database -eq "") { $database = read-host "Enter the database name" } + if ($username -eq "") { $username = read-host "Enter the database username" } + if ($password -eq "") { $password = read-host "Enter the database user password" } + if ($query -eq "") { $query = read-host "Enter the database query" } + $secpasswd = ConvertTo-SecureString $password -AsPlainText -Force $creds = New-Object System.Management.Automation.PSCredential ($username, $secpasswd) $csvfilepath = "$PSScriptRoot\sqlserver_table.csv" diff --git a/Scripts/convert-txt2wav.ps1 b/Scripts/convert-txt2wav.ps1 index 1ccc0ec2..64e3b028 100755 --- a/Scripts/convert-txt2wav.ps1 +++ b/Scripts/convert-txt2wav.ps1 @@ -11,11 +11,12 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "", $WavFile = "") -if ($Text -eq "") { $Text = read-host "Enter text to speak" } -if ($WavFile -eq "") { $WavFile = read-host "Enter .WAV file to save to" } +param([string]$Text = "", [string]$WavFile = "") try { + if ($Text -eq "") { $Text = read-host "Enter text to speak" } + if ($WavFile -eq "") { $WavFile = read-host "Enter .WAV file to save to" } + Add-Type -AssemblyName System.Speech $SpeechSynthesizer = New-Object System.Speech.Synthesis.SpeechSynthesizer $SpeechSynthesizer.SetOutputToWaveFile($tWavFile) diff --git a/Scripts/create-branch.ps1 b/Scripts/create-branch.ps1 index d9479928..3dbb48be 100755 --- a/Scripts/create-branch.ps1 +++ b/Scripts/create-branch.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($NewBranchName = "", $RepoDir = "$PWD") -if ($NewBranchName -eq "") { $NewBranchName = read-host "Enter new branch name" } +param([string]$NewBranchName = "", [string]$RepoDir = "$PWD") try { + if ($NewBranchName -eq "") { $NewBranchName = read-host "Enter new branch name" } + $StopWatch = [system.diagnostics.stopwatch]::startNew() if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } diff --git a/Scripts/create-shortcut.ps1 b/Scripts/create-shortcut.ps1 index 32d5d2b4..38e17732 100755 --- a/Scripts/create-shortcut.ps1 +++ b/Scripts/create-shortcut.ps1 @@ -11,12 +11,13 @@ Author: Markus Fleschutz / License: CC0 #> -param($Shortcut = "", $Target = "", $Description) -if ($Shortcut -eq "" ) { $Shortcut = read-host "Enter filename of shortcut" } -if ($Target -eq "" ) { $Target = read-host "Enter path to target" } -if ($Description -eq "" ) { $Description = read-host "Enter description" } +param([string]$Shortcut = "", [string]$Target = "", [string]$Description) try { + if ($Shortcut -eq "" ) { $Shortcut = read-host "Enter filename of shortcut" } + if ($Target -eq "" ) { $Target = read-host "Enter path to target" } + if ($Description -eq "" ) { $Description = read-host "Enter description" } + $sh = new-object -ComObject WScript.Shell $shortcut = $sh.CreateShortcut("$Shortcut.lnk") $shortcut.TargetPath = "$Target" diff --git a/Scripts/create-symlink.ps1 b/Scripts/create-symlink.ps1 index aeafed85..030263db 100755 --- a/Scripts/create-symlink.ps1 +++ b/Scripts/create-symlink.ps1 @@ -11,14 +11,15 @@ Author: Markus Fleschutz / License: CC0 #> -param($Symlink = "", $Target = "") -if ($Symlink -eq "" ) { $Symlink = read-host "Enter filename of symlink" } -if ($Target -eq "" ) { $Target = read-host "Enter path to target" } +param([string]$Symlink = "", $[string]Target = "") try { + if ($Symlink -eq "" ) { $Symlink = read-host "Enter filename of symlink" } + if ($Target -eq "" ) { $Target = read-host "Enter path to target" } + new-item -path "$Symlink" -itemType SymbolicLink -Value "$Target" - write-host -foregroundColor green "✔️ symlink $Symlink created (pointing to $Target)" + "✔️ created symlink $Symlink (pointing to $Target)" exit 0 } catch { write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/Scripts/create-tag.ps1 b/Scripts/create-tag.ps1 index 4779228c..86ec4e77 100755 --- a/Scripts/create-tag.ps1 +++ b/Scripts/create-tag.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($NewTagName = "", $RepoDir = "$PWD") -if ($NewTagName -eq "") { $NewTagName = read-host "Enter new tag name" } +param([string]$NewTagName = "", [string]$RepoDir = "$PWD") try { + if ($NewTagName -eq "") { $NewTagName = read-host "Enter new tag name" } + if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } set-location "$RepoDir" diff --git a/Scripts/download-dir.ps1 b/Scripts/download-dir.ps1 index 2d264144..6bba214c 100755 --- a/Scripts/download-dir.ps1 +++ b/Scripts/download-dir.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($URL = "") -if ($URL -eq "") { $URL = read-host "Enter directory URL to download" } +param([string]$URL = "") try { + if ($URL -eq "") { $URL = read-host "Enter directory URL to download" } + & wget --version if ($lastExitCode -ne "0") { throw "Can't execute 'wget' - make sure wget is installed and available" } diff --git a/Scripts/download-file.ps1 b/Scripts/download-file.ps1 index f759e822..5b331f8b 100755 --- a/Scripts/download-file.ps1 +++ b/Scripts/download-file.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($URL = "") -if ($URL -eq "") { $URL = read-host "Enter file URL to download" } +param([string]$URL = "") try { + if ($URL -eq "") { $URL = read-host "Enter file URL to download" } + & wget --version if ($lastExitCode -ne "0") { throw "Can't execute 'wget' - make sure wget is installed and available" } diff --git a/Scripts/edit.ps1 b/Scripts/edit.ps1 index 0f6d7ef4..4775a01d 100755 --- a/Scripts/edit.ps1 +++ b/Scripts/edit.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Filename = "") +param([string]$Filename = "") try { if ($IsLinux) { diff --git a/Scripts/encrypt-file.ps1 b/Scripts/encrypt-file.ps1 index 2ddb9b4b..5bd6d766 100755 --- a/Scripts/encrypt-file.ps1 +++ b/Scripts/encrypt-file.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Path = "", $Password = "") +param([string]$Path = "", [string]$Password = "") function EncryptFile { <# diff --git a/Scripts/fetch-repo.ps1 b/Scripts/fetch-repo.ps1 index adc3812e..5c34c650 100755 --- a/Scripts/fetch-repo.ps1 +++ b/Scripts/fetch-repo.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($RepoDir = "$PWD") +param([string]$RepoDir = "$PWD") try { if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } diff --git a/Scripts/fetch-repos.ps1 b/Scripts/fetch-repos.ps1 index 19699243..0223f7f7 100755 --- a/Scripts/fetch-repos.ps1 +++ b/Scripts/fetch-repos.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($ParentDir = "$PWD") +param([string]$ParentDir = "$PWD") try { $StopWatch = [system.diagnostics.stopwatch]::startNew() diff --git a/Scripts/generate-qrcode.ps1 b/Scripts/generate-qrcode.ps1 index 3c214f58..889b5366 100755 --- a/Scripts/generate-qrcode.ps1 +++ b/Scripts/generate-qrcode.ps1 @@ -11,11 +11,12 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "", $ImageSize = "") -if ($Text -eq "") { $Text = read-host "Enter text or URL" } -if ($ImageSize -eq "") { $ImageSize = read-host "Enter image size (e.g. 500x500)" } +param([string]$Text = "", [string]$ImageSize = "") try { + if ($Text -eq "") { $Text = read-host "Enter text or URL" } + if ($ImageSize -eq "") { $ImageSize = read-host "Enter image size (e.g. 500x500)" } + $ECC = "M" # can be L, M, Q, H $QuietZone = 1 $ForegroundColor = "000000" diff --git a/Scripts/inspect-exe.ps1 b/Scripts/inspect-exe.ps1 index 9c387780..4e57b763 100755 --- a/Scripts/inspect-exe.ps1 +++ b/Scripts/inspect-exe.ps1 @@ -11,13 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($PathToExe = "") - -if ($PathToExe -eq "" ) { - $PathToExe = read-host "Enter path to executable file" -} +param([string]$PathToExe = "") try { + if ($PathToExe -eq "" ) { $PathToExe = read-host "Enter path to executable file" } + get-childitem $PathToExe | % {$_.VersionInfo} | Select * exit 0 } catch { diff --git a/Scripts/install-signal-cli.ps1 b/Scripts/install-signal-cli.ps1 index c869ecd3..daddc02b 100755 --- a/Scripts/install-signal-cli.ps1 +++ b/Scripts/install-signal-cli.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($Version = "") -if ($Version -eq "") { $Version = read-host "Enter version to install (see https://github.com/AsamK/signal-cli)" } +param([string]$Version = "") try { + if ($Version -eq "") { $Version = read-host "Enter version to install (see https://github.com/AsamK/signal-cli)" } + $StopWatch = [system.diagnostics.stopwatch]::startNew() set-location /tmp diff --git a/Scripts/list-anagrams.ps1 b/Scripts/list-anagrams.ps1 index 97615863..09df75c0 100755 --- a/Scripts/list-anagrams.ps1 +++ b/Scripts/list-anagrams.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Word = "", [int]$Columns = 8) +param([string]$Word = "", [int]$Columns = 8) function GetPermutations { [cmdletbinding()] diff --git a/Scripts/list-branches.ps1 b/Scripts/list-branches.ps1 index 12e0c9b8..821c82fb 100755 --- a/Scripts/list-branches.ps1 +++ b/Scripts/list-branches.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($RepoDir = "$PWD", $Pattern = "*") +param([string]$RepoDir = "$PWD", [string]$Pattern = "*") try { if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } diff --git a/Scripts/list-commits.ps1 b/Scripts/list-commits.ps1 index 40b26218..aba017ac 100755 --- a/Scripts/list-commits.ps1 +++ b/Scripts/list-commits.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($RepoDir = "$PWD", $Format = "compact") +param([string]$RepoDir = "$PWD", [string]$Format = "compact") try { if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } diff --git a/Scripts/list-dir-tree.ps1 b/Scripts/list-dir-tree.ps1 index 43c0df58..a90b0d13 100755 --- a/Scripts/list-dir-tree.ps1 +++ b/Scripts/list-dir-tree.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($DirTree = "$PWD") +param([string]$DirTree = "$PWD") function ListDir { param([string]$Directory, [int]$Depth) $Depth++ diff --git a/Scripts/list-dir.ps1 b/Scripts/list-dir.ps1 index ed67bbe1..d7fa3267 100755 --- a/Scripts/list-dir.ps1 +++ b/Scripts/list-dir.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Pattern = "*") +param([string]$Pattern = "*") function ListDir { param([string]$Pattern) $Items = get-childItem -path "$Pattern" diff --git a/Scripts/list-empty-dirs.ps1 b/Scripts/list-empty-dirs.ps1 index b30e69bf..cb8a0a5e 100755 --- a/Scripts/list-empty-dirs.ps1 +++ b/Scripts/list-empty-dirs.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($DirTree = "$PWD") +param([string]$DirTree = "$PWD") try { $DirTree = resolve-path "$DirTree/" diff --git a/Scripts/list-empty-files.ps1 b/Scripts/list-empty-files.ps1 index 1bf1227a..77806c89 100755 --- a/Scripts/list-empty-files.ps1 +++ b/Scripts/list-empty-files.ps1 @@ -11,13 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($DirTree = "") - -if ($DirTree -eq "" ) { - $DirTree = read-host "Enter the path to the directory tree" -} +param([string]$DirTree = "") try { + if ($DirTree -eq "" ) { $DirTree = read-host "Enter the path to the directory tree" } + [int]$Count = 0 write-progress "Listing empty files in $DirTree ..." get-childItem $DirTree -attributes !Directory -recurse | where {$_.Length -eq 0} | foreach-object { diff --git a/Scripts/list-files.ps1 b/Scripts/list-files.ps1 index b6773ea2..c830135d 100755 --- a/Scripts/list-files.ps1 +++ b/Scripts/list-files.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($DirTree = "") -if ($DirTree -eq "" ) { $DirTree = read-host "Enter path to directory tree" } +param([string]$DirTree = "") try { + if ($DirTree -eq "" ) { $DirTree = read-host "Enter path to directory tree" } + Get-ChildItem -path $DirTree -recurse | select FullName exit 0 } catch { diff --git a/Scripts/list-fritzbox-calls.ps1 b/Scripts/list-fritzbox-calls.ps1 index fed69697..47c213f7 100755 --- a/Scripts/list-fritzbox-calls.ps1 +++ b/Scripts/list-fritzbox-calls.ps1 @@ -13,7 +13,8 @@ #Requires -Version 3 -param($Username = "", $Password = "") +param([string]$Username = "", [string]$Password = "") + if ($Username -eq "") { $Username = read-host "Enter username for FRITZ!Box" } if ($Password -eq "") { $Password = read-host "Enter password for FRITZ!Box" } diff --git a/Scripts/list-fritzbox-devices.ps1 b/Scripts/list-fritzbox-devices.ps1 index 87efd958..a52587c8 100755 --- a/Scripts/list-fritzbox-devices.ps1 +++ b/Scripts/list-fritzbox-devices.ps1 @@ -13,7 +13,8 @@ #Requires -Version 3 -param($Username = "", $Password = "") +param([string]$Username = "", [string]$Password = "") + if ($Username -eq "") { $Username = read-host "Enter username for FRITZ!Box" } if ($Password -eq "") { $Password = read-host "Enter password for FRITZ!Box" } diff --git a/Scripts/list-hidden-files.ps1 b/Scripts/list-hidden-files.ps1 index 2e296996..d97d1f20 100755 --- a/Scripts/list-hidden-files.ps1 +++ b/Scripts/list-hidden-files.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($DirTree = "$PWD") +param([string]$DirTree = "$PWD") try { $DirTree = resolve-path "$DirTree" diff --git a/Scripts/list-latest-tag.ps1 b/Scripts/list-latest-tag.ps1 index c0fcb15b..be417005 100755 --- a/Scripts/list-latest-tag.ps1 +++ b/Scripts/list-latest-tag.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($RepoDir = "$PWD") +param([string]$RepoDir = "$PWD") try { if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } diff --git a/Scripts/list-news.ps1 b/Scripts/list-news.ps1 index 70e5792c..7d3f521d 100755 --- a/Scripts/list-news.ps1 +++ b/Scripts/list-news.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($RSS_URL = "https://yahoo.com/news/rss/world", [int]$MaxCount = 20) +param([string]$RSS_URL = "https://yahoo.com/news/rss/world", [int]$MaxCount = 20) try { [xml]$Content = (invoke-webRequest -uri $RSS_URL -useBasicParsing).Content diff --git a/Scripts/list-os-updates.ps1 b/Scripts/list-os-updates.ps1 index b23e197b..6d782add 100755 --- a/Scripts/list-os-updates.ps1 +++ b/Scripts/list-os-updates.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($RSS_URL = "https://distrowatch.com/news/dwd.xml", [int]$MaxCount = 20) +param([string]$RSS_URL = "https://distrowatch.com/news/dwd.xml", [int]$MaxCount = 20) try { & "$PSScriptRoot/write-big.ps1" "OS Updates" diff --git a/Scripts/list-submodules.ps1 b/Scripts/list-submodules.ps1 index 66a3ba4d..76d64af3 100644 --- a/Scripts/list-submodules.ps1 +++ b/Scripts/list-submodules.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($RepoDir = "$PWD") +param([string]$RepoDir = "$PWD") try { if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } diff --git a/Scripts/list-tags.ps1 b/Scripts/list-tags.ps1 index 37f2e67a..321ca53e 100755 --- a/Scripts/list-tags.ps1 +++ b/Scripts/list-tags.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($RepoDir = "$PWD", $Pattern="*") +param([string]$RepoDir = "$PWD", [string]$Pattern="*") try { if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } diff --git a/Scripts/list-unused-files.ps1 b/Scripts/list-unused-files.ps1 index 806fd82e..a2e2d353 100755 --- a/Scripts/list-unused-files.ps1 +++ b/Scripts/list-unused-files.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($DirTree = "", [int]$NumberOfDaysUnused = 99) +param([string]$DirTree = "", [int]$NumberOfDaysUnused = 99) write-host "Listing files in $DirTree with last access time older than $NumberOfDaysUnused days" diff --git a/Scripts/list-weather.ps1 b/Scripts/list-weather.ps1 index 7e9a6739..9f01170d 100755 --- a/Scripts/list-weather.ps1 +++ b/Scripts/list-weather.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Location = "") # empty means determine automatically +param([string]$Location = "") # empty means determine automatically try { $Weather = (invoke-webRequest -uri http://wttr.in/${Location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json diff --git a/Scripts/locate-city.ps1 b/Scripts/locate-city.ps1 index 1ce8d214..ab496d67 100755 --- a/Scripts/locate-city.ps1 +++ b/Scripts/locate-city.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($City = "") -if ($City -eq "" ) { $City = read-host "Enter the city name" } +param([string]$City = "") try { + if ($City -eq "" ) { $City = read-host "Enter the city name" } + write-progress "Reading worldcities.csv..." $Table = import-csv "$PSScriptRoot/../Data/worldcities.csv" diff --git a/Scripts/locate-ipaddress.ps1 b/Scripts/locate-ipaddress.ps1 index 90d92fe3..72cfcfce 100755 --- a/Scripts/locate-ipaddress.ps1 +++ b/Scripts/locate-ipaddress.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($IPaddr = "") -if ($IPaddr -eq "" ) { $IPaddr = read-host "Enter IP address to locate" } +param([string]$IPaddr = "") try { + if ($IPaddr -eq "" ) { $IPaddr = read-host "Enter IP address to locate" } + $result = Invoke-RestMethod -Method Get -Uri "http://ip-api.com/json/$IPaddr" write-output $result exit 0 diff --git a/Scripts/locate-zip-code.ps1 b/Scripts/locate-zip-code.ps1 index f2686904..73a82ce9 100755 --- a/Scripts/locate-zip-code.ps1 +++ b/Scripts/locate-zip-code.ps1 @@ -11,11 +11,12 @@ Author: Markus Fleschutz / License: CC0 #> -param($CountryCode = "", $ZipCode = "") -if ($CountryCode -eq "" ) { $CountryCode = read-host "Enter the country code" } -if ($ZipCode -eq "" ) { $ZipCode = read-host "Enter the zip code" } +param([string]$CountryCode = "", [string]$ZipCode = "") try { + if ($CountryCode -eq "" ) { $CountryCode = read-host "Enter the country code" } + if ($ZipCode -eq "" ) { $ZipCode = read-host "Enter the zip code" } + write-progress "Reading zip-codes.csv..." $Table = import-csv "$PSScriptRoot/../Data/zip-codes.csv" diff --git a/Scripts/make-repo.ps1 b/Scripts/make-repo.ps1 index b51fa2df..9e405d82 100755 --- a/Scripts/make-repo.ps1 +++ b/Scripts/make-repo.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($RepoDir = "$PWD") +param([string]$RepoDir = "$PWD") function MakeDir { param($Path) $DirName = (get-item "$Path").Name diff --git a/Scripts/make-repos.ps1 b/Scripts/make-repos.ps1 index 41e47500..67dd68d4 100755 --- a/Scripts/make-repos.ps1 +++ b/Scripts/make-repos.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($ParentDir = "$PWD") +param([string]$ParentDir = "$PWD") try { $StopWatch = [system.diagnostics.stopwatch]::startNew() diff --git a/Scripts/new-email.ps1 b/Scripts/new-email.ps1 index 1680f9bf..9f70b902 100755 --- a/Scripts/new-email.ps1 +++ b/Scripts/new-email.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($EmailAddress = "markus@fleschutz.de") +param([string]$EmailAddress = "markus@fleschutz.de") try { $URL="mailto:$EmailAddress" diff --git a/Scripts/open-browser.ps1 b/Scripts/open-browser.ps1 index 8f802615..ad796ca3 100755 --- a/Scripts/open-browser.ps1 +++ b/Scripts/open-browser.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($URL = "http://www.fleschutz.de") +param([string]$URL = "http://www.fleschutz.de") try { Start-Process $URL diff --git a/Scripts/play-files.ps1 b/Scripts/play-files.ps1 index 3b411efd..a9d7c55f 100755 --- a/Scripts/play-files.ps1 +++ b/Scripts/play-files.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Pattern = "*") +param([string]$Pattern = "*") try { $Files = (get-childItem -path "$Pattern" -attributes !Directory) diff --git a/Scripts/play-m3u.ps1 b/Scripts/play-m3u.ps1 index 994809e5..042eaee3 100755 --- a/Scripts/play-m3u.ps1 +++ b/Scripts/play-m3u.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($Filename = "") -if ($Filename -eq "" ) { $Filename = read-host "Enter the M3U playlist filename" } +param([string]$Filename = "") try { + if ($Filename -eq "" ) { $Filename = read-host "Enter the M3U playlist filename" } + if (-not(test-path "$Filename" -pathType leaf)) { throw "Can't access playlist file: $Filename" } $Lines = get-content $Filename diff --git a/Scripts/play-mp3.ps1 b/Scripts/play-mp3.ps1 index c4aa9062..97aaa1d2 100755 --- a/Scripts/play-mp3.ps1 +++ b/Scripts/play-mp3.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($Filename = "") -if ($Filename -eq "" ) { $Filename = read-host "Enter the MP3 filename" } +param([string]$Filename = "") try { + if ($Filename -eq "" ) { $Filename = read-host "Enter the MP3 filename" } + if (-not(test-path "$Filename" -pathType leaf)) { throw "Can't access audio file: $Filename" } $FullPath = (get-childItem $Filename).fullname $Filename = (get-item "$FullPath").name diff --git a/Scripts/pull-repo.ps1 b/Scripts/pull-repo.ps1 index 71cd53db..c03d949d 100755 --- a/Scripts/pull-repo.ps1 +++ b/Scripts/pull-repo.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($RepoDir = "$PWD") +param([string]$RepoDir = "$PWD") try { "🢃 Pulling updates..." diff --git a/Scripts/pull-repos.ps1 b/Scripts/pull-repos.ps1 index ba54c600..b2f34491 100755 --- a/Scripts/pull-repos.ps1 +++ b/Scripts/pull-repos.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($ParentDir = "$PWD") +param([string]$ParentDir = "$PWD") try { $StopWatch = [system.diagnostics.stopwatch]::startNew() diff --git a/Scripts/query-smart-data.ps1 b/Scripts/query-smart-data.ps1 index 4e68c361..69f0fa0f 100755 --- a/Scripts/query-smart-data.ps1 +++ b/Scripts/query-smart-data.ps1 @@ -16,7 +16,7 @@ #Requires -RunAsAdministrator -param($Directory = "") +param([string]$Directory = "") function CheckIfInstalled { diff --git a/Scripts/reboot-fritzbox.ps1 b/Scripts/reboot-fritzbox.ps1 index 3fdc69fb..ce97f785 100755 --- a/Scripts/reboot-fritzbox.ps1 +++ b/Scripts/reboot-fritzbox.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($USERNAME = "", $PASSWORD = "") +param([string]$USERNAME = "", [string]$PASSWORD = "") if ($USERNAME -eq "") { $USERNAME = read-host "Enter username for FRITZ!Box" } diff --git a/Scripts/remove-empty-dirs.ps1 b/Scripts/remove-empty-dirs.ps1 index 7f114a8c..be75f328 100755 --- a/Scripts/remove-empty-dirs.ps1 +++ b/Scripts/remove-empty-dirs.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($DirTree = "") -if ($DirTree -eq "" ) { $DirTree = read-host "Enter the path to the directory tree" } +param([string]$DirTree = "") try { + if ($DirTree -eq "" ) { $DirTree = read-host "Enter the path to the directory tree" } + $Folders = @() foreach ($Folder in (Get-ChildItem -path "$DirTree" -Recurse | Where { $_.PSisContainer })) { $Folders += New-Object PSObject -Property @{ diff --git a/Scripts/search-files.ps1 b/Scripts/search-files.ps1 index ca273c6f..f8a81d69 100755 --- a/Scripts/search-files.ps1 +++ b/Scripts/search-files.ps1 @@ -11,9 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Pattern = "", $Path = "") -if ($Pattern -eq "" ) { $Pattern = read-host "Enter search pattern" } -if ($Path -eq "" ) { $Path = read-host "Enter path to files" } +param([string]$Pattern = "", [string]$Path = "") function ListScripts { param([string]$Pattern, [string]$Path) $List = Select-String -Path $Path -Pattern "$Pattern" @@ -28,6 +26,9 @@ function ListScripts { param([string]$Pattern, [string]$Path) } try { + if ($Pattern -eq "" ) { $Pattern = read-host "Enter search pattern" } + if ($Path -eq "" ) { $Path = read-host "Enter path to files" } + ListScripts $Pattern $Path | format-table -property Path,Line,Text exit 0 } catch { diff --git a/Scripts/send-tcp.ps1 b/Scripts/send-tcp.ps1 index 75f94468..a00c000c 100755 --- a/Scripts/send-tcp.ps1 +++ b/Scripts/send-tcp.ps1 @@ -11,12 +11,13 @@ Author: Markus Fleschutz / License: CC0 #> -param($TargetIP = "", [int]$TargetPort = 0, $Message = "") -if ($TargetIP -eq "" ) { $TargetIP = read-host "Enter target IP address" } -if ($TargetPort -eq 0 ) { $TargetPort = read-host "Enter target port" } -if ($Message -eq "" ) { $Message = read-host "Enter message to send" } +param([string]$TargetIP = "", [int]$TargetPort = 0, [string]$Message = "") try { + if ($TargetIP -eq "" ) { $TargetIP = read-host "Enter target IP address" } + if ($TargetPort -eq 0 ) { $TargetPort = read-host "Enter target port" } + if ($Message -eq "" ) { $Message = read-host "Enter message to send" } + $IP = [System.Net.Dns]::GetHostAddresses($TargetIP) $Address = [System.Net.IPAddress]::Parse($IP) $Socket = New-Object System.Net.Sockets.TCPClient($Address,$TargetPort) diff --git a/Scripts/send-udp.ps1 b/Scripts/send-udp.ps1 index fdb63bfc..e2bfb25e 100755 --- a/Scripts/send-udp.ps1 +++ b/Scripts/send-udp.ps1 @@ -11,12 +11,13 @@ Author: Markus Fleschutz / License: CC0 #> -param($TargetIP = "", [int]$TargetPort = 0, $Message = "") -if ($TargetIP -eq "" ) { $TargetIP = read-host "Enter target IP address" } -if ($TargetPort -eq 0 ) { $TargetPort = read-host "Enter target port" } -if ($Message -eq "" ) { $Message = read-host "Enter message to send" } +param([string]$TargetIP = "", [int]$TargetPort = 0, $[string]Message = "") try { + if ($TargetIP -eq "" ) { $TargetIP = read-host "Enter target IP address" } + if ($TargetPort -eq 0 ) { $TargetPort = read-host "Enter target port" } + if ($Message -eq "" ) { $Message = read-host "Enter message to send" } + $IP = [System.Net.Dns]::GetHostAddresses($TargetIP) $Address = [System.Net.IPAddress]::Parse($IP) $EndPoints = New-Object System.Net.IPEndPoint($Address, $TargetPort) diff --git a/Scripts/set-timer.ps1 b/Scripts/set-timer.ps1 index b67ce2d8..4f77b16a 100755 --- a/Scripts/set-timer.ps1 +++ b/Scripts/set-timer.ps1 @@ -12,9 +12,10 @@ #> param([int]$Seconds = 0) -if ($Seconds -eq 0 ) { [int]$Seconds = read-host "Enter number of seconds" } try { + if ($Seconds -eq 0 ) { [int]$Seconds = read-host "Enter number of seconds" } + for ($i = $Seconds; $i -gt 0; $i--) { clear-host ./write-big "T-$i seconds" diff --git a/Scripts/set-wallpaper.ps1 b/Scripts/set-wallpaper.ps1 index 0256eb56..c418a1ed 100755 --- a/Scripts/set-wallpaper.ps1 +++ b/Scripts/set-wallpaper.ps1 @@ -12,7 +12,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($ImageFile = "", $Style = "Fit") +param([string]$ImageFile = "", [string]$Style = "Fit") function SetWallPaper { param([string]$Image, [ValidateSet('Fill', 'Fit', 'Stretch', 'Tile', 'Center', 'Span')][string]$Style) diff --git a/Scripts/simulate-presence.ps1 b/Scripts/simulate-presence.ps1 index 6b5f242c..fcc0c4e0 100755 --- a/Scripts/simulate-presence.ps1 +++ b/Scripts/simulate-presence.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($IPaddress = "") -if ($IPaddress -eq "" ) { $IPaddress = read-host "Enter IP address of Shelly1 device" } +param([string]$IPaddress = "") try { + if ($IPaddress -eq "" ) { $IPaddress = read-host "Enter IP address of Shelly1 device" } + for ([int]$i = 0; $i -lt 1000; $i++) { & "$PSScriptRoot/switch-shelly1.ps1" $IPaddress on 0 start-sleep -s 10 diff --git a/Scripts/smart-data2csv.ps1 b/Scripts/smart-data2csv.ps1 index de1caf00..f03891a5 100755 --- a/Scripts/smart-data2csv.ps1 +++ b/Scripts/smart-data2csv.ps1 @@ -12,7 +12,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Directory = "") +param([string]$Directory = "") function WriteCsvHeader { param([PSCustomObject]$File) foreach($Entry in $File.ata_smart_attributes.table) { diff --git a/Scripts/speak-checklist.ps1 b/Scripts/speak-checklist.ps1 index 374ea723..1cec10de 100755 --- a/Scripts/speak-checklist.ps1 +++ b/Scripts/speak-checklist.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($Name = "") -if ($Name -eq "") { $Name = read-host "Enter the name of the checklist" } +param([string]$Name = "") try { + if ($Name -eq "") { $Name = read-host "Enter the name of the checklist" } + $Lines = Get-Content -path "$PSScriptRoot/../Data/Checklists/$Name.txt" clear-host $Step = 1 diff --git a/Scripts/speak-english.ps1 b/Scripts/speak-english.ps1 index 945de9fa..fff5b519 100755 --- a/Scripts/speak-english.ps1 +++ b/Scripts/speak-english.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "") -if ("$Text" -eq "") { $Text = read-host "Enter the text to speak" } +param([string]$Text = "") try { + if ("$Text" -eq "") { $Text = read-host "Enter the text to speak" } + $Voice = new-object -ComObject SAPI.SPVoice $Voices = $Voice.GetVoices() foreach ($OtherVoice in $Voices) { diff --git a/Scripts/speak-epub.ps1 b/Scripts/speak-epub.ps1 index f9fb7ffa..c586bc9c 100755 --- a/Scripts/speak-epub.ps1 +++ b/Scripts/speak-epub.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Filename = "") +param([string]$Filename = "") function Speak { param([string]$Text) write-output "$Text" diff --git a/Scripts/speak-file.ps1 b/Scripts/speak-file.ps1 index 825aa83b..448644c5 100755 --- a/Scripts/speak-file.ps1 +++ b/Scripts/speak-file.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($File = "") -if ($File -eq "") { $File = read-host "Enter path to text file" } +param([string]$File = "") try { + if ($File -eq "") { $File = read-host "Enter path to text file" } + $Text = Get-Content $File $Voice = new-object -ComObject SAPI.SPVoice diff --git a/Scripts/speak-german.ps1 b/Scripts/speak-german.ps1 index 7889390c..be723a8f 100755 --- a/Scripts/speak-german.ps1 +++ b/Scripts/speak-german.ps1 @@ -12,9 +12,10 @@ #> param([string]$Text = "") -if ($Text -eq "") { $Text = read-host "Enter the text to speak" } try { + if ($Text -eq "") { $Text = read-host "Enter the text to speak" } + $Voice = new-object -ComObject SAPI.SPVoice $Voices = $Voice.GetVoices() foreach ($OtherVoice in $Voices) { diff --git a/Scripts/speak-text.ps1 b/Scripts/speak-text.ps1 index 52089322..9f1003a4 100755 --- a/Scripts/speak-text.ps1 +++ b/Scripts/speak-text.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "") -if ($Text -eq "") { $Text = read-host "Enter the text to speak" } +param([string]$Text = "") try { + if ($Text -eq "") { $Text = read-host "Enter the text to speak" } + $Voice = new-object -ComObject SAPI.SPVoice $Result = $Voice.Speak($Text) exit 0 diff --git a/Scripts/switch-branch.ps1 b/Scripts/switch-branch.ps1 index b02a307f..777780cd 100755 --- a/Scripts/switch-branch.ps1 +++ b/Scripts/switch-branch.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($BranchName = "", $RepoDir = "$PWD") -if ($BranchName -eq "") { $BranchName = read-host "Enter name of branch to switch to" } +param([string]$BranchName = "", [string]$RepoDir = "$PWD") try { + if ($BranchName -eq "") { $BranchName = read-host "Enter name of branch to switch to" } + $RepoDir = resolve-path "$RepoDir" if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } set-location "$RepoDir" diff --git a/Scripts/switch-shelly1.ps1 b/Scripts/switch-shelly1.ps1 index 8248c981..c0a7f414 100755 --- a/Scripts/switch-shelly1.ps1 +++ b/Scripts/switch-shelly1.ps1 @@ -11,12 +11,13 @@ Author: Markus Fleschutz / License: CC0 #> -param($Host = "", $TurnMode = "", [int]$Timer = -999) -if ($Host -eq "") { $Host = read-host "Enter hostname or IP address of the Shelly1 device" } -if ($TurnMode -eq "") { $TurnMode = read-host "Enter turn mode (on/off/toggle)" } -if ($Timer -eq -999) { [int]$Timer = read-host "Enter timer in seconds (0=endless)" } +param([string]$Host = "", [string]$TurnMode = "", [int]$Timer = -999) try { + if ($Host -eq "") { $Host = read-host "Enter hostname or IP address of the Shelly1 device" } + if ($TurnMode -eq "") { $TurnMode = read-host "Enter turn mode (on/off/toggle)" } + if ($Timer -eq -999) { [int]$Timer = read-host "Enter timer in seconds (0=endless)" } + $Result = Invoke-RestMethod "http://$($Host)/relay/0?turn=$($TurnMode)&timer=$($Timer)" write-host -foregroundColor green "✔️ Shelly1 device at $Host switched to $TurnMode for $Timer second(s)" diff --git a/Scripts/sync-repo.ps1 b/Scripts/sync-repo.ps1 index 50a5abba..44b0e0ee 100644 --- a/Scripts/sync-repo.ps1 +++ b/Scripts/sync-repo.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($RepoDir = "$PWD") +param([string]$RepoDir = "$PWD") try { if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } diff --git a/Scripts/take-screenshot.ps1 b/Scripts/take-screenshot.ps1 index 55729e51..31365c77 100755 --- a/Scripts/take-screenshot.ps1 +++ b/Scripts/take-screenshot.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Directory = "$PWD") +param([string]$Directory = "$PWD") function TakeScreenshot { param([string]$FilePath) Add-Type -Assembly System.Windows.Forms diff --git a/Scripts/take-screenshots.ps1 b/Scripts/take-screenshots.ps1 index 6f046315..4e76c6e5 100755 --- a/Scripts/take-screenshots.ps1 +++ b/Scripts/take-screenshots.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Directory = "$PWD", [int]$Interval = 60) +param([string]$Directory = "$PWD", [int]$Interval = 60) function TakeScreenshot { param([string]$FilePath) Add-Type -Assembly System.Windows.Forms diff --git a/Scripts/translate-file.ps1 b/Scripts/translate-file.ps1 index c427605d..94fcbbce 100755 --- a/Scripts/translate-file.ps1 +++ b/Scripts/translate-file.ps1 @@ -11,11 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($File = "", $SourceLang = "", $TargetLang = "") - -if ($File -eq "" ) { $File = read-host "Enter path to file" } -if ($SourceLang -eq "" ) { $SourceLang = read-host "Enter language used in this file" } -if ($TargetLang -eq "" ) { $TargetLang = read-host "Enter language to translate to" } +param([string]$File = "", [string]$SourceLang = "", [string]$TargetLang = "") function UseLibreTranslate { param([string]$Text, [string]$SourceLang, [string]$TargetLang) $Parameters = @{"q"="$Text"; "source"="$SourceLang"; "target"="$TargetLang"; } @@ -25,6 +21,10 @@ function UseLibreTranslate { param([string]$Text, [string]$SourceLang, [string]$ } try { + if ($File -eq "" ) { $File = read-host "Enter path to file" } + if ($SourceLang -eq "" ) { $SourceLang = read-host "Enter language used in this file" } + if ($TargetLang -eq "" ) { $TargetLang = read-host "Enter language to translate to" } + $Lines = Get-Content -path $File foreach($Line in $Lines) { if ("$Line" -eq "") { write-output "$Line"; continue } diff --git a/Scripts/translate-files.ps1 b/Scripts/translate-files.ps1 index 1336c43a..531ab182 100755 --- a/Scripts/translate-files.ps1 +++ b/Scripts/translate-files.ps1 @@ -11,8 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($FilePattern = "") -if ($FilePattern -eq "" ) { $FilePattern = read-host "Enter the file pattern" } +param([string]$FilePattern = "") function DetectSourceLang { param([string]$Filename) if ("$Filename" -like "*Deutsch*") { return "de" } @@ -30,6 +29,8 @@ function TranslateFilename { param([string]$Filename, [string]$SourceLang, [stri } try { + if ($FilePattern -eq "" ) { $FilePattern = read-host "Enter the file pattern" } + $TargetLanguages = "ar","zh","fr","de","hi","ga","it","ja","ko","pt","ru","es" $SourceFiles = get-childItem -path "$FilePattern" foreach($SourceFile in $SourceFiles) { diff --git a/Scripts/translate-text.ps1 b/Scripts/translate-text.ps1 index 9ef15301..3b0fe257 100755 --- a/Scripts/translate-text.ps1 +++ b/Scripts/translate-text.ps1 @@ -11,8 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "", $SourceLang = "en", $TargetLang = "any") -if ($Text -eq "" ) { $Text = read-host "Enter text in English to translate" } +param([string]$Text = "", [string]$SourceLang = "en", [string]$TargetLang = "any") function Language2Code { param([string]$Language) $Code = switch($Language) { @@ -50,6 +49,8 @@ function UseArgosTranslateCLI { param([string]$Text, [string]$SourceLang, [strin } try { + if ($Text -eq "" ) { $Text = read-host "Enter text in English to translate" } + if ($TargetLang -eq "any") { $TargetLanguages = "Arabic","Chinese","French","German","Hindi","Irish","Italian","Japanese","Korean","Portuguese","Russian","Spanish" foreach($TargetLang in $TargetLanguages) { diff --git a/Scripts/upload-file.ps1 b/Scripts/upload-file.ps1 index ae82827b..e38b1132 100644 --- a/Scripts/upload-file.ps1 +++ b/Scripts/upload-file.ps1 @@ -11,19 +11,19 @@ Author: Markus Fleschutz / License: CC0 #> -param($File = "", $URL = "", $Username = "", $Password = "") - -if ($File -eq "") { $File = read-host "Enter local file to upload" } -if ($URL -eq "") { $URL = read-host "Enter URL of FTP server" } -if ($Username -eq "") { $Username = read-host "Enter username for login" } -if ($Password -eq "") { $Password = read-host "Enter password for login" } -[bool]$EnableSSL = $true -[bool]$UseBinary = $true -[bool]$UsePassive = $true -[bool]$KeepAlive = $true -[bool]$IgnoreCert = $true +param([string]$File = "", [string]$URL = "", [string]$Username = "", [string]$Password = "") try { + if ($File -eq "") { $File = read-host "Enter local file to upload" } + if ($URL -eq "") { $URL = read-host "Enter URL of FTP server" } + if ($Username -eq "") { $Username = read-host "Enter username for login" } + if ($Password -eq "") { $Password = read-host "Enter password for login" } + [bool]$EnableSSL = $true + [bool]$UseBinary = $true + [bool]$UsePassive = $true + [bool]$KeepAlive = $true + [bool]$IgnoreCert = $true + $StopWatch = [system.diagnostics.stopwatch]::startNew() # check local file: diff --git a/Scripts/wakeup.ps1 b/Scripts/wakeup.ps1 index be4215f8..2b0e7012 100755 --- a/Scripts/wakeup.ps1 +++ b/Scripts/wakeup.ps1 @@ -11,9 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($MACaddress = "", $IPaddress = "", [int]$Port=9) -if ($MACaddress -eq "" ) { $MACaddress = read-host "Enter the MAC address (e.g. 00:11:22:33:44:55)" } -if ($IPaddress -eq "" ) { $IPaddress = read-host "Enter the IP address or subnet address (e.g. 255.255.255.255)" } +param([string]$MACaddress = "", [string]$IPaddress = "", [int]$Port=9) function Send-WOL { param([string]$mac, [string]$ip="255.255.255.255", [int]$port=9) $broadcast = [Net.IPAddress]::Parse($ip) @@ -28,6 +26,9 @@ function Send-WOL { param([string]$mac, [string]$ip="255.255.255.255", [int]$por } try { + if ($MACaddress -eq "" ) { $MACaddress = read-host "Enter the MAC address (e.g. 00:11:22:33:44:55)" } + if ($IPaddress -eq "" ) { $IPaddress = read-host "Enter the IP address or subnet address (e.g. 255.255.255.255)" } + Send-WOL $MACaddress $IPaddress $Port start-sleep -milliseconds 100 Send-WOL $MACaddress $IPaddress $Port diff --git a/Scripts/weather-report.ps1 b/Scripts/weather-report.ps1 index b77de875..854ecc64 100755 --- a/Scripts/weather-report.ps1 +++ b/Scripts/weather-report.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($GeoLocation = "") # empty means determine automatically +param([string]$GeoLocation = "") # empty means determine automatically try { (invoke-webRequest http://v2d.wttr.in/$GeoLocation -UserAgent "curl" ).Content diff --git a/Scripts/weather.ps1 b/Scripts/weather.ps1 index e0b9c961..9391c1c2 100755 --- a/Scripts/weather.ps1 +++ b/Scripts/weather.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($GeoLocation = "") # empty means determine automatically +param([string]$GeoLocation = "") # empty means determine automatically try { (invoke-webRequest http://wttr.in/$GeoLocation -UserAgent "curl" ).Content diff --git a/Scripts/what-is.ps1 b/Scripts/what-is.ps1 index 4577e66d..4472e993 100755 --- a/Scripts/what-is.ps1 +++ b/Scripts/what-is.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($Abbreviation = "") -if ($Abbreviation -eq "" ) { $Abbreviation = read-host "Enter the abbreviation" } +param([string]$Abbreviation = "") try { + if ($Abbreviation -eq "" ) { $Abbreviation = read-host "Enter the abbreviation" } + write-progress "Searching ..." $FoundOne = $false diff --git a/Scripts/write-big.ps1 b/Scripts/write-big.ps1 index bdcc6e3d..c6c6b0cd 100755 --- a/Scripts/write-big.ps1 +++ b/Scripts/write-big.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "") +param([string]$Text = "") Set-StrictMode -Version Latest diff --git a/Scripts/write-blue.ps1 b/Scripts/write-blue.ps1 index d894c43e..c709b5e4 100755 --- a/Scripts/write-blue.ps1 +++ b/Scripts/write-blue.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "") +param([string]$Text = "") if ($Text -eq "" ) { $Text = read-host "Enter the text to write" } diff --git a/Scripts/write-braille.ps1 b/Scripts/write-braille.ps1 index 54da7600..c6b1e9b4 100755 --- a/Scripts/write-braille.ps1 +++ b/Scripts/write-braille.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "") +param([string]$Text = "") function BrailleA { param([int]$Row) switch($Row) { diff --git a/Scripts/write-green.ps1 b/Scripts/write-green.ps1 index 03844cea..203bb0ab 100755 --- a/Scripts/write-green.ps1 +++ b/Scripts/write-green.ps1 @@ -11,7 +11,8 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "") +param([string]$Text = "") + if ($Text -eq "" ) { $Text = read-host "Enter the text to write" } write-host -foregroundColor green "$Text" diff --git a/Scripts/write-lowercase.ps1 b/Scripts/write-lowercase.ps1 index cf1fd460..acd4c460 100755 --- a/Scripts/write-lowercase.ps1 +++ b/Scripts/write-lowercase.ps1 @@ -11,7 +11,8 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "") +param([string]$Text = "") + if ($Text -eq "" ) { $Text = read-host "Enter the text to write" } write-output $Text.ToLower() diff --git a/Scripts/write-marquee.ps1 b/Scripts/write-marquee.ps1 index f290ee67..35cc6c0d 100755 --- a/Scripts/write-marquee.ps1 +++ b/Scripts/write-marquee.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "PowerShell is powerful! PowerShell is cross-platform! PowerShell is open-source! PowerShell is easy to learn! Powershell is fully documented", [int]$Speed = 60) # 60 ms pause +param([string]$Text = "PowerShell is powerful! PowerShell is cross-platform! PowerShell is open-source! PowerShell is easy to learn! Powershell is fully documented", [int]$Speed = 60) # 60 ms pause function StartMarquee { param([string]$text) $Length = $text.Length diff --git a/Scripts/write-morse-code.ps1 b/Scripts/write-morse-code.ps1 index ef271b68..50085eab 100755 --- a/Scripts/write-morse-code.ps1 +++ b/Scripts/write-morse-code.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "", [int]$OneTimeUnit = 100) # in milliseconds +param([string]$Text = "", [int]$OneTimeUnit = 100) # in milliseconds function gap { param([int]$Length) for ([int]$i = 1; $i -lt $Length; $i++) { diff --git a/Scripts/write-red.ps1 b/Scripts/write-red.ps1 index 0deb3d0d..38b72fed 100755 --- a/Scripts/write-red.ps1 +++ b/Scripts/write-red.ps1 @@ -12,6 +12,7 @@ #> param([string]$Text = "") + if ($Text -eq "" ) { $Text = read-host "Enter the text to write" } write-host -foregroundcolor red "$Text" diff --git a/Scripts/write-rot13.ps1 b/Scripts/write-rot13.ps1 index 5b207925..fb9c3fe4 100755 --- a/Scripts/write-rot13.ps1 +++ b/Scripts/write-rot13.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "") +param([string]$Text = "") function ROT13 { param([string]$Text) $Text.ToCharArray() | ForEach-Object { diff --git a/Scripts/write-typewriter.ps1 b/Scripts/write-typewriter.ps1 index b8eb52fd..571ed676 100755 --- a/Scripts/write-typewriter.ps1 +++ b/Scripts/write-typewriter.ps1 @@ -11,7 +11,7 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "`nHello World`n-----------`nPowerShell is cross-platform`nPowerShell is open-source`nPowerShell is easy to learn`nPowerShell is fully documented`n`nThanks for watching`n`n:-)`n`n", [int]$Speed = 250) # in milliseconds +param([string]$Text = "`nHello World`n-----------`nPowerShell is cross-platform`nPowerShell is open-source`nPowerShell is easy to learn`nPowerShell is fully documented`n`nThanks for watching`n`n:-)`n`n", [int]$Speed = 250) # in milliseconds try { $Random = New-Object System.Random diff --git a/Scripts/write-uppercase.ps1 b/Scripts/write-uppercase.ps1 index 6262ec2d..638efea5 100755 --- a/Scripts/write-uppercase.ps1 +++ b/Scripts/write-uppercase.ps1 @@ -11,7 +11,8 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "") +param([string]$Text = "") + if ($Text -eq "" ) { $Text = read-host "Enter the text to write" } write-output $Text.ToUpper() diff --git a/Scripts/write-vertical.ps1 b/Scripts/write-vertical.ps1 index c31066c8..f89301e8 100755 --- a/Scripts/write-vertical.ps1 +++ b/Scripts/write-vertical.ps1 @@ -11,10 +11,11 @@ Author: Markus Fleschutz / License: CC0 #> -param($Text = "") -if ($Text -eq "" ) { $Text = read-host "Enter the text to write" } +param([string]$Text = "") try { + if ($Text -eq "" ) { $Text = read-host "Enter the text to write" } + [char[]]$TextArray = $Text foreach($Char in $TextArray) { write-output $Char diff --git a/Scripts/zip-dir.ps1 b/Scripts/zip-dir.ps1 index d8ad8d95..e491f630 100755 --- a/Scripts/zip-dir.ps1 +++ b/Scripts/zip-dir.ps1 @@ -11,14 +11,15 @@ Author: Markus Fleschutz / License: CC0 #> -param($Directory = "") -if ($Directory -eq "" ) { $Directory = read-host "Enter the path to the directory to zip" } +param([string]$Directory = "") try { + if ($Directory -eq "" ) { $Directory = read-host "Enter the path to the directory to zip" } + $Directory = resolve-path $Directory compress-archive -path $Directory -destinationPath $Directory.zip - "✔️ zip archive created: $($Directory).zip" + "✔️ created zip archive: $($Directory).zip" exit 0 } catch { write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"