Add example output

This commit is contained in:
Markus Fleschutz 2021-10-04 17:42:06 +02:00
parent 7ddc6617c6
commit a1ec7f0183
34 changed files with 57 additions and 18 deletions

View File

@ -1,10 +1,13 @@
<# <#
.SYNOPSIS .SYNOPSIS
add-firewall-rules.ps1 [<path-to-executables>] add-firewall-rules.ps1 [<PathToExecutables>]
.DESCRIPTION .DESCRIPTION
Adds firewall rules for the given executables (needs administrator rights) Adds firewall rules for the given executables (needs admin rights)
.EXAMPLE .EXAMPLE
PS> ./add-firewall-rules C:\MyApp\bin PS> ./add-firewall-rules C:\MyApp\bin
Adding firewall rule for C:\MyApp\bin\app1.exe
Adding firewall rule for C:\MyApp\bin\app2.exe
...
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Adds the given memo text to $HOME/Memos.csv Adds the given memo text to $HOME/Memos.csv
.EXAMPLE .EXAMPLE
PS> ./add-memo "Buy apples" PS> ./add-memo "Buy apples"
added to 📄/home/markus/Memos.csv
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to the user's documents folder Change the working directory to the user's documents folder
.EXAMPLE .EXAMPLE
PS> ./cd-docs PS> ./cd-docs
📂/home/markus/Documents
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to the user's downloads folder Change the working directory to the user's downloads folder
.EXAMPLE .EXAMPLE
PS> ./cd-downloads PS> ./cd-downloads
📂/home/markus/Downloads
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to the user's Dropbox folder Change the working directory to the user's Dropbox folder
.EXAMPLE .EXAMPLE
PS> ./cd-dropbox PS> ./cd-dropbox
📂/home/markus/Dropbox
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to the user's home directory Change the working directory to the user's home directory
.EXAMPLE .EXAMPLE
PS> ./cd-home PS> ./cd-home
📂/home/markus
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to the user's music folder Change the working directory to the user's music folder
.EXAMPLE .EXAMPLE
PS> ./cd-music PS> ./cd-music
📂/home/markus/Music
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to the user's OneDrive folder Change the working directory to the user's OneDrive folder
.EXAMPLE .EXAMPLE
PS> ./cd-onedrive PS> ./cd-onedrive
📂/home/markus/OneDrive
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to the user's pictures folder Change the working directory to the user's pictures folder
.EXAMPLE .EXAMPLE
PS> ./cd-pics PS> ./cd-pics
📂/home/markus/Pictures
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to the user's recycle bin folder Change the working directory to the user's recycle bin folder
.EXAMPLE .EXAMPLE
PS> ./cd-recycle-bin PS> ./cd-recycle-bin
📂C:\$Recycle.Bin\S-1-5-21-123404-23309-294260-1001
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to the user's Git repositories folder Change the working directory to the user's Git repositories folder
.EXAMPLE .EXAMPLE
PS> ./cd-repos PS> ./cd-repos
📂/home/markus/Repos
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to the root directory (C:\ on Windows) Change the working directory to the root directory (C:\ on Windows)
.EXAMPLE .EXAMPLE
PS> ./cd-root PS> ./cd-root
📂C:\
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -14,7 +15,7 @@
if ($IsLinux) { if ($IsLinux) {
$TargetDir = resolve-path "/" $TargetDir = resolve-path "/"
} else { } else {
$TargetDir = resolve-path "C:/" $TargetDir = resolve-path "C:\"
} }
if (-not(test-path "$TargetDir" -pathType container)) { if (-not(test-path "$TargetDir" -pathType container)) {
write-warning "Sorry, the root directory at 📂$TargetDir does not exist (yet)" write-warning "Sorry, the root directory at 📂$TargetDir does not exist (yet)"

View File

@ -5,6 +5,7 @@
Change the working directory to the PowerShell scripts folder Change the working directory to the PowerShell scripts folder
.EXAMPLE .EXAMPLE
PS> ./cd-scripts PS> ./cd-scripts
📂/home/markus/PowerShell/Scripts
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to the user's SSH folder Change the working directory to the user's SSH folder
.EXAMPLE .EXAMPLE
PS> ./cd-ssh PS> ./cd-ssh
📂/home/markus/.ssh
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to one level up Change the working directory to one level up
.EXAMPLE .EXAMPLE
PS> .\cd-up PS> .\cd-up
(one level up)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to two directory levels up Change the working directory to two directory levels up
.EXAMPLE .EXAMPLE
PS> ./cd-up2 PS> ./cd-up2
(two levels up)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to three directory levels up Change the working directory to three directory levels up
.EXAMPLE .EXAMPLE
PS> ./cd-up3 PS> ./cd-up3
(three levels up)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to four directory levels up Change the working directory to four directory levels up
.EXAMPLE .EXAMPLE
PS> ./cd-up4 PS> ./cd-up4
(four levels up)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Change the working directory to the user's videos folder Change the working directory to the user's videos folder
.EXAMPLE .EXAMPLE
PS> ./cd-videos PS> ./cd-videos
📂/home/markus/Videos
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Checks the DNS resolution with frequently used domain names Checks the DNS resolution with frequently used domain names
.EXAMPLE .EXAMPLE
PS> ./check-dns-resolution PS> ./check-dns-resolution
11.8 domains/sec (177 domains resolved in 15 sec)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -30,7 +31,7 @@ try {
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
$Average = [math]::round($Count / $Elapsed, 1) $Average = [math]::round($Count / $Elapsed, 1)
"✔️ $Average domains/s ($Count domains resolved in $Elapsed sec)" "✔️ $Average domains/sec ($Count domains resolved in $Elapsed sec)"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"

View File

@ -5,6 +5,7 @@
Checks a drive for free space left (20 GB by default) Checks a drive for free space left (20 GB by default)
.EXAMPLE .EXAMPLE
PS> ./check-drive-space C PS> ./check-drive-space C
172 GB left on drive C (61 of 233 GB used)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Checks the file system of a drive (needs admin rights) Checks the file system of a drive (needs admin rights)
.EXAMPLE .EXAMPLE
PS> ./check-file-system C PS> ./check-file-system C
file system on drive C is clean
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,12 @@
Checks the health of the local computer Checks the health of the local computer
.EXAMPLE .EXAMPLE
PS> ./check-health PS> ./check-health
1213 GB left for swap space (67 of 1280 GB used)
172 GB left on drive C (61 of 233 GB used)
30.3 °C CPU temperature - good
19.7 domains/s (177 domains resolved in 9 sec)
29 ms ping average (13 ms min, 110 ms max, 10 hosts)
Windmill is healthy
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -12,9 +18,7 @@
License: CC0 License: CC0
#> #>
$Hostname = $(hostname)
$Healthy = 1 $Healthy = 1
"Checking $Hostname's health..."
& "$PSScriptRoot/check-swap-space.ps1" & "$PSScriptRoot/check-swap-space.ps1"
if ($lastExitCode -ne "0") { $Healthy = 0 } if ($lastExitCode -ne "0") { $Healthy = 0 }
@ -41,6 +45,7 @@ if ($IsLinux) {
if ($lastExitCode -ne "0") { $Healthy = 0 } if ($lastExitCode -ne "0") { $Healthy = 0 }
} }
$Hostname = $(hostname)
if ($Healthy) { if ($Healthy) {
"✔️ $Hostname is healthy" "✔️ $Hostname is healthy"
exit 0 # success exit 0 # success

View File

@ -1,10 +1,11 @@
<# <#
.SYNOPSIS .SYNOPSIS
check-ipv4-address.ps1 [<address>] check-ipv4-address.ps1 [<Address>]
.DESCRIPTION .DESCRIPTION
Checks the given IPv4 address for validity Checks the given IPv4 address for validity
.EXAMPLE .EXAMPLE
PS> ./check-ipv4-address 192.168.11.22 PS> ./check-ipv4-address 192.168.11.22
IPv4 192.168.11.22 is valid
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -26,7 +27,7 @@ try {
if ($Address -eq "" ) { $Address = read-host "Enter IPv4 address to validate" } if ($Address -eq "" ) { $Address = read-host "Enter IPv4 address to validate" }
if (IsIPv4AddressValid $Address) { if (IsIPv4AddressValid $Address) {
"✔️ IPv4 address $Address is valid" "✔️ IPv4 $Address is valid"
exit 0 # success exit 0 # success
} else { } else {
write-warning "Invalid IPv4 address: $Address" write-warning "Invalid IPv4 address: $Address"

View File

@ -1,10 +1,11 @@
<# <#
.SYNOPSIS .SYNOPSIS
check-ipv6-address.ps1 [<address>] check-ipv6-address.ps1 [<Address>]
.DESCRIPTION .DESCRIPTION
Checks the given IPv6 address for validity Checks the given IPv6 address for validity
.EXAMPLE .EXAMPLE
PS> ./check-ipv6-address fe80::200:5aee:feaa:20a2 PS> ./check-ipv6-address fe80::200:5aee:feaa:20a2
IPv6 fe80::200:5aee:feaa:20a2 is valid
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -40,7 +41,7 @@ try {
$Address = read-host "Enter IPv6 address to validate" $Address = read-host "Enter IPv6 address to validate"
} }
if (IsIPv6AddressValid $Address) { if (IsIPv6AddressValid $Address) {
"✔️ IPv6 address $Address is valid" "✔️ IPv6 $Address is valid"
exit 0 # success exit 0 # success
} else { } else {
write-warning "Invalid IPv6 address: $Address" write-warning "Invalid IPv6 address: $Address"

View File

@ -5,6 +5,7 @@
Checks the given MAC address for validity (MAC address like 00:00:00:00:00:00 or 00-00-00-00-00-00 or 000000000000). Checks the given MAC address for validity (MAC address like 00:00:00:00:00:00 or 00-00-00-00-00-00 or 000000000000).
.EXAMPLE .EXAMPLE
PS> ./check-mac-address 11:22:33:44:55:66 PS> ./check-mac-address 11:22:33:44:55:66
MAC address 11:22:33:44:55:66 is valid
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -6,6 +6,7 @@
(default is: 'amazon.com,apple.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com) (default is: 'amazon.com,apple.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com)
.EXAMPLE .EXAMPLE
PS> ./check-ping PS> ./check-ping
36 ms ping average (13 ms min, 109 ms max, 10 hosts)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -34,7 +35,7 @@ try {
} }
$Avg = $Avg / $Pings.count $Avg = $Avg / $Pings.count
"✔️ $Avg ms net latency average ($Min ms min, $Max ms max, $($Pings.count) hosts)" "✔️ $Avg ms ping average ($Min ms min, $Max ms max, $($Pings.count) hosts)"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"

View File

@ -5,6 +5,7 @@
Checks the given subnet mask for validity Checks the given subnet mask for validity
.EXAMPLE .EXAMPLE
PS> ./check-subnet-mask 255.255.255.0 PS> ./check-subnet-mask 255.255.255.0
subnet mask 255.255.255.0 is valid
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Checks the free swap space Checks the free swap space
.EXAMPLE .EXAMPLE
PS> ./check-swap-space PS> ./check-swap-space
1213 GB left for swap space (67 of 1280 GB used)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -36,7 +37,7 @@ try {
write-warning "Swap space has only $Free GB left to use! ($Used of $Total GB used, minimum is $MinLevel GB)" write-warning "Swap space has only $Free GB left to use! ($Used of $Total GB used, minimum is $MinLevel GB)"
exit 1 exit 1
} }
"✔️ $Free GB left on swap space ($Used of $Total GB used)" "✔️ $Free GB left for swap space ($Used of $Total GB used)"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))" "⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"

View File

@ -5,6 +5,7 @@
Checks the validity of the Windows system files (requires admin rights) Checks the validity of the Windows system files (requires admin rights)
.EXAMPLE .EXAMPLE
PS> ./check-windows-system-files PS> ./check-windows-system-files
checked Windows system files
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES

View File

@ -5,6 +5,7 @@
Checks the given XML file for validity Checks the given XML file for validity
.EXAMPLE .EXAMPLE
PS> ./check-xml-file myfile.xml PS> ./check-xml-file myfile.xml
XML file is valid
.NOTES .NOTES
Author: Markus Fleschutz · License: CC0 Author: Markus Fleschutz · License: CC0
.LINK .LINK

View File

@ -5,6 +5,8 @@
Cleans a Git repository from untracked files (including submodules, e.g. for a fresh build) Cleans a Git repository from untracked files (including submodules, e.g. for a fresh build)
.EXAMPLE .EXAMPLE
PS> ./clean-repo C:\MyRepo PS> ./clean-repo C:\MyRepo
🧹 Cleaning Git repository 📂C:\MyRepo from untracked files...
cleaned Git repository 📂C:\MyRepo in 0 sec
.NOTES .NOTES
Author: Markus Fleschutz · License: CC0 Author: Markus Fleschutz · License: CC0
.LINK .LINK

View File

@ -6,6 +6,7 @@
NOTE: can not be undo! NOTE: can not be undo!
.EXAMPLE .EXAMPLE
PS> ./clear-recycle-bin PS> ./clear-recycle-bin
cleared recycle bin
.NOTES .NOTES
Author: Markus Fleschutz · License: CC0 Author: Markus Fleschutz · License: CC0
.LINK .LINK

View File

@ -18,27 +18,26 @@ try {
$StopWatch = [system.diagnostics.stopwatch]::startNew() $StopWatch = [system.diagnostics.stopwatch]::startNew()
"" "⏳ Step 1/3: Searching for IPFS executable..."
"👉 Step 1/3: Searching IPFS executable..."
& ipfs --version & ipfs --version
if ($lastExitCode -ne "0") { throw "Can't execute 'ipfs' - make sure IPFS is installed and available" } if ($lastExitCode -ne "0") { throw "Can't execute 'ipfs' - make sure IPFS is installed and available" }
if (test-path "$FilePattern" -pathType container) { if (test-path "$FilePattern" -pathType container) {
"" ""
"👉 Step 2/3: Publishing folder $FilePattern/..." " Step 2/3: Publishing folder $FilePattern/..."
& ipfs add -r "$FilePattern" > $HashList & ipfs add -r "$FilePattern" > $HashList
[int]$Count = 1 [int]$Count = 1
"" ""
"👉 Step 3/3: Calculating digital forensics hashes to $DF_HASHES ..." " Step 3/3: Calculating digital forensics hashes to $DF_HASHES ..."
& nice hashdeep -c md5,sha1,sha256 -r -d -l -j 1 "$FilePattern" > $DF_Hashes & nice hashdeep -c md5,sha1,sha256 -r -d -l -j 1 "$FilePattern" > $DF_Hashes
} else { } else {
$FileList = (get-childItem "$FilePattern") $FileList = (get-childItem "$FilePattern")
foreach ($File in $FileList) { foreach ($File in $FileList) {
if (test-path "$FilePattern" -pathType container) { if (test-path "$FilePattern" -pathType container) {
"👉 Step 2/3: Publishing folder $File/..." " Step 2/3: Publishing folder $File/..."
& ipfs add -r "$File" >> $HashList & ipfs add -r "$File" >> $HashList
} else { } else {
"👉 Step 2/3: Publishing file $File..." "⏳ Step 3/3: Publishing file $File..."
& ipfs add "$File" >> $HashList & ipfs add "$File" >> $HashList
} }
} }