Added comment-based help

This commit is contained in:
Markus Fleschutz 2020-12-29 14:14:21 +00:00
parent 3b83d94809
commit 66bc6a7699
85 changed files with 687 additions and 725 deletions

View File

@ -136,7 +136,7 @@ Using PowerShell in Context Menus
Script Conventions
------------------
Each PowerShell script should follow the 8 golden rules:
Each PowerShell script should follow the 9 golden rules:
* **Rule #1:** the filename should be named `<verb>-<object>.ps1`
* **Rule #2:** the first line reads `#!/snap/bin/powershell` to support PowerShell on Linux
@ -145,7 +145,8 @@ Each PowerShell script should follow the 8 golden rules:
* **Rule #5:** prefer command-line options, else ask the user
* **Rule #6:** the encoding of the script is in UTF-8 with BOM to support Unicode characters
* **Rule #7:** use `Set-StrictMode -Version Latest` to enable additional error checking
* **Rule #8:** exits 0 for success, else print an error message and exit with the error code (mostly 1)
* **Rule #8:** for readibility use lowercase or lowerCamelCase
* **Rule #9:** exits 0 for success, else print an error message and exit with the error code (mostly 1)
Feedback
--------

View File

@ -1,12 +1,13 @@
#!/snap/bin/powershell
<#
.SYNTAX ./MD5.ps1 [<file>]
.DESCRIPTION prints the MD5 checksum of the given file
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./MD5.ps1 [<file>]
# Description: prints the MD5 checksum of the given file
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$File)
try {
if ($File -eq "" ) {
$File = read-host "Enter path to file"

View File

@ -1,12 +1,13 @@
#!/snap/bin/powershell
<#
.SYNTAX ./SHA1.ps1 [<file>]
.DESCRIPTION prints the SHA1 checksum of the given file
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./SHA1.ps1 [<file>]
# Description: prints the SHA1 checksum of the given file
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$File)
try {
if ($File -eq "" ) {
$File = read-host "Enter file"

View File

@ -1,12 +1,13 @@
#!/snap/bin/powershell
# Syntax: ./SHA256.ps1 [<file>]
# Description: prints the SHA256 checksum of the given file
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./SHA256.ps1 [<file>]
.DESCRIPTION prints the SHA256 checksum of the given file
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$File)
try {
if ($File -eq "" ) {
$File = read-host "Enter file"

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./alert.ps1 [<message>]
# Description: handle and escalate the given alert message
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./alert.ps1 [<message>]
.DESCRIPTION handle and escalate the given alert message
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$Message)
if ($Message -eq "" ) {

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./calculator.ps1
# Description: starts a calculator (GUI)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./calculator.ps1
.DESCRIPTION starts a calculator (GUI)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
clear-host
write-host " PowerShell Calculator " -for green

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./check-ipv4-address.ps1 [<address>]
# Description: checks the given IPv4 address for validity
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./check-ipv4-address.ps1 [<address>]
.DESCRIPTION checks the given IPv4 address for validity
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$Addr)

View File

@ -1,7 +1,11 @@
#!/snap/bin/powershell
<#
.SYNTAX ./check-mac-address.ps1 [<MAC>]
.DESCRIPTION checks the given MAC address for validity
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./check-mac-address.ps1 [<MAC>]
# Description: checks the given MAC address for validity
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./check-xml-file [<file>]
# Description: checks the given XML file for validity
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./check-xml-file [<file>]
.DESCRIPTION checks the given XML file for validity
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param ([String]$XmlFilePath)

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./clone-repos.ps1
# Description: clones well-known Git repositories into the current directory.
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./clone-repos.ps1
.DESCRIPTION clones well-known Git repositories into the current directory.
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
$Repos = "https://github.com/commonmark/cmark", "https://github.com/opencv/opencv", "https://github.com/openzfs/zfs", "https://github.com/synesthesiam/voice2json", "https://github.com/fleschutz/CWTS", "https://github.com/fleschutz/cubesum", "https://github.com/fleschutz/PowerShell","https://github.com/fleschutz/CWTS", "https://github.com/fleschutz/eventdriven"

View File

@ -1,9 +1,9 @@
#!/snap/bin/powershell
# Syntax: ./close-chrome.ps1
# Description: closes Google Chrome gracefully
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./close-chrome.ps1
.DESCRIPTION closes Google Chrome gracefully
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
./close-program "chrome"

View File

@ -1,9 +1,9 @@
#!/snap/bin/powershell
# Syntax: ./close-edge.ps1
# Description: closes Microsoft Edge gracefully
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./close-edge.ps1
.DESCRIPTION closes Microsoft Edge gracefully
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
./close-program "msedge"

View File

@ -1,9 +1,9 @@
#!/snap/bin/powershell
# Syntax: ./close-file-explorer.ps1
# Description: closes Microsoft File Explorer gracefully
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./close-file-explorer.ps1
.DESCRIPTION closes Microsoft File Explorer gracefully
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
./close-program "explorer"

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./close-program.ps1 [<program-name>]
# Description: closes the given program gracefully
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./close-program.ps1 [<program-name>]
.DESCRIPTION closes the given program gracefully
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$ProgramName)

View File

@ -1,9 +1,9 @@
#!/snap/bin/powershell
# Syntax: ./close-thunderbird.ps1
# Description: closes Mozilla Thunderbird gracefully
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./close-thunderbird.ps1
.DESCRIPTION closes Mozilla Thunderbird gracefully
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
./close-program "thunderbird"

View File

@ -1,9 +1,9 @@
#!/snap/bin/powershell
# Syntax: ./close-windows-terminal.ps1
# Description: closes Windows Terminal gracefully
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./close-windows-terminal.ps1
.DESCRIPTION closes Windows Terminal gracefully
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
./close-program "WindowsTerminal"

View File

@ -1,11 +1,11 @@
#!/snap/bin/powershell
# Syntax: ./configure-git.ps1
# Description: sets up the Git configuration
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
# NOTE: requires installation of Git
<#
.SYNTAX ./configure-git.ps1
.DESCRIPTION sets up the Git configuration
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
requires installation of Git
#>
$UserName = read-host "Enter your full name"
$UserEmail = read-host "Enter your email address"

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./csv-to-text.ps1 [<csv-file>]
# Description: converts the given CSV file into a text list
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./csv-to-text.ps1 [<csv-file>]
.DESCRIPTION converts the given CSV file into a text list
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([String]$Path)

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./display-time.ps1
# Description: displays the current time
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./display-time.ps1
.DESCRIPTION displays the current time
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
for ($i = 0; $i -lt 1000; $i++) {

View File

@ -1,9 +1,10 @@
#!/snap/bin/powershell
# Syntax: empty-dir.ps1 <dir>
# Description: Empties the given directory. The content is removed!
# Author: Markus Fleschutz
# License: CC0
<#
.SYNTAX ./empty-dir.ps1 [<path-to-dir>]
.DESCRIPTION Empties the given directory by removing(!) any file and subdirectories.
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# TODO
exit 0

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./enable-crash-dumps.ps1
# Description: enables the writing of crash dumps
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./enable-crash-dumps.ps1
.DESCRIPTION enables the writing of crash dumps
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
##################################################################
# #

View File

@ -1,18 +1,18 @@
#!/snap/bin/powershell
<#
.SYNTAX ./inspect-exe.ps1 [<path-to-exe-file>]
.DESCRIPTION prints basic information of the given executable file
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./inspect-exe.ps1 [<executable-file>]
# Description: prints basic information of the given executable file
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$File)
param([string]$PathToExe)
try {
if ($File -eq "" ) {
$File = read-host "Enter path to executable file"
if ($PathToExe -eq "" ) {
$PathToExe = read-host "Enter path to executable file"
}
get-childitem $File | % {$_.VersionInfo} | Select *
get-childitem $PathToExe | % {$_.VersionInfo} | Select *
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,15 +1,14 @@
#!/snap/bin/powershell
<#
.SYNTAX ./list-anagrams.ps1 [<word>] [<columns>]
.DESCRIPTION lists all anagrams of the given word
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./list-anagrams.ps1 [<word>]
# Description: lists all anagrams of the given word
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$Word, [int]$Columns = 8)
param([string]$Word)
$Columns = 8
Function GetPermutations {
function GetPermutations {
[cmdletbinding()]
Param(
[parameter(ValueFromPipeline=$True)]

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./list-cmdlets.ps1
# Description: lists all PowerShell cmdlets
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./list-cmdlets.ps1
.DESCRIPTION lists all PowerShell cmdlets
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
Get-Command -Command-Type cmdlet

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./list-earthquakes.ps1
# Description: lists earthquakes >= 6.0 for the last 30 days
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./list-earthquakes.ps1
.DESCRIPTION lists earthquakes with magnitude >= 6.0 for the last 30 days
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
$Format="csv" # csv, geojson, kml, text, xml
$MinMagnitude=6.0

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./list-empty-dirs.ps1 <dirtree>
# Description: lists empty subfolders in the <directory tree>
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./list-empty-dirs.ps1 <dirtree>
.DESCRIPTION lists empty subfolders in the <directory tree>
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$DirTree)

View File

@ -1,16 +1,16 @@
#!/snap/bin/powershell
# Syntax: ./list-files.ps1 [<folder>]
# Description: lists all files in the given <folder> and also in every subfolder
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./list-files.ps1 [<folder>]
.DESCRIPTION lists all files in the given folder and also in every subfolder
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$Folder)
try {
if ($Folder -eq "" ) {
[String]$Folder = read-host "Enter path to folder"
[string]$Folder = read-host "Enter path to folder"
}
Get-ChildItem -path $Folder -recurse | select FullName
exit 0

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./list-logbook.ps1
# Description: lists the content of the logbook (../Data/Logbook.csv)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./list-logbook.ps1
.DESCRIPTION lists the content of the logbook (../Data/Logbook.csv)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./list-modules.ps1
# Description: lists all PowerShell modules
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./list-modules.ps1
.DESCRIPTION lists all PowerShell modules
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
Get-Module

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./list-processes.ps1
# Description: lists the local computer processes
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./list-processes.ps1
.DESCRIPTION lists the local computer processes
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
Get-Process | Format-Table -Property Id, @{Label="CPU(s)";Expression={$_.CPU.ToString("N")+"%"};Alignment="Right"}, ProcessName -AutoSize

View File

@ -1,11 +1,11 @@
#!/snap/bin/powershell
<#
.SYNTAX ./list-random-passwords.ps1
.DESCRIPTION prints a list of random passwords
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./list-random-passwords.ps1
# Description: prints a list of random passwords
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
$PasswordLength = 15
$Columns = 6
$Lines = 24

View File

@ -1,18 +1,16 @@
#!/snap/bin/powershell
<#
.SYNTAX ./list-random-pins.ps1 [<pin-length>] [<columns>] [<rows>]
.DESCRIPTION prints a list of random PIN's
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./list-random-pins.ps1
# Description: prints a list of random PIN's
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
$PIN_Length = 5
$Columns = 12
$Lines = 24
param([int]$PinLength = 5, [int]$Columns = 12, [int]$Rows = 24)
function GeneratePIN() {
$Generator = New-Object System.Random
for ($i = 0; $i -lt $PIN_Length; $i++) {
for ($i = 0; $i -lt $PinLength; $i++) {
$PIN += [char]$Generator.next(48,57)
}
return $PIN
@ -20,7 +18,7 @@ function GeneratePIN() {
try {
write-output ""
for ($j = 0; $j -lt $Lines; $j++) {
for ($j = 0; $j -lt $Rows; $j++) {
$Line = ""
for ($k = 0; $k -lt $Columns; $k++) {
$Line += GeneratePIN

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./list-unused-files.ps1 <dirtree> <days>
# Description: lists files in the <directory tree> with last access time older than <days>
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./list-unused-files.ps1 <dirtree> <days>
.DESCRIPTION lists files in the <directory tree> with last access time older than <days>
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$DirTree, [int]$NumberOfDaysUnused)

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./locate-city.ps1 [<city>]
# Description: prints the geographic location of the given city
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./locate-city.ps1 [<city>]
.DESCRIPTION prints the geographic location of the given city
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$City)
if ($City -eq "" ) {

View File

@ -1,11 +1,11 @@
#!/snap/bin/powershell
<#
.SYNTAX ./locate-ipaddress.ps1 [<IPaddress>]
.DESCRIPTION prints the geographic location of the given IP address
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./locate-ipaddress.ps1 [<IPaddress>]
# Description: prints the geographic location of the given IP address
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$IPaddr)
try {
if ($IPaddr -eq "" ) {

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./locate-zip-code.ps1 [<country-code>] [<zip-code>]
# Description: prints the geographic location of the given zip-code
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./locate-zip-code.ps1 [<country-code>] [<zip-code>]
.DESCRIPTION prints the geographic location of the given zip-code
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$CountryCode, [string]$ZipCode)

View File

@ -1,9 +1,10 @@
#!/snap/bin/powershell
# Syntax: make-install.ps1 <build-dir>
# Description: Copies newer EXE's + DLL's from the build directory to the installation directory.
# Author: Markus Fleschutz
# License: CC0
<#
.SYNTAX make-install.ps1 <build-dir>
.DESCRIPTION Copies newer EXE's + DLL's from the build directory to the installation directory.
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
set SRC_DIR=%1
set "DST_DIR=C:\Program Files\MyApp\bin"

View File

@ -1,11 +1,11 @@
#!/snap/bin/powershell
<#
.SYNTAX ./moon.ps1
.DESCRIPTION prints the current moon phase
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./moon.ps1
# Description: prints the current moon phase
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
try {
(Invoke-WebRequest http://wttr.in/Moon -UserAgent "curl" ).Content
exit 0

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./mute-audio.ps1
# Description: mutes the audio
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./mute-audio.ps1
.DESCRIPTION mutes the audio
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
$obj = new-object -com wscript.shell

View File

@ -1,17 +1,18 @@
#!/snap/bin/powershell
<#
.SYNTAX ./new-email.ps1 [<address>]
.DESCRIPTION starts the default email client to write a new email
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./new-email.ps1 [<address>]
# Description: starts the default email client to write a new email
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$EmailAddress)
param([string]$emailAddress)
try {
if ($emailAddress -eq "" ) {
$emailAddress = "markus@fleschutz.de"
if ($EmailAddress -eq "" ) {
$EmailAddress = "markus@fleschutz.de"
}
$URL="mailto:$emailAddress"
$URL="mailto:$EmailAddress"
Start-Process $URL
exit 0
} catch {

View File

@ -1,11 +1,11 @@
#!/snap/bin/powershell
<#
.SYNTAX ./news.ps1
.DESCRIPTION print the latest news
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./news.ps1
# Description: print the latest news
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
#$RSS_URL = "http://feeds.skynews.com/feeds/rss/world.xml"
$RSS_URL = "https://yahoo.com/news/rss/world"
# $RSS_URL = "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml"

View File

@ -1,12 +1,13 @@
#!/snap/bin/powershell
# Syntax: ./open-browser.ps1 [<URL>]
# Description: starts the default Web browser, optional with given URL
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./open-browser.ps1 [<URL>]
.DESCRIPTION starts the default Web browser, optional with given URL
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$URL)
try {
if ($URL -eq "" ) {
$URL = "http://www.fleschutz.de"

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./open-email-client.ps1
# Description: starts the default email client
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./open-email-client.ps1
.DESCRIPTION starts the default email client
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
Start-Process "mailto:markus@fleschutz.de"

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./play-beep.ps1
# Description: plays a beep sound
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./play-beep.ps1
.DESCRIPTION plays a beep sound
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
[console]::beep(500,300)

View File

@ -1,12 +1,13 @@
#!/snap/bin/powershell
# Syntax: ./poweroff.ps1
# Description: halts the local computer, administrator rights are required
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./poweroff.ps1
.DESCRIPTION halts the local computer, administrator rights are required
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
#Requires -RunAsAdministrator
try {
Stop-Computer
exit 0

View File

@ -1,12 +1,13 @@
#!/snap/bin/powershell
# Syntax: ./reboot.ps1
# Description: reboots the local computer, administrator rights are required
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./reboot.ps1
.DESCRIPTION reboots the local computer, administrator rights are required
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
#Requires -RunAsAdministrator
try {
Restart-Computer
exit 0

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./scan-ports.ps1
# Description: scans the network for open/closed ports
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./scan-ports.ps1
.DESCRIPTION scans the network for open/closed ports
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
$network = "192.168.178"
$port = 8080

View File

@ -1,12 +1,12 @@
#!/snap/bin/powershell
<#
.SYNTAX ./search-files.ps1 [<pattern>] [<path>]
.DESCRIPTION searches the given pattern in the given files
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./search-files.ps1 [<pattern>] [<path>]
# Description: searches the given pattern in the given files
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([String]$Pattern, [String]$Path)
param([string]$Pattern, [string]$Path)
Set-StrictMode -Version Latest

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./send-email.ps1
# Description: sends an email
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./send-email.ps1
.DESCRIPTION sends an email
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
$smtpServer = "smtp.example.com"
$From = read-host "Enter sender email address"

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./send-tcp.ps1 [<IP>] [<port>] [<message>]
# Description: sends a TCP message to the given IP address and port
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./send-tcp.ps1 [<target-IP>] [<target-port>] [<message>]
.DESCRIPTION sends a TCP message to the given IP address and port
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$TargetIP, [int]$TargetPort, [string]$Message)

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./send-udp.ps1 [<IP>] [<port>] [<message>]
# Description: sends a UDP datagram message to the given IP address and port
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./send-udp.ps1 [<target-IP>] [<target-port>] [<message>]
.DESCRIPTION sends a UDP datagram message to the given IP address and port
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$TargetIP, [int]$TargetPort, [string]$Message)

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./set-timer.ps1 [<seconds>]
# Description: sets a timer for a countdown
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./set-timer.ps1 [<seconds>]
.DESCRIPTION sets a timer for a countdown
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([int]$Seconds)
try {

View File

@ -1,48 +1,48 @@
#!/snap/bin/powershell
# Syntax: ./simulate-matrix.ps1
# Description: simulates the Matrix (fun)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./simulate-matrix.ps1
.DESCRIPTION simulates the Matrix (fun)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
write-progress "Reading Matrix.csv..."
$PathToRepo=(get-item $MyInvocation.MyCommand.Path).directory.parent
$Table = import-csv "$PathToRepo/Data/Matrix.csv"
Clear-Host
clear-host
foreach($Row in $Table) {
for ($i = 0; $i -lt 4; $i++) {
Write-Host -nonewline $($Row.A); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.B); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.C); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.D); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.E); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.F); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.G); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.H); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.I); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.J); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.K); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.L); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.M); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.N); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.O); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.P); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.Q); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.R); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.S); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.T); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.U); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.V); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.W); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.X); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.Y); Start-Sleep -milliseconds 5
Write-Host -nonewline $($Row.Z); Start-Sleep -milliseconds 5
write-host -nonewline $($Row.A); start-sleep -milliseconds 5
write-host -nonewline $($Row.B); start-sleep -milliseconds 5
write-host -nonewline $($Row.C); start-sleep -milliseconds 5
write-host -nonewline $($Row.D); start-sleep -milliseconds 5
write-host -nonewline $($Row.E); start-sleep -milliseconds 5
write-host -nonewline $($Row.F); start-sleep -milliseconds 5
write-host -nonewline $($Row.G); start-sleep -milliseconds 5
write-host -nonewline $($Row.H); start-sleep -milliseconds 5
write-host -nonewline $($Row.I); start-sleep -milliseconds 5
write-host -nonewline $($Row.J); start-sleep -milliseconds 5
write-host -nonewline $($Row.K); start-sleep -milliseconds 5
write-host -nonewline $($Row.L); start-sleep -milliseconds 5
write-host -nonewline $($Row.M); start-sleep -milliseconds 5
write-host -nonewline $($Row.N); start-sleep -milliseconds 5
write-host -nonewline $($Row.O); start-sleep -milliseconds 5
write-host -nonewline $($Row.P); start-sleep -milliseconds 5
write-host -nonewline $($Row.Q); start-sleep -milliseconds 5
write-host -nonewline $($Row.R); start-sleep -milliseconds 5
write-host -nonewline $($Row.S); start-sleep -milliseconds 5
write-host -nonewline $($Row.T); start-sleep -milliseconds 5
write-host -nonewline $($Row.U); start-sleep -milliseconds 5
write-host -nonewline $($Row.V); start-sleep -milliseconds 5
write-host -nonewline $($Row.W); start-sleep -milliseconds 5
write-host -nonewline $($Row.X); start-sleep -milliseconds 5
write-host -nonewline $($Row.Y); start-sleep -milliseconds 5
write-host -nonewline $($Row.Z); start-sleep -milliseconds 5
}
Write-Host ""
Start-Sleep -milliseconds 200
write-host ""
start-sleep -milliseconds 200
}
exit 0
} catch {

View File

@ -1,19 +1,17 @@
#!/snap/bin/powershell
<#
.SYNTAX ./simulate-presence.ps1 [<IP-address>]
.DESCRIPTION simulates the human presence against burglars
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./simulate-presence.ps1
# Description: simulates the human presence against burglars
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]IPaddress)
function SwitchLight {
for ([int]$i = 0; $i -lt 1000; $i++) {
./switch-shelly1 $IPaddress on 0
sleep 60
./switch-shelly1 $IPaddress off 0
sleep 10
}
SwitchLight 1
sleep 60
SwitchLight 0
sleep 10
exit 0

View File

@ -1,12 +1,13 @@
#!/snap/bin/powershell
# Syntax: ./speak-file.ps1 [<file>]
# Description: speaks the content of the given text file by text-to-speech (TTS)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./speak-file.ps1 [<file>]
.DESCRIPTION speaks the content of the given text file by text-to-speech (TTS)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$File)
try {
if ($File -eq "") {
$File = read-host "Enter path to file"

View File

@ -1,12 +1,13 @@
#!/snap/bin/powershell
# Syntax: ./speak-text.ps1 [<text>]
# Description: speaks the given text by text-to-speech (TTS)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./speak-text.ps1 [<text>]
.DESCRIPTION speaks the given text by text-to-speech (TTS)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$Text)
try {
if ($Text -eq "") {
$Text = read-host "Enter text to speak"

View File

@ -1,21 +1,21 @@
#!/snap/bin/powershell
<#
.SYNTAX ./switch-shelly1.ps1 [<IP-address>] [<turn-mode>] [<timer>]
.DESCRIPTION switches a Shelly1 device in the local network
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./switch-shelly1.ps1 [<IP addr>] [<turn-mode>] [<timer>]
# Description: switches a Shelly1 device in the local network
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([String]$IPaddr, [String]$TurnMode, [Int]$Timer)
param([string]$IPaddr, [string]$TurnMode, [int]$Timer = -999)
try {
if ($IPaddr -eq "" ) {
if ($IPaddr -eq "") {
[String]$IPaddr = read-host "Enter IP address of the Shelly1 device"
}
if ($TurnMode -eq "" ) {
if ($TurnMode -eq "") {
[String]$TurnMode = read-host "Enter turn mode (on/off/toggle)"
}
if ($Timer -eq 0 ) {
if ($Timer -eq -999) {
[Int]$Timer = read-host "Enter timer (0=endless)"
}

View File

@ -1,38 +1,12 @@
#!/snap/bin/powershell
Function Get-TimedScreenshot {
<#
.SYNOPSIS
Get-TimedScreenshot
.DESCRIPTION
A function that takes screenshots and saves them to a folder.
.PARAMETER $Path
Specifies the folder path.
.PARAMETER $Interval
Specifies the interval in seconds between taking screenshots.
.PARAMETER $EndTime
Specifies when the script should stop running in the format HH-MM
.EXAMPLE
PS C:\> Get-TimedScreenshot -Path c:\temp\ -Interval 30 -EndTime 14:00
.LINK
http://obscuresecurity.blogspot.com/2013/01/Get-TimedScreenshot.html
https://github.com/obscuresec/random/blob/master/Get-TimedScreenshot
.SYNTAX ./take-screenshot.ps1
.DESCRIPTION takes a single screenshots
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
Function Get-TimedScreenshot {
[CmdletBinding()] Param(
[Parameter(Mandatory=$True)]
[ValidateScript({Test-Path -Path $_ })]

View File

@ -1,38 +1,12 @@
#!/snap/bin/powershell
Function Get-TimedScreenshot {
<#
.SYNOPSIS
Get-TimedScreenshot
.DESCRIPTION
A function that takes screenshots and saves them to a folder.
.PARAMETER $Path
Specifies the folder path.
.PARAMETER $Interval
Specifies the interval in seconds between taking screenshots.
.PARAMETER $EndTime
Specifies when the script should stop running in the format HH-MM
.EXAMPLE
PS C:\> Get-TimedScreenshot -Path c:\temp\ -Interval 30 -EndTime 14:00
.LINK
http://obscuresecurity.blogspot.com/2013/01/Get-TimedScreenshot.html
https://github.com/obscuresec/random/blob/master/Get-TimedScreenshot
.SYNTAX ./take-screenshots.ps1
.DESCRIPTION takes multiple screenshots
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
Function Get-TimedScreenshot {
[CmdletBinding()] Param(
[Parameter(Mandatory=$True)]
[ValidateScript({Test-Path -Path $_ })]

View File

@ -1,11 +1,11 @@
#!/snap/bin/powershell
<#
.SYNTAX ./test.ps1
.DESCRIPTION simple PowerShell test script
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./test.ps1
# Description: simple PowerShell test script
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
try {
write-output "✔️ PowerShell works. Details are:"
echo $PSVersionTable

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./train-dns-cache.ps1
# Description: trains the DNS cache with frequently used domain names
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./train-dns-cache.ps1
.DESCRIPTION trains the DNS cache with frequently used domain names
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
Set-StrictMode -Version Latest

View File

@ -1,12 +1,13 @@
#!/snap/bin/powershell
# Syntax: ./translate-file.ps1 [<file>]
# Description: translates the given file from source to target language.
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./translate-file.ps1 [<file>] [<source-lang>] [<target-lang>]
.DESCRIPTION translates the given file from source to target language.
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$SourceFile, [string]$SourceLanguage, [string]$TargetLanguage)
try {
if ($SourceFile -eq "" ) {
$SourceFile = read-host "Enter path to file"

View File

@ -1,16 +1,16 @@
#!/snap/bin/powershell
<#
.SYNTAX ./translate-text.ps1 [<text>] [<source-lang>]
.DESCRIPTION translates the given text into other languages
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./translate-text.ps1 [<text>]
# Description: translates the given text into other languages
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$SourceText, [string]$SourceLang = "en")
param([string]$SourceText)
if ($SourceText -eq "" ) {
$SourceText = "Hello World!"
$SourceText = read-host "Enter text to translate"
}
$SourceLanguage = "en"
$TargetLanguages = "af","da","de","el","es","hr","it","ja","ko","pl","pt","nl","ru","tr","uk","vi"
function TranslateWithGoogle {
@ -36,7 +36,7 @@ function TranslateWithGoogle {
try {
foreach($TargetLanguage in $TargetLanguages) {
$Result = TranslateWithGoogle $SourceText $SourceLanguage $TargetLanguage
$Result = TranslateWithGoogle $SourceText $SourceLang $TargetLanguage
write-output $TargetLanguage" : "$Result
}
exit 0

View File

@ -1,16 +1,16 @@
#!/snap/bin/powershell
<#
.SYNTAX ./turn-volume-down.ps1 [<percent>]
.DESCRIPTION turns the audio volume down (-10% by default)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./turn-volume-down.ps1 [<percent>]
# Description: turns the audio volume down (-10% by default)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
Param([Int]$Percent = 10)
param([int]$Percent = 10)
try {
$obj = New-Object -com wscript.shell
for ($i = 0; $i -lt $Percent; $i += 2) {
for ([int]$i = 0; $i -lt $Percent; $i += 2) {
$obj.SendKeys([char]174) # each tick is -2%
}
write-output "OK"

View File

@ -1,16 +1,16 @@
#!/snap/bin/powershell
<#
.SYNTAX ./turn-volume-up.ps1 [<percent>]
.DESCRIPTION turns the audio volume up (+10% by default)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./turn-volume-up.ps1 [<percent>]
# Description: turns the audio volume up (+10% by default)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
Param([Int]$Percent = 10)
param([int]$Percent = 10)
try {
$obj = New-Object -com wscript.shell
for ($i = 0; $i -lt $Percent; $i += 2) {
for ([int]$i = 0; $i -lt $Percent; $i += 2) {
$obj.SendKeys([char]175) # each tick is +2%
}
write-output "OK"

View File

@ -1,17 +1,15 @@
#!/snap/bin/powershell
<#
.SYNTAX ./txt2wav.ps1
.DESCRIPTION converts the given text into an audio .WAV file
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./txt2wav.ps1
# Description: converts the given text into an audio .WAV file
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
# Configuration:
$Text = "Hello, my name ist Bond, James Bond"
$Speed = -1 # -10 is slowest, 10 is fastest
$TargetWavFile = "spoken.wav"
# Run:
try {
Add-Type -AssemblyName System.Speech
$SpeechSynthesizer = New-Object System.Speech.Synthesis.SpeechSynthesizer

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./unmute-audio.ps1
# Description: unmutes the audio
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./unmute-audio.ps1
.DESCRIPTION unmutes audio output
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
$obj = new-object -com wscript.shell

View File

@ -1,10 +1,10 @@
#!/snap/bin/powershell
# Syntax: ./wakeup.ps1 [<hostname>]
# Description: sends a magic packet to the given computer, waking him up
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./wakeup.ps1 [<hostname>]
.DESCRIPTION sends a magic packet to the given computer, waking him up
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$Hostname)
if ($Hostname -eq "" ) {

View File

@ -1,15 +1,14 @@
#!/snap/bin/powershell
<#
.SYNTAX ./weather-alert.ps1
.DESCRIPTION checks the current weather for critical values
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./weather-alert.ps1
# Description: checks the current weather for critical values
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
$GeoLocation="" # empty means determine automatically
function Check {
param ([int]$Value, [int]$NormalMin, [int]$NormalMax, [string]$Unit)
function Check { param([int]$Value, [int]$NormalMin, [int]$NormalMax, [string]$Unit)
if ($Value -lt $NormalMin) {
return "$Value $Unit ! "
}

View File

@ -1,15 +1,15 @@
#!/snap/bin/powershell
<#
.SYNTAX ./weather-report.ps1 [<geo-location>]
.DESCRIPTION prints the local weather report
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./weather-report.ps1
# Description: prints the local weather report
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
$GeoLocation="" # empty means determine automatically
param([string]$GeoLocation = "") # empty means determine automatically
try {
(Invoke-WebRequest http://v2d.wttr.in/$GeoLocation -UserAgent "curl" ).Content
(invoke-webRequest http://v2d.wttr.in/$GeoLocation -UserAgent "curl" ).Content
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,11 +1,11 @@
#!/snap/bin/powershell
<#
.SYNTAX ./weather-worldwide.ps1
.DESCRIPTION prints the current weather of cities world-wide
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./weather-worldwide.ps1
# Description: prints the current weather of cities world-wide
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
$Cities="Hawaii","Los Angeles","Mexico City","Miami","New York","Rio de Janeiro","Paris","London","Berlin","Cape Town","Dubai","Mumbai","Singapore","Hong Kong","Peking","Tokyo","Sydney"
try {

View File

@ -1,15 +1,15 @@
#!/snap/bin/powershell
<#
.SYNTAX ./weather.ps1 [<geo-location>]
.DESCRIPTION prints the current weather forecast
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./weather.ps1
# Description: prints the current weather forecast
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
$GeoLocation="" # empty means determine automatically
param([string]$GeoLocation = "") # empty means determine automatically
try {
(Invoke-WebRequest http://wttr.in/$GeoLocation -UserAgent "curl" ).Content
(invoke-webRequest http://wttr.in/$GeoLocation -UserAgent "curl" ).Content
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,16 +1,16 @@
#!/snap/bin/powershell
<#
.SYNTAX ./write-big.ps1 [<text>]
.DESCRIPTION writes the given text in big letters
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./write-big.ps1 [<text>]
# Description: writes the given text in big letters
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([String]$Text)
param([string]$Text)
Set-StrictMode -Version Latest
function BigA() { param([Int]$Row)
function BigA() { param([int]$Row)
switch($Row) {
1 { return " __ " }
2 { return " /__\ " }
@ -19,7 +19,7 @@ function BigA() { param([Int]$Row)
}
}
function BigB() { param([Int]$Row)
function BigB() { param([int]$Row)
switch($Row) {
1 { return " ____ " }
2 { return "| _ )" }
@ -28,7 +28,7 @@ function BigB() { param([Int]$Row)
}
}
function BigC() { param([Int]$Row)
function BigC() { param([int]$Row)
switch($Row) {
1 { return " ___ " }
2 { return " / __)" }
@ -37,7 +37,7 @@ function BigC() { param([Int]$Row)
}
}
function BigD() { param([Int]$Row)
function BigD() { param([int]$Row)
switch($Row) {
1 { return " ____ " }
2 { return "| _ \ " }
@ -46,7 +46,7 @@ function BigD() { param([Int]$Row)
}
}
function BigE() { param([Int]$Row)
function BigE() { param([int]$Row)
switch($Row) {
1 { return " ____ " }
2 { return "| ___)" }
@ -55,7 +55,7 @@ function BigE() { param([Int]$Row)
}
}
function BigF() { param([Int]$Row)
function BigF() { param([int]$Row)
switch($Row) {
1 { return " ____ " }
2 { return "| ___)" }
@ -64,7 +64,7 @@ function BigF() { param([Int]$Row)
}
}
function BigG() { param([Int]$Row)
function BigG() { param([int]$Row)
switch($Row) {
1 { return " ____ " }
2 { return " / ___)" }
@ -73,7 +73,7 @@ function BigG() { param([Int]$Row)
}
}
function BigH() { param([Int]$Row)
function BigH() { param([int]$Row)
switch($Row) {
1 { return " _ _ " }
2 { return "| |_| |" }
@ -82,7 +82,7 @@ function BigH() { param([Int]$Row)
}
}
function BigI() { param([Int]$Row)
function BigI() { param([int]$Row)
switch($Row) {
1 { return " _ " }
2 { return "| |" }
@ -91,7 +91,7 @@ function BigI() { param([Int]$Row)
}
}
function BigJ() { param([Int]$Row)
function BigJ() { param([int]$Row)
switch($Row) {
1 { return " __ " }
2 { return " ( |" }
@ -100,7 +100,7 @@ function BigJ() { param([Int]$Row)
}
}
function BigK() { param([Int]$Row)
function BigK() { param([int]$Row)
switch($Row) {
1 { return " _ _ " }
2 { return "| |/ )" }
@ -109,7 +109,7 @@ function BigK() { param([Int]$Row)
}
}
function BigL() { param([Int]$Row)
function BigL() { param([int]$Row)
switch($Row) {
1 { return " _ " }
2 { return "| | " }
@ -118,7 +118,7 @@ function BigL() { param([Int]$Row)
}
}
function BigM() { param([Int]$Row)
function BigM() { param([int]$Row)
switch($Row) {
1 { return " _ _ " }
2 { return "| \ / |" }
@ -127,7 +127,7 @@ function BigM() { param([Int]$Row)
}
}
function BigN() { param([Int]$Row)
function BigN() { param([int]$Row)
switch($Row) {
1 { return " _ _ " }
2 { return "| \ | |" }
@ -136,7 +136,7 @@ function BigN() { param([Int]$Row)
}
}
function BigO() { param([Int]$Row)
function BigO() { param([int]$Row)
switch($Row) {
1 { return " ___ " }
2 { return " / _ \ " }
@ -145,7 +145,7 @@ function BigO() { param([Int]$Row)
}
}
function BigP() { param([Int]$Row)
function BigP() { param([int]$Row)
switch($Row) {
1 { return " ____ " }
2 { return "| _ \" }
@ -154,7 +154,7 @@ function BigP() { param([Int]$Row)
}
}
function BigQ() { param([Int]$Row)
function BigQ() { param([int]$Row)
switch($Row) {
1 { return " ____ " }
2 { return " / _ \ " }
@ -163,7 +163,7 @@ function BigQ() { param([Int]$Row)
}
}
function BigR() { param([Int]$Row)
function BigR() { param([int]$Row)
switch($Row) {
1 { return " ____ " }
2 { return "| _ \" }
@ -172,7 +172,7 @@ function BigR() { param([Int]$Row)
}
}
function BigS() { param([Int]$Row)
function BigS() { param([int]$Row)
switch($Row) {
1 { return " ____ " }
2 { return "/ __)" }
@ -181,7 +181,7 @@ function BigS() { param([Int]$Row)
}
}
function BigT() { param([Int]$Row)
function BigT() { param([int]$Row)
switch($Row) {
1 { return " _____ " }
2 { return "|_ _|" }
@ -190,7 +190,7 @@ function BigT() { param([Int]$Row)
}
}
function BigU() { param([Int]$Row)
function BigU() { param([int]$Row)
switch($Row) {
1 { return " _ _ " }
2 { return "| | | |" }
@ -199,7 +199,7 @@ function BigU() { param([Int]$Row)
}
}
function BigV() { param([Int]$Row)
function BigV() { param([int]$Row)
switch($Row) {
1 { return " _ _ " }
2 { return "( \/ )" }
@ -208,7 +208,7 @@ function BigV() { param([Int]$Row)
}
}
function BigW() { param([Int]$Row)
function BigW() { param([int]$Row)
switch($Row) {
1 { return " __ __ " }
2 { return "\ \/\/ /" }
@ -217,7 +217,7 @@ function BigW() { param([Int]$Row)
}
}
function BigX() { param([Int]$Row)
function BigX() { param([int]$Row)
switch($Row) {
1 { return " _ _ " }
2 { return "( \/ )" }
@ -226,7 +226,7 @@ function BigX() { param([Int]$Row)
}
}
function BigY() { param([Int]$Row)
function BigY() { param([int]$Row)
switch($Row) {
1 { return " _ _ " }
2 { return "( \/ )" }
@ -235,7 +235,7 @@ function BigY() { param([Int]$Row)
}
}
function BigZ() { param([Int]$Row)
function BigZ() { param([int]$Row)
switch($Row) {
1 { return " ____ " }
2 { return "(_ )" }
@ -245,7 +245,7 @@ function BigZ() { param([Int]$Row)
}
function Big0() { param([Int]$Row)
function Big0() { param([int]$Row)
switch($Row) {
1 { return " ___ " }
2 { return " / _ \ " }
@ -254,7 +254,7 @@ function Big0() { param([Int]$Row)
}
}
function Big1() { param([Int]$Row)
function Big1() { param([int]$Row)
switch($Row) {
1 { return " ___ " }
2 { return "/_ |" }
@ -263,7 +263,7 @@ function Big1() { param([Int]$Row)
}
}
function Big2() { param([Int]$Row)
function Big2() { param([int]$Row)
switch($Row) {
1 { return " ___ " }
2 { return "(__ \ " }
@ -272,7 +272,7 @@ function Big2() { param([Int]$Row)
}
}
function Big3() { param([Int]$Row)
function Big3() { param([int]$Row)
switch($Row) {
1 { return " ___ " }
2 { return "(__ )" }
@ -281,7 +281,7 @@ function Big3() { param([Int]$Row)
}
}
function Big4() { param([Int]$Row)
function Big4() { param([int]$Row)
switch($Row) {
1 { return " __ " }
2 { return " /. | " }
@ -290,7 +290,7 @@ function Big4() { param([Int]$Row)
}
}
function Big5() { param([Int]$Row)
function Big5() { param([int]$Row)
switch($Row) {
1 { return " ____ " }
2 { return "| ___)" }
@ -299,7 +299,7 @@ function Big5() { param([Int]$Row)
}
}
function Big6() { param([Int]$Row)
function Big6() { param([int]$Row)
switch($Row) {
1 { return " _ " }
2 { return " / ) " }
@ -308,7 +308,7 @@ function Big6() { param([Int]$Row)
}
}
function Big7() { param([Int]$Row)
function Big7() { param([int]$Row)
switch($Row) {
1 { return " ___ " }
2 { return "(__ )" }
@ -317,7 +317,7 @@ function Big7() { param([Int]$Row)
}
}
function Big8() { param([Int]$Row)
function Big8() { param([int]$Row)
switch($Row) {
1 { return " ___ " }
2 { return "( _ )" }
@ -326,7 +326,7 @@ function Big8() { param([Int]$Row)
}
}
function Big9() { param([Int]$Row)
function Big9() { param([int]$Row)
switch($Row) {
1 { return " ___ " }
2 { return "/ _ \" }
@ -335,7 +335,7 @@ function Big9() { param([Int]$Row)
}
}
function BigColon() { param([Int]$Row)
function BigColon() { param([int]$Row)
switch($Row) {
1 { return " " }
2 { return " o " }
@ -344,7 +344,7 @@ function BigColon() { param([Int]$Row)
}
}
function BigMinus() { param([Int]$Row)
function BigMinus() { param([int]$Row)
switch($Row) {
1 { return " " }
2 { return " ____ " }
@ -353,7 +353,7 @@ function BigMinus() { param([Int]$Row)
}
}
function BigChar() { param([String]$Char, [Int]$Row)
function BigChar() { param([string]$Char, [int]$Row)
switch($Char) {
'A' { return BigA $Row }
'B' { return BigB $Row }

View File

@ -1,17 +1,18 @@
#!/snap/bin/powershell
<#
.SYNTAX ./write-blue.ps1 [<text>]
.DESCRIPTION writes the given text in a blue foreground color
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./write-blue.ps1 [<text>]
# Description: writes the given text in a blue foreground color
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$Text)
param([String]$Text)
try {
if ($Text -eq "" ) {
[String]$Text = read-host "Enter text to write"
}
write-host -foregroundcolor blue $Text
write-host -foregroundColor blue $Text
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,14 +1,14 @@
#!/snap/bin/powershell
<#
.SYNTAX write-braille.ps1 [<text>]
.DESCRIPTION writes the given text in Braille
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./write-braille.ps1 [<text>]
# Description: writes the given text in Braille
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$Text)
param([String]$Text)
function BrailleA() { param([Int]$Row)
function BrailleA() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return "oo" }
@ -16,7 +16,7 @@ function BrailleA() { param([Int]$Row)
}
}
function BrailleB() { param([Int]$Row)
function BrailleB() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return ".o" }
@ -24,7 +24,7 @@ function BrailleB() { param([Int]$Row)
}
}
function BrailleC() { param([Int]$Row)
function BrailleC() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return "oo" }
@ -32,7 +32,7 @@ function BrailleC() { param([Int]$Row)
}
}
function BrailleD() { param([Int]$Row)
function BrailleD() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return "o." }
@ -40,7 +40,7 @@ function BrailleD() { param([Int]$Row)
}
}
function BrailleE() { param([Int]$Row)
function BrailleE() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return "o." }
@ -48,7 +48,7 @@ function BrailleE() { param([Int]$Row)
}
}
function BrailleF() { param([Int]$Row)
function BrailleF() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return ".o" }
@ -56,7 +56,7 @@ function BrailleF() { param([Int]$Row)
}
}
function BrailleG() { param([Int]$Row)
function BrailleG() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return ".." }
@ -64,7 +64,7 @@ function BrailleG() { param([Int]$Row)
}
}
function BrailleH() { param([Int]$Row)
function BrailleH() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return ".." }
@ -72,7 +72,7 @@ function BrailleH() { param([Int]$Row)
}
}
function BrailleI() { param([Int]$Row)
function BrailleI() { param([int]$Row)
switch($Row) {
1 { return "o." }
2 { return ".o" }
@ -80,7 +80,7 @@ function BrailleI() { param([Int]$Row)
}
}
function BrailleJ() { param([Int]$Row)
function BrailleJ() { param([int]$Row)
switch($Row) {
1 { return "o." }
2 { return ".." }
@ -88,7 +88,7 @@ function BrailleJ() { param([Int]$Row)
}
}
function BrailleK() { param([Int]$Row)
function BrailleK() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return "oo" }
@ -96,7 +96,7 @@ function BrailleK() { param([Int]$Row)
}
}
function BrailleL() { param([Int]$Row)
function BrailleL() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return ".o" }
@ -104,7 +104,7 @@ function BrailleL() { param([Int]$Row)
}
}
function BrailleM() { param([Int]$Row)
function BrailleM() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return "oo" }
@ -112,7 +112,7 @@ function BrailleM() { param([Int]$Row)
}
}
function BrailleN() { param([Int]$Row)
function BrailleN() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return "o." }
@ -120,7 +120,7 @@ function BrailleN() { param([Int]$Row)
}
}
function BrailleO() { param([Int]$Row)
function BrailleO() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return "o." }
@ -128,7 +128,7 @@ function BrailleO() { param([Int]$Row)
}
}
function BrailleP() { param([Int]$Row)
function BrailleP() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return ".o" }
@ -136,7 +136,7 @@ function BrailleP() { param([Int]$Row)
}
}
function BrailleQ() { param([Int]$Row)
function BrailleQ() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return ".." }
@ -144,7 +144,7 @@ function BrailleQ() { param([Int]$Row)
}
}
function BrailleR() { param([Int]$Row)
function BrailleR() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return ".." }
@ -152,7 +152,7 @@ function BrailleR() { param([Int]$Row)
}
}
function BrailleS() { param([Int]$Row)
function BrailleS() { param([int]$Row)
switch($Row) {
1 { return "o." }
2 { return ".o" }
@ -160,7 +160,7 @@ function BrailleS() { param([Int]$Row)
}
}
function BrailleT() { param([Int]$Row)
function BrailleT() { param([int]$Row)
switch($Row) {
1 { return "o." }
2 { return ".." }
@ -168,7 +168,7 @@ function BrailleT() { param([Int]$Row)
}
}
function BrailleU() { param([Int]$Row)
function BrailleU() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return "oo" }
@ -176,7 +176,7 @@ function BrailleU() { param([Int]$Row)
}
}
function BrailleV() { param([Int]$Row)
function BrailleV() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return ".o" }
@ -184,7 +184,7 @@ function BrailleV() { param([Int]$Row)
}
}
function BrailleW() { param([Int]$Row)
function BrailleW() { param([int]$Row)
switch($Row) {
1 { return "o." }
2 { return ".." }
@ -192,7 +192,7 @@ function BrailleW() { param([Int]$Row)
}
}
function BrailleX() { param([Int]$Row)
function BrailleX() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return "oo" }
@ -200,7 +200,7 @@ function BrailleX() { param([Int]$Row)
}
}
function BrailleY() { param([Int]$Row)
function BrailleY() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return "o." }
@ -208,7 +208,7 @@ function BrailleY() { param([Int]$Row)
}
}
function BrailleZ() { param([Int]$Row)
function BrailleZ() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return "o." }
@ -216,7 +216,7 @@ function BrailleZ() { param([Int]$Row)
}
}
function Braille1() { param([Int]$Row)
function Braille1() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return "oo" }
@ -224,7 +224,7 @@ function Braille1() { param([Int]$Row)
}
}
function Braille2() { param([Int]$Row)
function Braille2() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return ".o" }
@ -232,7 +232,7 @@ function Braille2() { param([Int]$Row)
}
}
function Braille3() { param([Int]$Row)
function Braille3() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return "oo" }
@ -240,7 +240,7 @@ function Braille3() { param([Int]$Row)
}
}
function Braille4() { param([Int]$Row)
function Braille4() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return "o." }
@ -248,7 +248,7 @@ function Braille4() { param([Int]$Row)
}
}
function Braille5() { param([Int]$Row)
function Braille5() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return "o." }
@ -256,7 +256,7 @@ function Braille5() { param([Int]$Row)
}
}
function Braille6() { param([Int]$Row)
function Braille6() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return ".o" }
@ -264,7 +264,7 @@ function Braille6() { param([Int]$Row)
}
}
function Braille7() { param([Int]$Row)
function Braille7() { param([int]$Row)
switch($Row) {
1 { return ".." }
2 { return ".." }
@ -272,7 +272,7 @@ function Braille7() { param([Int]$Row)
}
}
function Braille8() { param([Int]$Row)
function Braille8() { param([int]$Row)
switch($Row) {
1 { return ".o" }
2 { return ".." }
@ -280,7 +280,7 @@ function Braille8() { param([Int]$Row)
}
}
function Braille9() { param([Int]$Row)
function Braille9() { param([int]$Row)
switch($Row) {
1 { return "o." }
2 { return ".o" }
@ -288,7 +288,7 @@ function Braille9() { param([Int]$Row)
}
}
function Braille0() { param([Int]$Row)
function Braille0() { param([int]$Row)
switch($Row) {
1 { return "o." }
2 { return ".." }
@ -296,7 +296,7 @@ function Braille0() { param([Int]$Row)
}
}
function BrailleChar() { param([String]$Char, [Int]$Row)
function BrailleChar() { param([string]$Char, [int]$Row)
switch($Char) {
'A' { return BrailleA $Row }
'B' { return BrailleB $Row }

View File

@ -1,17 +1,18 @@
#!/snap/bin/powershell
<#
.SYNTAX ./write-green.ps1 [<text>]
.DESCRIPTION writes the given text in a green foreground color
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./write-green.ps1 [<text>]
# Description: writes the given text in a green foreground color
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$Text = "")
param([String]$Text)
try {
if ($Text -eq "" ) {
[String]$Text = read-host "Enter text to write"
[string]$Text = read-host "Enter text to write"
}
write-host -foregroundcolor green $Text
write-host -foregroundColor green $Text
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,17 +1,18 @@
#!/snap/bin/powershell
<#
.SYNTAX ./write-logbook.ps1 [<text>]
.DESCRIPTION writes the given text to the logbook (../Data/Logbook.csv)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./write-logbook.ps1 [<text>]
# Description: writes the given text to the logbook (../Data/Logbook.csv)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$Text = "")
param([String]$Text)
try {
$Time = Get-Date -format "yyyy-MM-ddTHH:mm:ssZ" -AsUTC
$Time = get-date -format "yyyy-MM-ddTHH:mm:ssZ" -asUTC
$User = $(whoami)
if ($Text -eq "" ) {
[String]$Text = read-host "Enter text to write"
[string]$Text = read-host "Enter text to write"
}
$Line = "$Time,$User,$Text"

View File

@ -1,16 +1,15 @@
#!/snap/bin/powershell
<#
.SYNTAX ./write-morse-code.ps1 [<text>] [<speed>]
.DESCRIPTION writes the given text in Morse code
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./write-morse-code.ps1 [<text>]
# Description: writes the given text in Morse code
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$Text, [int]$OneTimeUnit = 100) # in milliseconds
param([String]$Text)
$OneTimeUnit = 100 # milliseconds
function gap() { param([Int]$Length)
for ($i = 1; $i -lt $Length; $i++) {
function gap() { param([int]$Length)
for ([int]$i = 1; $i -lt $Length; $i++) {
write-host " " -nonewline
}
start-sleep -milliseconds ($Length * $OneTimeUnit)
@ -26,7 +25,7 @@ function dash() {
start-sleep -milliseconds (3 * $OneTimeUnit) # signal
}
function Char2MorseCode() { param([String]$Char)
function Char2MorseCode() { param([string]$Char)
switch($Char) {
'A' { dot; gap 1; dash; gap 3 }
'B' { dash; gap 1; dot; gap 1; dot; gap 1; dot; gap 3 }
@ -70,7 +69,7 @@ function Char2MorseCode() { param([String]$Char)
try {
if ($Text -eq "" ) {
[String]$Text = read-host "Enter text to write"
[string]$Text = read-host "Enter text to write"
}
[char[]]$ArrayOfChars = $Text.ToUpper()
foreach($Char in $ArrayOfChars) {

View File

@ -1,14 +1,12 @@
#!/snap/bin/powershell
# Syntax: ./write-motd.ps1
# Description: writes the message of the day (MOTD)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./write-motd.ps1
.DESCRIPTION writes the message of the day (MOTD)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Retrieve information:
$CurrentTime = Get-Date -format "yyyy-MM-dd HH:mm"
$TimeZone = (Get-TimeZone).id
$UserName = $(whoami)

View File

@ -1,15 +1,16 @@
#!/snap/bin/powershell
<#
.SYNTAX ./write-red.ps1 [<text>]
.DESCRIPTION writes the given text in a red foreground color
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./write-red.ps1 [<text>]
# Description: writes the given text in a red foreground color
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$Text = "")
param([String]$Text)
try {
if ($Text -eq "" ) {
[String]$Text = read-host "Enter text to write"
[string]$Text = read-host "Enter text to write"
}
write-host -foregroundcolor red $Text
exit 0

View File

@ -1,14 +1,14 @@
#!/snap/bin/powershell
<#
.SYNTAX ./write-rot13.ps1 [<text>]
.DESCRIPTION encodes or decodes the given text with ROT13
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./write-rot13.ps1 [<text>]
# Description: encodes or decodes the given text with ROT13
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$Text)
param([String]$Text)
function ROT13 { param([String]$Text)
function ROT13 { param([string]$Text)
$Text.ToCharArray() | ForEach-Object {
if ((([int] $_ -ge 97) -and ([int] $_ -le 109)) -or (([int] $_ -ge 65) -and ([int] $_ -le 77))) {
$Result += [char] ([int] $_ + 13);
@ -23,7 +23,7 @@ function ROT13 { param([String]$Text)
try {
if ($Text -eq "" ) {
[String]$Text = read-host "Enter text to write"
[string]$Text = read-host "Enter text to write"
}
$Result = ROT13 $Text
write-output $Result

View File

@ -1,23 +1,23 @@
#!/snap/bin/powershell
<#
.SYNTAX ./write-typewriter.ps1 [<text>] [<speed>]
.DESCRIPTION writes the given text with the typewriter effect
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./write-typewriter.ps1 [<text>]
# Description: writes the given test with the typewriter effect
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$Text = "", [int]$Speed = 250) # in milliseconds
param([string]$Text)
if ($Text -eq "" ) {
$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"
}
$Speed = 250 # milliseconds
try {
$Random = New-Object System.Random
$Text -split '' | ForEach-Object {
Write-Host -nonewline $_
Start-Sleep -milliseconds $(1 + $Random.Next($Speed))
write-host -nonewline $_
start-sleep -milliseconds $(1 + $Random.Next($Speed))
}
exit 0
} catch {

View File

@ -1,15 +1,16 @@
#!/snap/bin/powershell
<#
.SYNTAX ./write-uppercase.ps1 [<text>]
.DESCRIPTION writes the given text in uppercase letters
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./write-uppercase.ps1 [<text>]
# Description: writes the given text in uppercase letters
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$Text = "")
param([String]$Text)
try {
if ($Text -eq "" ) {
[String]$Text = read-host "Enter text to write"
[string]$Text = read-host "Enter text to write"
}
write-output $Text.ToUpper()
exit 0

View File

@ -1,12 +1,13 @@
#!/snap/bin/powershell
<#
.SYNTAX ./write-vertical.ps1 [<text>]
.DESCRIPTION writes the given text in vertical direction
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
# Syntax: ./write-vertical.ps1 [<text>]
# Description: writes the given text in vertical direction
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([string]$Text = "")
param([String]$Text)
try {
if ($Text -eq "" ) {
[String]$Text = read-host "Enter text to write"

View File

@ -1,18 +1,20 @@
#!/snap/bin/powershell
# Syntax: ./zip-dir.ps1 [<path-to-folder>]
# Description: creates a zip archive of the given folder
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
<#
.SYNTAX ./zip-dir.ps1 [<path-to-folder>]
.DESCRIPTION creates a zip archive of the given folder
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param([string]$Path)
try {
if ($Path -eq "" ) {
$URL = read-host "Enter path to folder to zip"
$URL = read-host "Enter path to folder"
}
Compress-Archive -Path $Path -DestinationPath $Path.zip
compress-archive -path $Path -destinationPath $Path.zip
write-output "OK - folder has been compressed to $($Path).zip"
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"