Add datatype to param()

This commit is contained in:
Markus Fleschutz 2021-07-15 15:51:22 +02:00
parent 35255539df
commit b97098fc42
109 changed files with 256 additions and 216 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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" }

View File

@ -13,7 +13,7 @@
#Requires -RunAsAdministrator
param($Drive = "")
param([string]$Drive = "")
if ($Drive -eq "" ) {
$Drive = read-host "Enter drive (letter) to check"

View File

@ -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]?)$"

View File

@ -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}))'

View File

@ -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}$"

View File

@ -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"

View File

@ -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) {

View File

@ -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

View File

@ -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"

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($RepoDir = "$PWD")
param([string]$RepoDir = "$PWD")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($ParentDir = "$PWD")
param([string]$ParentDir = "$PWD")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($ParentDir = "$PWD")
param([string]$ParentDir = "$PWD")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()

View File

@ -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) {

View File

@ -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" }

View File

@ -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) {

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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)

View File

@ -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" }

View File

@ -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"

View File

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

View File

@ -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"

View File

@ -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" }

View File

@ -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" }

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($Filename = "")
param([string]$Filename = "")
try {
if ($IsLinux) {

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($Path = "", $Password = "")
param([string]$Path = "", [string]$Password = "")
function EncryptFile {
<#

View File

@ -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" }

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($ParentDir = "$PWD")
param([string]$ParentDir = "$PWD")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()

View File

@ -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"

View File

@ -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 {

View File

@ -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

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($Word = "", [int]$Columns = 8)
param([string]$Word = "", [int]$Columns = 8)
function GetPermutations {
[cmdletbinding()]

View File

@ -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" }

View File

@ -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" }

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($DirTree = "$PWD")
param([string]$DirTree = "$PWD")
function ListDir { param([string]$Directory, [int]$Depth)
$Depth++

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($Pattern = "*")
param([string]$Pattern = "*")
function ListDir { param([string]$Pattern)
$Items = get-childItem -path "$Pattern"

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($DirTree = "$PWD")
param([string]$DirTree = "$PWD")
try {
$DirTree = resolve-path "$DirTree/"

View File

@ -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 {

View File

@ -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 {

View File

@ -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" }

View File

@ -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" }

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($DirTree = "$PWD")
param([string]$DirTree = "$PWD")
try {
$DirTree = resolve-path "$DirTree"

View File

@ -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" }

View File

@ -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

View File

@ -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"

View File

@ -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" }

View File

@ -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" }

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($ParentDir = "$PWD")
param([string]$ParentDir = "$PWD")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($EmailAddress = "markus@fleschutz.de")
param([string]$EmailAddress = "markus@fleschutz.de")
try {
$URL="mailto:$EmailAddress"

View File

@ -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

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($Pattern = "*")
param([string]$Pattern = "*")
try {
$Files = (get-childItem -path "$Pattern" -attributes !Directory)

View File

@ -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

View File

@ -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

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($RepoDir = "$PWD")
param([string]$RepoDir = "$PWD")
try {
"🢃 Pulling updates..."

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($ParentDir = "$PWD")
param([string]$ParentDir = "$PWD")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()

View File

@ -16,7 +16,7 @@
#Requires -RunAsAdministrator
param($Directory = "")
param([string]$Directory = "")
function CheckIfInstalled {

View File

@ -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"
}

View File

@ -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 @{

View File

@ -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 {

View File

@ -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)

View File

@ -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)

View File

@ -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"

View File

@ -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)

View File

@ -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

View File

@ -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) {

View File

@ -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

View File

@ -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) {

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($Filename = "")
param([string]$Filename = "")
function Speak { param([string]$Text)
write-output "$Text"

View File

@ -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

View File

@ -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) {

View File

@ -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

View File

@ -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"

View File

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

View File

@ -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" }

View File

@ -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

View File

@ -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

View File

@ -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 }

View File

@ -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) {

View File

@ -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) {

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($Text = "")
param([string]$Text = "")
Set-StrictMode -Version Latest

View File

@ -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" }

View File

@ -11,7 +11,7 @@
Author: Markus Fleschutz / License: CC0
#>
param($Text = "")
param([string]$Text = "")
function BrailleA { param([int]$Row)
switch($Row) {

View File

@ -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"

Some files were not shown because too many files have changed in this diff Show More