diff --git a/Docs/add-firewall-rules.md b/Docs/add-firewall-rules.md index 1150a34c..a2290537 100644 --- a/Docs/add-firewall-rules.md +++ b/Docs/add-firewall-rules.md @@ -1,4 +1,4 @@ -## add-firewall-rules.ps1 - Adds firewall rules for executables (needs admin rights) +## The add-firewall-rules.ps1 PowerShell Script This PowerShell script adds firewall rules for the given executable. Administrator rights are required. @@ -35,4 +35,70 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Adds firewall rules for executables (needs admin rights) +.DESCRIPTION + This PowerShell script adds firewall rules for the given executable. Administrator rights are required. +.PARAMETER PathToExecutables + Specifies the path to the executables +.EXAMPLE + 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 + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +param([string]$PathToExecutables = "") + +$command = ' +$output = ''Firewall rules for path '' + $args[0] +write-output $output +for($i = 1; $i -lt $args.count; $i++){ + $path = $args[0] + $path += ''\'' + $path += $args[$i] + + $null = $args[$i] -match ''[^\\]*\.exe$'' + $name = $matches[0] + $output = ''Adding firewall rule for '' + $name + write-output $output + $null = New-NetFirewallRule -DisplayName $name -Direction Inbound -Program $path -Profile Domain, Private -Action Allow +} +write-host -foregroundColor green -noNewline ''Done - press any key to continue...''; +[void]$Host.UI.RawUI.ReadKey(''NoEcho,IncludeKeyDown''); +' + + +try { + if ($PathToExecutables -eq "" ) { + $PathToExecutables = read-host "Enter path to executables" + } + + $PathToExecutables = Convert-Path -Path $PathToExecutables + + $Apps = Get-ChildItem "$PathToExecutables\*.exe" -Name + + if($Apps.count -eq 0){ + write-warning "No executables found. No Firewall rules have been created." + Write-Host -NoNewhLine 'Press any key to continue...'; + [void]$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown'); + exit 1 + } + + $arg = "PathToExecutables $Apps" + Start-Process powershell -Verb runAs -ArgumentList "-command & {$command} $arg" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of add-firewall-rules.ps1* diff --git a/Docs/add-memo.md b/Docs/add-memo.md index a7205df5..b64a52d9 100644 --- a/Docs/add-memo.md +++ b/Docs/add-memo.md @@ -1,4 +1,4 @@ -## add-memo.ps1 - Adds a memo text +## The add-memo.ps1 PowerShell Script This PowerShell script adds the given memo text to $HOME/Memos.csv. @@ -33,4 +33,43 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Adds a memo text +.DESCRIPTION + This PowerShell script adds the given memo text to $HOME/Memos.csv. +.PARAMETER text + Specifies the text to memorize +.EXAMPLE + PS> ./add-memo "Buy apples" + โœ”๏ธ added to ๐Ÿ“„/home/markus/Memos.csv +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "" ) { $text = read-host "Enter the memo text to add" } + + $Path = "$HOME/Memos.csv" + $Time = get-date -format "yyyy-MM-ddTHH:mm:ssZ" -asUTC + $User = $(whoami) + $Line = "$Time,$User,$text" + + if (-not(test-path "$Path" -pathType leaf)) { + write-output "Time,User,text" > "$Path" + } + write-output $Line >> "$Path" + + "โœ”๏ธ added to ๐Ÿ“„$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of add-memo.ps1* diff --git a/Docs/alert.md b/Docs/alert.md index a7ff2b7a..60aaae9a 100644 --- a/Docs/alert.md +++ b/Docs/alert.md @@ -1,4 +1,4 @@ -## alert.ps1 - Handles and escalates an alert +## The alert.ps1 PowerShell Script This PowerShell script handles and escalates the given alert message. @@ -32,4 +32,35 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Handles and escalates an alert +.DESCRIPTION + This PowerShell script handles and escalates the given alert message. +.PARAMETER message + Specifies the alert message +.EXAMPLE + PS> ./alert "Harddisk failure" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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 + + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of alert.ps1* diff --git a/Docs/build-repo.md b/Docs/build-repo.md index b6e3ade6..8e5b103f 100644 --- a/Docs/build-repo.md +++ b/Docs/build-repo.md @@ -1,4 +1,4 @@ -## build-repo.ps1 - Builds a Git repository +## The build-repo.ps1 PowerShell Script This PowerShell script supports building with cmake, configure, autogen, Imakefile and Makefile. @@ -32,4 +32,134 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Builds a Git repository +.DESCRIPTION + This PowerShell script supports building with cmake, configure, autogen, Imakefile and Makefile. +.PARAMETER RepoDir + Specifies the path to the Git repository +.EXAMPLE + PS> ./build-repo C:\MyRepo +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RepoDir = "$PWD") + +function MakeDir { param($Path) + $DirName = (get-item "$Path").Name + if (test-path "$Path/CMakeLists.txt" -pathType leaf) { + "๐Ÿ”จ Building ๐Ÿ“‚$DirName using CMakeLists.txt to subfolder _My_Build/..." + if (-not(test-path "$Path/_My_Build/" -pathType container)) { + & mkdir "$Path/_My_Build/" + } + set-location "$Path/_My_Build/" + + & cmake .. + if ($lastExitCode -ne "0") { throw "Executing 'cmake ..' has failed" } + + & make -j4 + if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" } + + & make test + if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" } + + } elseif (test-path "$Path/configure" -pathType leaf) { + "๐Ÿ”จ Building ๐Ÿ“‚$DirName using 'configure'..." + set-location "$Path/" + + & ./configure + #if ($lastExitCode -ne "0") { throw "Script 'configure' exited with error code $lastExitCode" } + + & make -j4 + if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" } + + & make test + if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" } + + } elseif (test-path "$Path/autogen.sh" -pathType leaf) { + "๐Ÿ”จ Building ๐Ÿ“‚$DirName using 'autogen.sh'..." + set-location "$Path/" + + & ./autogen.sh + if ($lastExitCode -ne "0") { throw "Script 'autogen.sh' exited with error code $lastExitCode" } + + & make -j4 + if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" } + + } elseif (test-path "$Path/build.gradle" -pathType leaf) { + "๐Ÿ”จ Building ๐Ÿ“‚$DirName using build.gradle..." + set-location "$Path" + + & gradle build + if ($lastExitCode -ne "0") { throw "'gradle build' has failed" } + + & gradle test + if ($lastExitCode -ne "0") { throw "'gradle test' has failed" } + + } elseif (test-path "$Path/Imakefile" -pathType leaf) { + "๐Ÿ”จ Building ๐Ÿ“‚$DirName using Imakefile..." + set-location "$RepoDir/" + + & xmkmf + if ($lastExitCode -ne "0") { throw "Executing 'xmkmf' has failed" } + + & make -j4 + if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" } + + } elseif (test-path "$Path/Makefile" -pathType leaf) { + "๐Ÿ”จ Building ๐Ÿ“‚$DirName using Makefile..." + set-location "$Path" + + & make -j4 + if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" } + + } elseif (test-path "$Path/compile.sh" -pathType leaf) { + "๐Ÿ”จ Building ๐Ÿ“‚$DirName using 'compile.sh'..." + set-location "$Path/" + + & ./compile.sh + if ($lastExitCode -ne "0") { throw "Script 'compile.sh' exited with error code $lastExitCode" } + + & make -j4 + if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" } + + } elseif (test-path "$Path/attower/src/build/DevBuild/build.bat" -pathType leaf) { + "๐Ÿ”จ Building ๐Ÿ“‚$DirName using build.bat ..." + set-location "$Path/attower/src/build/DevBuild/" + + & ./build.bat build-all-release + if ($lastExitCode -ne "0") { throw "Script 'build.bat' exited with error code $lastExitCode" } + + } elseif (test-path "$Path/$DirName" -pathType container) { + "๐Ÿ”จ No make rule found, trying subfolder ๐Ÿ“‚$($DirName)..." + MakeDir "$Path/$DirName" + } else { + write-warning "Sorry, no make rule applies to: ๐Ÿ“‚$DirName" + exit 0 # success + } +} + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + $RepoDirName = (get-item "$RepoDir").Name + + $PreviousPath = get-location + MakeDir "$RepoDir" + set-location "$PreviousPath" + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ built Git repository ๐Ÿ“‚$RepoDirName in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of build-repo.ps1* diff --git a/Docs/build-repos.md b/Docs/build-repos.md index 684d6f14..425ecdeb 100644 --- a/Docs/build-repos.md +++ b/Docs/build-repos.md @@ -1,4 +1,4 @@ -## build-repos.ps1 - Builds Git repositories +## The build-repos.ps1 PowerShell Script This PowerShell script builds all Git repositories in a folder. @@ -32,4 +32,46 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Builds Git repositories +.DESCRIPTION + This PowerShell script builds all Git repositories in a folder. +.PARAMETER ParentDir + Specifies the path to the parent folder +.EXAMPLE + PS> ./build-repos C:\MyRepos +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$ParentDir = "$PWD") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + $ParentDirName = (Get-Item "$ParentDir").Name + "โณ Step 1 - Checking parent folder ๐Ÿ“‚$ParentDirName..." + if (-not(Test-Path "$ParentDir" -pathType container)) { throw "Can't access folder: $ParentDir" } + $Folders = (Get-ChildItem "$ParentDir" -attributes Directory) + $FolderCount = $Folders.Count + "Found $FolderCount subfolders." + + [int]$Step = 1 + foreach ($Folder in $Folders) { + & "$PSScriptRoot/build-repo.ps1" "$Folder" + $Step++ + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ built $FolderCount Git repositories at ๐Ÿ“‚$ParentDirName in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of build-repos.ps1* diff --git a/Docs/cd-autostart.md b/Docs/cd-autostart.md index d877fd84..02d910c1 100644 --- a/Docs/cd-autostart.md +++ b/Docs/cd-autostart.md @@ -1,4 +1,4 @@ -## cd-autostart.ps1 - Sets the working directory to the user's autostart folder +## The cd-autostart.ps1 PowerShell Script This PowerShell script changes the working directory to the user's autostart folder. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's autostart folder +.DESCRIPTION + This PowerShell script changes the working directory to the user's autostart folder. +.EXAMPLE + PS> ./cd-autostart + ๐Ÿ“‚C:\Users\Markus\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = Resolve-Path "$HOME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup" + if (-not(Test-Path "$Path" -pathType container)) { + throw "Autostart folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-autostart.ps1* diff --git a/Docs/cd-desktop.md b/Docs/cd-desktop.md index 619c7bfe..7e4c6b66 100644 --- a/Docs/cd-desktop.md +++ b/Docs/cd-desktop.md @@ -1,4 +1,4 @@ -## cd-desktop.ps1 - Sets the working directory to the user's desktop folder +## The cd-desktop.ps1 PowerShell Script This PowerShell script changes the working directory to the user's desktop folder. @@ -24,4 +24,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's desktop folder +.DESCRIPTION + This PowerShell script changes the working directory to the user's desktop folder. +.EXAMPLE + PS> ./cd-desktop + ๐Ÿ“‚/home/Markus/Desktop +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + $Path = Resolve-Path "$HOME/Desktop" + } else { + $Path = [Environment]::GetFolderPath('DesktopDirectory') + } + if (-not(Test-Path "$Path" -pathType container)) { + throw "Desktop folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-desktop.ps1* diff --git a/Docs/cd-docs.md b/Docs/cd-docs.md index 8cb02f44..77f401a5 100644 --- a/Docs/cd-docs.md +++ b/Docs/cd-docs.md @@ -1,4 +1,4 @@ -## cd-docs.ps1 - Sets the working directory to the documents folder +## The cd-docs.ps1 PowerShell Script This PowerShell script changes the working directory to the documents folder. @@ -24,4 +24,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the documents folder +.DESCRIPTION + This PowerShell script changes the working directory to the documents folder. +.EXAMPLE + PS> ./cd-docs + ๐Ÿ“‚C:\Users\Markus\Documents +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + $Path = Resolve-Path "$HOME/Documents" + } else { + $Path = [Environment]::GetFolderPath('MyDocuments') + } + if (-not(Test-Path "$Path" -pathType container)) { + throw "Documents folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-docs.ps1* diff --git a/Docs/cd-downloads.md b/Docs/cd-downloads.md index 3a470bac..3258c190 100644 --- a/Docs/cd-downloads.md +++ b/Docs/cd-downloads.md @@ -1,4 +1,4 @@ -## cd-downloads.ps1 - Sets the working directory to the user's downloads folder +## The cd-downloads.ps1 PowerShell Script This PowerShell script changes the working directory to the user's downloads folder. @@ -24,4 +24,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's downloads folder +.DESCRIPTION + This PowerShell script changes the working directory to the user's downloads folder. +.EXAMPLE + PS> ./cd-downloads + ๐Ÿ“‚C:\Users\Markus\Downloads +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + $Path = Resolve-Path "$HOME/Downloads" + } else { + $Path = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path + } + if (-not(Test-Path "$Path" -pathType container)) { + throw "Downloads folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-downloads.ps1* diff --git a/Docs/cd-dropbox.md b/Docs/cd-dropbox.md index 7a0988b8..16ea1435 100644 --- a/Docs/cd-dropbox.md +++ b/Docs/cd-dropbox.md @@ -1,4 +1,4 @@ -## cd-dropbox.ps1 - Sets the working directory to the user's Dropbox folder +## The cd-dropbox.ps1 PowerShell Script This PowerShell script changes the working directory to the user's Dropbox folder. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's Dropbox folder +.DESCRIPTION + This PowerShell script changes the working directory to the user's Dropbox folder. +.EXAMPLE + PS> ./cd-dropbox + ๐Ÿ“‚/home/Markus/Dropbox +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = Resolve-Path "$HOME/Dropbox" + if (-not(Test-Path "$Path" -pathType container)) { + throw "Dropbox folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-dropbox.ps1* diff --git a/Docs/cd-fonts.md b/Docs/cd-fonts.md index 47e133c3..d6cd2f89 100644 --- a/Docs/cd-fonts.md +++ b/Docs/cd-fonts.md @@ -1,4 +1,4 @@ -## cd-fonts.ps1 - Sets the working directory to the fonts folder +## The cd-fonts.ps1 PowerShell Script This PowerShell script changes the working directory to the fonts folder. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the fonts folder +.DESCRIPTION + This PowerShell script changes the working directory to the fonts folder. +.EXAMPLE + PS> ./cd-fonts + ๐Ÿ“‚C:\Windows\Fonts +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = [Environment]::GetFolderPath('Fonts') + if (-not(Test-Path "$Path" -pathType container)) { + throw "Fonts folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-fonts.ps1* diff --git a/Docs/cd-home.md b/Docs/cd-home.md index a9c31309..39d09ef3 100644 --- a/Docs/cd-home.md +++ b/Docs/cd-home.md @@ -1,4 +1,4 @@ -## cd-home.ps1 - Sets the working directory to the user's home directory +## The cd-home.ps1 PowerShell Script This PowerShell script changes the working directory to the user's home directory. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's home directory +.DESCRIPTION + This PowerShell script changes the working directory to the user's home directory. +.EXAMPLE + PS> ./cd-home + ๐Ÿ“‚/home/Markus +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = Resolve-Path "$HOME" + if (-not(Test-Path "$Path" -pathType container)) { + throw "Home directory at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-home.ps1* diff --git a/Docs/cd-music.md b/Docs/cd-music.md index 05a8c0f1..d26ec339 100644 --- a/Docs/cd-music.md +++ b/Docs/cd-music.md @@ -1,4 +1,4 @@ -## cd-music.ps1 - Sets the working directory to the user's music folder +## The cd-music.ps1 PowerShell Script This PowerShell script changes the working directory to the user's music folder. @@ -24,4 +24,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's music folder +.DESCRIPTION + This PowerShell script changes the working directory to the user's music folder. +.EXAMPLE + PS> ./cd-music + ๐Ÿ“‚/home/Markus/Music +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + $Path = Resolve-Path "$HOME/Music" + } else { + $Path = [Environment]::GetFolderPath('MyMusic') + } + if (-not(Test-Path "$Path" -pathType container)) { + throw "Music folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-music.ps1* diff --git a/Docs/cd-onedrive.md b/Docs/cd-onedrive.md index 943d1958..39bd9b44 100644 --- a/Docs/cd-onedrive.md +++ b/Docs/cd-onedrive.md @@ -1,4 +1,4 @@ -## cd-onedrive.ps1 - Sets the working directory to the user's OneDrive folder +## The cd-onedrive.ps1 PowerShell Script This PowerShell script changes the working directory to the user's OneDrive folder. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's OneDrive folder +.DESCRIPTION + This PowerShell script changes the working directory to the user's OneDrive folder. +.EXAMPLE + PS> ./cd-onedrive + ๐Ÿ“‚/home/Markus/OneDrive +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = Resolve-Path "$HOME/OneDrive" + if (-not(Test-Path "$Path" -pathType container)) { + throw "OneDrive folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-onedrive.ps1* diff --git a/Docs/cd-pics.md b/Docs/cd-pics.md index 237a11fd..8bd5a139 100644 --- a/Docs/cd-pics.md +++ b/Docs/cd-pics.md @@ -1,4 +1,4 @@ -## cd-pics.ps1 - Sets the working directory to the user's pictures folder +## The cd-pics.ps1 PowerShell Script This PowerShell script changes the working directory to the user's pictures folder. @@ -24,4 +24,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's pictures folder +.DESCRIPTION + This PowerShell script changes the working directory to the user's pictures folder. +.EXAMPLE + PS> ./cd-pics + ๐Ÿ“‚/home/Markus/Pictures +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + $Path = Resolve-Path "$HOME/Pictures" + } else { + $Path = [Environment]::GetFolderPath('MyPictures') + } + if (-not(Test-Path "$Path" -pathType container)) { + throw "Pictures folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-pics.ps1* diff --git a/Docs/cd-recycle-bin.md b/Docs/cd-recycle-bin.md index 30f5cf8a..431200b7 100644 --- a/Docs/cd-recycle-bin.md +++ b/Docs/cd-recycle-bin.md @@ -1,4 +1,6 @@ -## cd-recycle-bin.ps1 - cd-recycle-bin.ps1 +## The cd-recycle-bin.ps1 PowerShell Script + +cd-recycle-bin.ps1 ## Parameters @@ -10,4 +12,38 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's recycle bin folder +.DESCRIPTION + This PowerShell script changes the working directory to the user's recycle bin folder. +.EXAMPLE + PS> ./cd-recycle-bin + ๐Ÿ“‚C:\$Recycle.Bin\S-1-5-21-123404-23309-294260-1001 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function GetCurrentUserSID { [CmdletBinding()] param() + Add-Type -AssemblyName System.DirectoryServices.AccountManagement + return ([System.DirectoryServices.AccountManagement.UserPrincipal]::Current).SID.Value +} + + +try { + $Path = 'C:\$Recycle.Bin\' + "$(GetCurrentUserSID)" + if (-not(Test-Path "$Path" -pathType container)) { + throw "Recycle bin folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-recycle-bin.ps1* diff --git a/Docs/cd-repos.md b/Docs/cd-repos.md index a2cfc6a7..df792922 100644 --- a/Docs/cd-repos.md +++ b/Docs/cd-repos.md @@ -1,4 +1,4 @@ -## cd-repos.ps1 - Sets the working directory to the user's repos folder +## The cd-repos.ps1 PowerShell Script This PowerShell script changes the working directory to the user's Git repositories folder. @@ -24,4 +24,38 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's repos folder +.DESCRIPTION + This PowerShell script changes the working directory to the user's Git repositories folder. +.EXAMPLE + PS> ./cd-repos + ๐Ÿ“‚C:\Users\Markus\Repos +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if (Test-Path "$HOME/Repos" -pathType Container) { + $Path = Resolve-Path "$HOME/Repos" # short form + } elseif (Test-Path "$HOME/Repositories" -pathType Container) { + $Path = Resolve-Path "$HOME/Repositories" # long form + } elseif (Test-Path "$HOME/source/repos" -pathType Container) { + $Path = Resolve-Path "$HOME/source/repos" # default by Visual Studio + } else { + $Path = "$HOME/Repos" + throw "Folder for Git repositories at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-repos.ps1* diff --git a/Docs/cd-root.md b/Docs/cd-root.md index 2a1381ef..a3191a00 100644 --- a/Docs/cd-root.md +++ b/Docs/cd-root.md @@ -1,4 +1,4 @@ -## cd-root.ps1 - Sets the working directory to the root directory +## The cd-root.ps1 PowerShell Script This PowerShell script changes the current working directory to the root directory (C:\ on Windows). @@ -24,4 +24,29 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the root directory +.DESCRIPTION + This PowerShell script changes the current working directory to the root directory (C:\ on Windows). +.EXAMPLE + PS> ./cd-root + ๐Ÿ“‚C:\ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { $Path = "/" } else { $Path = "C:\" } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-root.ps1* diff --git a/Docs/cd-screenshots.md b/Docs/cd-screenshots.md index 24e7d923..f0f97bcc 100644 --- a/Docs/cd-screenshots.md +++ b/Docs/cd-screenshots.md @@ -1,4 +1,4 @@ -## cd-screenshots.ps1 - Sets the working directory to the user's screenshots folder +## The cd-screenshots.ps1 PowerShell Script This PowerShell script changes the working directory to the user's screenshots folder. @@ -24,4 +24,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's screenshots folder +.DESCRIPTION + This PowerShell script changes the working directory to the user's screenshots folder. +.EXAMPLE + PS> ./cd-screenshots + ๐Ÿ“‚C:\Users\Markus\Pictures\Screenshots +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + $Path = Resolve-Path "$HOME/Pictures/Screenshots" + } else { + $Path = [Environment]::GetFolderPath('MyPictures') + $Path = "$Path\Screenshots" + } + if (-not(Test-Path "$Path" -pathType container)) { + throw "Screenshots folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-screenshots.ps1* diff --git a/Docs/cd-scripts.md b/Docs/cd-scripts.md index 32b81b42..0b8e27a5 100644 --- a/Docs/cd-scripts.md +++ b/Docs/cd-scripts.md @@ -1,4 +1,4 @@ -## cd-scripts.ps1 - Sets the working directory to the PowerShell scripts folder +## The cd-scripts.ps1 PowerShell Script This PowerShell script changes the working directory to the PowerShell scripts folder. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the PowerShell scripts folder +.DESCRIPTION + This PowerShell script changes the working directory to the PowerShell scripts folder. +.EXAMPLE + PS> ./cd-scripts + ๐Ÿ“‚/home/Markus/PowerShell/Scripts +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = Resolve-Path "$PSScriptRoot" + if (-not(Test-Path "$Path" -pathType container)) { + throw "PowerShell scripts folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-scripts.ps1* diff --git a/Docs/cd-ssh.md b/Docs/cd-ssh.md index f1536551..a3913e1e 100644 --- a/Docs/cd-ssh.md +++ b/Docs/cd-ssh.md @@ -1,4 +1,4 @@ -## cd-ssh.ps1 - Sets the working directory to the user's SSH folder +## The cd-ssh.ps1 PowerShell Script This PowerShell script changes the working directory to the user's SSH folder. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's SSH folder +.DESCRIPTION + This PowerShell script changes the working directory to the user's SSH folder. +.EXAMPLE + PS> ./cd-ssh + ๐Ÿ“‚/home/Markus/.ssh +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = Resolve-Path "$HOME/.ssh" + if (-not(Test-Path "$Path" -pathType container)) { + throw "SSH folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-ssh.ps1* diff --git a/Docs/cd-temp.md b/Docs/cd-temp.md index c485d231..ce6e320e 100644 --- a/Docs/cd-temp.md +++ b/Docs/cd-temp.md @@ -1,4 +1,6 @@ -## cd-temp.ps1 - cd-temp.ps1 +## The cd-temp.ps1 PowerShell Script + +cd-temp.ps1 ## Parameters @@ -10,4 +12,39 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Sets the working directory to the temporary folder +.DESCRIPTION + This PowerShell script changes the working directory to the temporary folder. +.EXAMPLE + PS> ./cd-temp + ๐Ÿ“‚C:\Users\Markus\AppData\Local\Temp +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function GetTempDir { + if ("$env:TEMP" -ne "") { return "$env:TEMP" } + if ("$env:TMP" -ne "") { return "$env:TMP" } + if ($IsLinux) { return "/tmp" } + return "C:\Temp" +} + +try { + $Path = GetTempDir + if (-not(Test-Path "$Path" -pathType container)) { + throw "Temporary folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-temp.ps1* diff --git a/Docs/cd-up.md b/Docs/cd-up.md index e1578ac1..b297cdf2 100644 --- a/Docs/cd-up.md +++ b/Docs/cd-up.md @@ -1,4 +1,4 @@ -## cd-up.ps1 - Sets the working directory to one level up +## The cd-up.ps1 PowerShell Script This PowerShell script changes the working directory to one directory level up. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to one level up +.DESCRIPTION + This PowerShell script changes the working directory to one directory level up. +.EXAMPLE + PS> .\cd-up + ๐Ÿ“‚C:\Users +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = Resolve-Path ".." + if (-not(Test-Path "$Path" -pathType container)) { + throw "Folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-up.ps1* diff --git a/Docs/cd-up2.md b/Docs/cd-up2.md index 8e0cf83f..58007be8 100644 --- a/Docs/cd-up2.md +++ b/Docs/cd-up2.md @@ -1,4 +1,4 @@ -## cd-up2.ps1 - Sets the working directory to two directory levels up +## The cd-up2.ps1 PowerShell Script This PowerShell script changes the working directory to two directory level up. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to two directory levels up +.DESCRIPTION + This PowerShell script changes the working directory to two directory level up. +.EXAMPLE + PS> ./cd-up2 + ๐Ÿ“‚C:\ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = Resolve-Path "../.." + if (-not(Test-Path "$Path" -pathType container)) { + throw "Folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-up2.ps1* diff --git a/Docs/cd-up3.md b/Docs/cd-up3.md index fc1452c2..7b0f95c3 100644 --- a/Docs/cd-up3.md +++ b/Docs/cd-up3.md @@ -1,4 +1,4 @@ -## cd-up3.ps1 - Sets the working directory to three directory levels up +## The cd-up3.ps1 PowerShell Script This PowerShell script changes the working directory to three directory levels up. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to three directory levels up +.DESCRIPTION + This PowerShell script changes the working directory to three directory levels up. +.EXAMPLE + PS> ./cd-up3 + ๐Ÿ“‚C:\ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = Resolve-Path "../../.." + if (-not(Test-Path "$Path" -pathType container)) { + throw "Folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-up3.ps1* diff --git a/Docs/cd-up4.md b/Docs/cd-up4.md index 192c8cf4..853a01c2 100644 --- a/Docs/cd-up4.md +++ b/Docs/cd-up4.md @@ -1,4 +1,4 @@ -## cd-up4.ps1 - Sets the working directory to four directory levels up +## The cd-up4.ps1 PowerShell Script This PowerShell script changes the working directory to four directory levels up. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to four directory levels up +.DESCRIPTION + This PowerShell script changes the working directory to four directory levels up. +.EXAMPLE + PS> ./cd-up4 + ๐Ÿ“‚C:\ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = Resolve-Path "../../../.." + if (-not(Test-Path "$Path" -pathType container)) { + throw "Folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-up4.ps1* diff --git a/Docs/cd-users.md b/Docs/cd-users.md index b0583e17..3c2f516b 100644 --- a/Docs/cd-users.md +++ b/Docs/cd-users.md @@ -1,4 +1,4 @@ -## cd-users.ps1 - Sets the working directory to the users directory +## The cd-users.ps1 PowerShell Script This PowerShell script changes the working directory to the users directory. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the users directory +.DESCRIPTION + This PowerShell script changes the working directory to the users directory. +.EXAMPLE + PS> ./cd-users + ๐Ÿ“‚C:\Users +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = Resolve-Path "$HOME/.." + if (-not(Test-Path "$Path" -pathType container)) { + throw "Users directory at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-users.ps1* diff --git a/Docs/cd-videos.md b/Docs/cd-videos.md index af3db935..71f69c41 100644 --- a/Docs/cd-videos.md +++ b/Docs/cd-videos.md @@ -1,4 +1,4 @@ -## cd-videos.ps1 - Sets the working directory to the user's videos folder +## The cd-videos.ps1 PowerShell Script This PowerShell script changes the working directory to the user's videos folder. @@ -24,4 +24,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the user's videos folder +.DESCRIPTION + This PowerShell script changes the working directory to the user's videos folder. +.EXAMPLE + PS> ./cd-videos + ๐Ÿ“‚C:\Users\Markus\Videos +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + $Path = Resolve-Path "$HOME/Videos" + } else { + $Path = [Environment]::GetFolderPath('MyVideos') + } + if (-not(Test-Path "$Path" -pathType container)) { + throw "Videos folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-videos.ps1* diff --git a/Docs/cd-windows.md b/Docs/cd-windows.md index 5635545e..44a3352e 100644 --- a/Docs/cd-windows.md +++ b/Docs/cd-windows.md @@ -1,4 +1,4 @@ -## cd-windows.ps1 - Sets the working directory to the Windows directory +## The cd-windows.ps1 PowerShell Script This PowerShell script changes the working directory to the Windows directory. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the working directory to the Windows directory +.DESCRIPTION + This PowerShell script changes the working directory to the Windows directory. +.EXAMPLE + PS> ./cd-windows + ๐Ÿ“‚C:\Windows +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Path = Resolve-Path "$env:WINDIR" + if (-not(Test-Path "$Path" -pathType container)) { + throw "Windows directory at ๐Ÿ“‚$Path doesn't exist" + } + Set-Location "$Path" + "๐Ÿ“‚$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of cd-windows.ps1* diff --git a/Docs/change-wallpaper.md b/Docs/change-wallpaper.md index 8cba0d2b..74a4a997 100644 --- a/Docs/change-wallpaper.md +++ b/Docs/change-wallpaper.md @@ -1,4 +1,4 @@ -## change-wallpaper.ps1 - Changes the wallpaper +## The change-wallpaper.ps1 PowerShell Script This PowerShell script downloads a random photo from Unsplash and sets it as desktop background. @@ -32,4 +32,43 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Changes the wallpaper +.DESCRIPTION + This PowerShell script downloads a random photo from Unsplash and sets it as desktop background. +.PARAMETER Category + Specifies the photo category (beach, city, ...) +.EXAMPLE + PS> ./change-wallpaper +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Category = "") + +function GetTempDir { + if ("$env:TEMP" -ne "") { return "$env:TEMP" } + if ("$env:TMP" -ne "") { return "$env:TMP" } + if ($IsLinux) { return "/tmp" } + return "C:\Temp" +} + +try { + & "$PSScriptRoot/give-reply.ps1" "Just a second..." + + $Path = "$(GetTempDir)/next_wallpaper.jpg" + & wget -O $Path "https://source.unsplash.com/3840x2160?$Category" + if ($lastExitCode -ne "0") { throw "Download failed" } + + & "$PSScriptRoot/set-wallpaper.ps1" -ImageFile "$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of change-wallpaper.ps1* diff --git a/Docs/check-bios.md b/Docs/check-bios.md index a357c858..6dd2183b 100644 --- a/Docs/check-bios.md +++ b/Docs/check-bios.md @@ -1,4 +1,4 @@ -## check-bios.ps1 - Checks BIOS details +## The check-bios.ps1 PowerShell Script This PowerShell script queries BIOS details and prints it. @@ -23,4 +23,35 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks BIOS details +.DESCRIPTION + This PowerShell script queries BIOS details and prints it. +.EXAMPLE + PS> ./check-bios +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + # TODO + } else { + $BIOS = Get-CimInstance -ClassName Win32_BIOS + $Manufacturer = $BIOS.Manufacturer + $Model = $BIOS.Name + $SerialNumber = $BIOS.SerialNumber + $Version = $BIOS.Version + "โœ… $Manufacturer BIOS $($Model): S/N $SerialNumber, version $Version" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-bios.ps1* diff --git a/Docs/check-cpu.md b/Docs/check-cpu.md index 87f9e279..085c3ee9 100644 --- a/Docs/check-cpu.md +++ b/Docs/check-cpu.md @@ -1,4 +1,6 @@ -## check-cpu.ps1 - check-cpu.ps1 +## The check-cpu.ps1 PowerShell Script + +check-cpu.ps1 ## Parameters @@ -10,4 +12,61 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Checks the CPU temperature +.DESCRIPTION + This PowerShell script queries the CPU temperature and returns it. +.EXAMPLE + PS> ./check-cpu + CPU is 30.3ยฐC warm. +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function GetCPUTemperatureInCelsius { + $Temp = 99999.9 # unsupported + if ($IsLinux) { + if (Test-Path "/sys/class/thermal/thermal_zone0/temp" -pathType leaf) { + [int]$IntTemp = Get-Content "/sys/class/thermal/thermal_zone0/temp" + $Temp = [math]::round($IntTemp / 1000.0, 1) + } + } else { + $Objects = Get-WmiObject -Query "SELECT * FROM Win32_PerfFormattedData_Counters_ThermalZoneInformation" -Namespace "root/CIMV2" + foreach ($Obj in $Objects) { + $HiPrec = $Obj.HighPrecisionTemperature + $Temp = [math]::round($HiPrec / 100.0, 1) + } + } + return $Temp; +} + +try { + $Celsius = GetCPUTemperatureInCelsius + if ($Celsius -eq 99999.9) { + $Temp = "no temp" + } elseif ($Celsius -gt 50) { + $Temp = "$($Celsius)ยฐC hot" + } elseif ($Celsius -gt 0) { + $Temp = "$($Celsius)ยฐC warm" + } else { + $Temp = "$($Celsius)ยฐC cold" + } + + if ($IsLinux) { + "โœ… CPU is $Temp." + } else { + $Details = Get-WmiObject -Class Win32_Processor + $DeviceName = $Details.Name.trim() + "โœ… $($DeviceName): $($Details.DeviceID), $($Details.MaxClockSpeed)MHz, $Temp" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-cpu.ps1* diff --git a/Docs/check-day.md b/Docs/check-day.md index 97808c7b..196a0d00 100644 --- a/Docs/check-day.md +++ b/Docs/check-day.md @@ -1,4 +1,4 @@ -## check-day.ps1 - Determines the current day +## The check-day.ps1 PowerShell Script This PowerShell script determines and speaks the current day by text-to-speech (TTS). @@ -24,4 +24,29 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Determines the current day +.DESCRIPTION + This PowerShell script determines and speaks the current day by text-to-speech (TTS). +.EXAMPLE + PS> ./check-day + โœ”๏ธ It's Sunday. +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + [system.threading.thread]::currentthread.currentculture=[system.globalization.cultureinfo]"en-US" + $Weekday = (Get-Date -format "dddd") + & "$PSScriptRoot/give-reply.ps1" "It's $Weekday." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-day.ps1* diff --git a/Docs/check-dns-server.md b/Docs/check-dns-server.md index be7801e0..420bdd38 100644 --- a/Docs/check-dns-server.md +++ b/Docs/check-dns-server.md @@ -1,4 +1,6 @@ -## check-dns-server.ps1 - check-dns-server.ps1 +## The check-dns-server.ps1 PowerShell Script + +check-dns-server.ps1 ## Parameters @@ -10,4 +12,59 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Checks DNS server +.DESCRIPTION + This PowerShell script checks the speed of public DNS server. +.EXAMPLE + PS> ./check-dns-server +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function CheckDNS { param($Name, $PriIPv4, $SecIPv4) + $StopWatch = [system.diagnostics.stopwatch]::startNew() + $null = (nslookup whitehouse.gov $PriIPv4) + [int]$PriIPv4Elapsed = $StopWatch.Elapsed.TotalMilliseconds + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + $null = (nslookup whitehouse.gov $SecIPv4) + [int]$SecIPv4Elapsed = $StopWatch.Elapsed.TotalMilliseconds + + " `"$Name`"; `"$PriIPv4`"; `"$PriIPv4Elapsed ms`"; `"$SecIPv4`"; `"$SecIPv4Elapsed ms`"; " +} + +try { + "Checking speed of public DNS server..." + " `"Company`"; `"IPv4 primary`"; `"Latency in ms`"; `"IPv4 secondary`"; `"Latency in ms`"; " + CheckDNS "Cloudflare" 1.1.1.1 1.0.0.1 + CheckDNS "Cloudflare with malware blocklist" 1.1.1.2 1.0.0.2 + CheckDNS "Cloudflare with malware+adult blocklist" 1.1.1.3 1.0.0.3 + CheckDNS "DNS.Watch" 84.200.69.80 84.200.70.40 + CheckDNS "FreeDNS Vienna" 37.235.1.174 37.235.1.177 + CheckDNS "Google Public DNS" 8.8.8.8 8.8.4.4 + CheckDNS "Level3 one" 4.2.2.1 4.2.2.1 + CheckDNS "Level3 two" 4.2.2.2 4.2.2.2 + CheckDNS "Level3 three" 4.2.2.3 4.2.2.3 + CheckDNS "Level3 four" 4.2.2.4 4.2.2.4 + CheckDNS "Level3 five" 4.2.2.5 4.2.2.5 + CheckDNS "Level3 six" 4.2.2.6 4.2.2.6 + CheckDNS "OpenDNS Basic" 208.67.222.222 208.67.220.220 + CheckDNS "OpenDNS Family Shield" 208.67.222.123 208.67.220.123 + CheckDNS "OpenNIC" 94.247.43.254 94.247.43.254 + CheckDNS "Quad9 with malware blocklist, with DNSSEC" 9.9.9.9 9.9.9.9 + CheckDNS "Quad9, no malware blocklist, no DNSSEC" 9.9.9.10 9.9.9.10 + CheckDNS "Quad9, with malware blocklist, with DNSSEC, with EDNS" 9.9.9.11 9.9.9.11 + CheckDNS "Quad9, with malware blocklist, with DNSSEC, NXDOMAIN only" 9.9.9.12 9.9.9.12 + CheckDNS "Verisign Public DNS" 64.6.64.6 64.6.65.6 + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-dns-server.ps1* diff --git a/Docs/check-dns.md b/Docs/check-dns.md index 4d348051..ad6c51e4 100644 --- a/Docs/check-dns.md +++ b/Docs/check-dns.md @@ -1,4 +1,4 @@ -## check-dns.ps1 - Checks the DNS resolution +## The check-dns.ps1 PowerShell Script This PowerShell script measures and prints the DNS resolution speed by using 200 frequently used domain names. @@ -23,4 +23,45 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the DNS resolution +.DESCRIPTION + This PowerShell script measures and prints the DNS resolution speed by using 200 frequently used domain names. +.EXAMPLE + PS> ./check-dns +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Write-Progress "โณ Step 1/2 - Reading from Data/frequent-domains.csv..." + $Table = Import-CSV "$PSScriptRoot/../Data/frequent-domains.csv" + $NumRows = $Table.Length + + Write-Progress "โณ Step 2/2 - Resolving $NumRows domains..." + $StopWatch = [system.diagnostics.stopwatch]::startNew() + if ($IsLinux) { + foreach($Row in $Table){$nop=dig $Row.Domain +short} + } else { + foreach($Row in $Table){$nop=Resolve-DNSName $Row.Domain} + } + + [float]$Elapsed = $StopWatch.Elapsed.TotalSeconds + $Average = [math]::round($NumRows / $Elapsed, 1) + + if ($Average -gt 10.0) { + "โœ… DNS resolves $Average domains per second." + } else { + "โš ๏ธ DNS resolves only $Average domains per second!" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-dns.ps1* diff --git a/Docs/check-drive-space.md b/Docs/check-drive-space.md index 9772f3e8..f802b8b7 100644 --- a/Docs/check-drive-space.md +++ b/Docs/check-drive-space.md @@ -1,4 +1,4 @@ -## check-drive-space.ps1 - Checks a drive for free space left +## The check-drive-space.ps1 PowerShell Script This PowerShell script checks a drive for free space left (20 GB by default). @@ -42,4 +42,45 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks a drive for free space left +.DESCRIPTION + This PowerShell script checks a drive for free space left (20 GB by default). +.PARAMETER Drive + Specifies the drive to check +.PARAMETER MinLevel + Specifies the minimum level in Gigabyte +.EXAMPLE + PS> ./check-drive-space C + โœ”๏ธ 172 GB left on drive C (61 of 233 GB used) +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Drive = "", [int]$MinLevel = 20) # minimum level in GB + +try { + if ($Drive -eq "" ) { $Drive = read-host "Enter drive to check" } + + $DriveDetails = (get-psdrive $Drive) + [int]$Free = (($DriveDetails.Free / 1024) / 1024) / 1024 + [int]$Used = (($DriveDetails.Used / 1024) / 1024) / 1024 + [int]$Total = ($Used + $Free) + + if ($Free -lt $MinLevel) { + write-warning "Drive $Drive has only $Free GB left to use! ($Used of $Total GB used, minimum is $MinLevel GB)" + exit 1 + } + + & "$PSScriptRoot/give-reply.ps1" "Drive $Drive has $Free GB left ($Total GB total)" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-drive-space.ps1* diff --git a/Docs/check-drives.md b/Docs/check-drives.md index 71df2c0c..5932d36f 100644 --- a/Docs/check-drives.md +++ b/Docs/check-drives.md @@ -1,4 +1,4 @@ -## check-drives.ps1 - Checks the drive space +## The check-drives.ps1 PowerShell Script This PowerShell script checks all drives for free space left. @@ -32,4 +32,63 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the drive space +.DESCRIPTION + This PowerShell script checks all drives for free space left. +.PARAMETER MinLevel + Specifies the minimum warning level (10 GB by default) +.EXAMPLE + PS> ./check-drives +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([int]$MinLevel = 10) # 10 GB minimum + +function Bytes2String { param([int64]$Bytes) + if ($Bytes -lt 1000) { return "$Bytes bytes" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)KB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)MB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)GB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)TB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)PB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)EB" } +} + +try { + $Drives = Get-PSDrive -PSProvider FileSystem + foreach($Drive in $Drives) { + $ID = $Drive.Name + $Details = (Get-PSDrive $ID) + [int64]$Free = $Details.Free + [int64]$Used = $Details.Used + [int64]$Total = ($Used + $Free) + + if ($Total -eq 0) { + "โœ… Drive $ID is empty." + } elseif ($Free -lt $MinLevel) { + "โš ๏ธ Drive $ID has only $(Bytes2String $Free) of $(Bytes2String $Total) left to use!" + } elseif ($Used -lt $Free) { + "โœ… Drive $ID uses $(Bytes2String $Used) of $(Bytes2String $Total)." + } else { + "โœ… Drive $ID has $(Bytes2String $Free) of $(Bytes2String $Total) left." + } + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-drives.ps1* diff --git a/Docs/check-dusk.md b/Docs/check-dusk.md index 2c1cf1f6..d1ff5cd3 100644 --- a/Docs/check-dusk.md +++ b/Docs/check-dusk.md @@ -1,4 +1,6 @@ -## check-dusk.ps1 - check-dusk.ps1 +## The check-dusk.ps1 PowerShell Script + +check-dusk.ps1 ## Parameters @@ -10,4 +12,49 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Checks the time of dusk +.DESCRIPTION + This PowerShell script queries the time of dusk and answers by text-to-speech (TTS). +.EXAMPLE + PS> ./check-dusk +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function TimeSpanToString { param([TimeSpan]$Delta) + $Result = "" + if ($Delta.Hours -eq 1) { $Result += "1 hour and " + } elseif ($Delta.Hours -gt 1) { $Result += "$($Delta.Hours) hours and " + } + if ($Delta.Minutes -eq 1) { $Result += "1 minute" + } else { $Result += "$($Delta.Minutes) minutes" + } + return $Result +} + +try { + [system.threading.thread]::currentThread.currentCulture=[system.globalization.cultureInfo]"en-US" + $String = (Invoke-WebRequest http://wttr.in/?format="%d" -UserAgent "curl" -useBasicParsing).Content + $Hour,$Minute,$Second = $String -split ':' + $Dusk = Get-Date -Hour $Hour -Minute $Minute -Second $Second + $Now = [DateTime]::Now + if ($Now -lt $Dusk) { + $TimeSpan = TimeSpanToString($Dusk - $Now) + $Reply = "Dusk is in $TimeSpan at $($Dusk.ToShortTimeString())." + } else { + $TimeSpan = TimeSpanToString($Now - $Dusk) + $Reply = "Dusk was $TimeSpan ago at $($Dusk.ToShortTimeString())." + } + & "$PSScriptRoot/give-reply.ps1" "$Reply" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-dusk.ps1* diff --git a/Docs/check-easter-sunday.md b/Docs/check-easter-sunday.md index 50172352..0c568df4 100644 --- a/Docs/check-easter-sunday.md +++ b/Docs/check-easter-sunday.md @@ -1,4 +1,4 @@ -## check-easter-sunday.ps1 - Checks the time until Easter Sunday +## The check-easter-sunday.ps1 PowerShell Script This PowerShell script checks the time until Easter Sunday and replies by text-to-speech (TTS). @@ -23,4 +23,34 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the time until Easter Sunday +.DESCRIPTION + This PowerShell script checks the time until Easter Sunday and replies by text-to-speech (TTS). +.EXAMPLE + PS> ./check-easter-sunday +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Now = [DateTime]::Now + $Easter = [Datetime]("04/17/2022") + if ($Now -lt $Easter) { + $Diff = $Easter โ€“ $Now + & "$PSScriptRoot/give-reply.ps1" "Easter Sunday on April 17 is in $($Diff.Days) days." + } else { + $Diff = $Now - $Easter + & "$PSScriptRoot/give-reply.ps1" "Easter Sunday on April 17 was $($Diff.Days) days ago." + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-easter-sunday.ps1* diff --git a/Docs/check-file-system.md b/Docs/check-file-system.md index 94d29965..4527c235 100644 --- a/Docs/check-file-system.md +++ b/Docs/check-file-system.md @@ -1,4 +1,4 @@ -## check-file-system.ps1 - Checks the file system of a drive (needs admin rights) +## The check-file-system.ps1 PowerShell Script This PowerShell script checks the file system of a drive. It needs admin rights. @@ -33,4 +33,38 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the file system of a drive (needs admin rights) +.DESCRIPTION + This PowerShell script checks the file system of a drive. It needs admin rights. +.PARAMETER Drive + Specifies the drive to check +.EXAMPLE + PS> ./check-file-system C + โœ”๏ธ file system on drive C is clean +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +param([string]$Drive = "") + +try { + if ($Drive -eq "" ) { $Drive = read-host "Enter drive (letter) to check" } + + $Result = repair-volume -driveLetter $Drive -scan + if ($Result -ne "NoErrorsFound") { throw "'repair-volume' failed" } + + & "$PSScriptRoot/give-reply.ps1" "File system on drive $Drive is clean." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-file-system.ps1* diff --git a/Docs/check-gpu.md b/Docs/check-gpu.md index 0bbf9305..74824c8a 100644 --- a/Docs/check-gpu.md +++ b/Docs/check-gpu.md @@ -1,4 +1,6 @@ -## check-gpu.ps1 - check-gpu.ps1 +## The check-gpu.ps1 PowerShell Script + +check-gpu.ps1 ## Parameters @@ -10,4 +12,50 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Checks the GPU +.DESCRIPTION + This PowerShell script queries GPU details and prints it. +.EXAMPLE + PS> ./check-gpu +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function Bytes2String { param([int64]$Bytes) + if ($Bytes -lt 1000) { return "$Bytes bytes" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)KB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)MB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)GB" } + $Bytes /= 1000 + return "$($Bytes)TB" +} + +try { + if ($IsLinux) { + # TODO + } else { + $Details = Get-WmiObject Win32_VideoController + $Model = $Details.Caption + $RAMSize = $Details.AdapterRAM + $ResWidth = $Details.CurrentHorizontalResolution + $ResHeight = $Details.CurrentVerticalResolution + $BitsPerPixel = $Details.CurrentBitsPerPixel + $RefreshRate = $Details.CurrentRefreshRate + $DriverVersion = $Details.DriverVersion + $Status = $Details.Status + "โœ… $($Model): $(Bytes2String $RAMSize) RAM, $($ResWidth)x$($ResHeight) pixels, $BitsPerPixel bit, $RefreshRate Hz, driver $DriverVersion, status $Status" + } +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-gpu.ps1* diff --git a/Docs/check-health.md b/Docs/check-health.md index 33d0517e..46dca559 100644 --- a/Docs/check-health.md +++ b/Docs/check-health.md @@ -1,4 +1,4 @@ -## check-health.ps1 - Checks the system health +## The check-health.ps1 PowerShell Script This PowerShell script checks some health parameter of the local computer. @@ -23,4 +23,34 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the system health +.DESCRIPTION + This PowerShell script checks some health parameter of the local computer. +.EXAMPLE + PS> ./check-health +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/check-operating-system.ps1" +& "$PSScriptRoot/check-uptime.ps1" +& "$PSScriptRoot/check-time-zone.ps1" +& "$PSScriptRoot/check-bios.ps1" +& "$PSScriptRoot/check-cpu.ps1" +& "$PSScriptRoot/check-ram.ps1" +& "$PSScriptRoot/check-gpu.ps1" +& "$PSScriptRoot/check-smart-devices.ps1" +& "$PSScriptRoot/check-swap-space.ps1" +& "$PSScriptRoot/check-drives.ps1" +& "$PSScriptRoot/check-dns.ps1" +& "$PSScriptRoot/check-ping.ps1" +& "$PSScriptRoot/check-vpn.ps1" +& "$PSScriptRoot/check-pending-reboot.ps1" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of check-health.ps1* diff --git a/Docs/check-independence-day.md b/Docs/check-independence-day.md index 8834ff32..af43a07d 100644 --- a/Docs/check-independence-day.md +++ b/Docs/check-independence-day.md @@ -1,4 +1,4 @@ -## check-independence-day.ps1 - Checks the time until Independence Day +## The check-independence-day.ps1 PowerShell Script This PowerShell script checks the time until Indepence Day and replies by text-to-speech (TTS). @@ -23,4 +23,34 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the time until Independence Day +.DESCRIPTION + This PowerShell script checks the time until Indepence Day and replies by text-to-speech (TTS). +.EXAMPLE + PS> ./check-independence-day +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Now = [DateTime]::Now + $IndependenceDay = [Datetime]("07/04/" + $Now.Year) + if ($Now -lt $IndependenceDay) { + $Diff = $IndependenceDay โ€“ $Now + & "$PSScriptRoot/give-reply.ps1" "Independence Day on July 4th is in $($Diff.Days) days." + } else { + $Diff = $Now - $IndependenceDay + & "$PSScriptRoot/give-reply.ps1" "Independence Day on July 4th was $($Diff.Days) days ago." + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-independence-day.ps1* diff --git a/Docs/check-ipv4-address.md b/Docs/check-ipv4-address.md index 4e8b028e..4d7a11d5 100644 --- a/Docs/check-ipv4-address.md +++ b/Docs/check-ipv4-address.md @@ -1,4 +1,4 @@ -## check-ipv4-address.ps1 - Checks an IPv4 address for validity +## The check-ipv4-address.ps1 PowerShell Script This PowerShell script checks the given IPv4 address for validity. @@ -33,4 +33,47 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks an IPv4 address for validity +.DESCRIPTION + This PowerShell script checks the given IPv4 address for validity. +.PARAMETER Address + Specifies the IPv4 address to check +.EXAMPLE + PS> ./check-ipv4-address 192.168.11.22 + โœ”๏ธ IPv4 192.168.11.22 is valid +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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]?)$" + if ($IP -match $RegEx) { + return $true + } else { + return $false + } +} + +try { + if ($Address -eq "" ) { $Address = read-host "Enter IPv4 address to validate" } + + if (IsIPv4AddressValid $Address) { + "โœ”๏ธ IPv4 $Address is valid" + exit 0 # success + } else { + write-warning "Invalid IPv4 address: $Address" + exit 1 + } +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-ipv4-address.ps1* diff --git a/Docs/check-ipv6-address.md b/Docs/check-ipv6-address.md index 2ae950f0..879d5aa6 100644 --- a/Docs/check-ipv6-address.md +++ b/Docs/check-ipv6-address.md @@ -1,4 +1,4 @@ -## check-ipv6-address.ps1 - Checks an IPv6 address for validity +## The check-ipv6-address.ps1 PowerShell Script This PowerShell script checks the given IPv6 address for validity @@ -33,4 +33,61 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks an IPv6 address for validity +.DESCRIPTION + This PowerShell script checks the given IPv6 address for validity +.PARAMETER Address + Specifies the IPv6 address to check +.EXAMPLE + PS> ./check-ipv6-address fe80::200:5aee:feaa:20a2 + โœ”๏ธ IPv6 fe80::200:5aee:feaa:20a2 is valid +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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}))' + $G = '[a-f\d]{1,4}' + $Tail = @(":", + "(:($G)?|$IPv4Regex)", + ":($IPv4Regex|$G(:$G)?|)", + "(:$IPv4Regex|:$G(:$IPv4Regex|(:$G){0,2})|:)", + "((:$G){0,2}(:$IPv4Regex|(:$G){1,2})|:)", + "((:$G){0,3}(:$IPv4Regex|(:$G){1,2})|:)", + "((:$G){0,4}(:$IPv4Regex|(:$G){1,2})|:)") + [string] $IPv6RegexString = $G + $Tail | foreach { $IPv6RegexString = "${G}:($IPv6RegexString|$_)" } + $IPv6RegexString = ":(:$G){0,5}((:$G){1,2}|:$IPv4Regex)|$IPv6RegexString" + $IPv6RegexString = $IPv6RegexString -replace '\(' , '(?:' # make all groups non-capturing + [regex] $IPv6Regex = $IPv6RegexString + if ($IP -imatch "^$IPv6Regex$") { + return $true + } else { + return $false + } +} + +try { + if ($Address -eq "" ) { + $Address = read-host "Enter IPv6 address to validate" + } + if (IsIPv6AddressValid $Address) { + "โœ”๏ธ IPv6 $Address is valid" + exit 0 # success + } else { + write-warning "Invalid IPv6 address: $Address" + exit 1 + } +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-ipv6-address.ps1* diff --git a/Docs/check-iss-position.md b/Docs/check-iss-position.md index bc492579..8f99fb43 100644 --- a/Docs/check-iss-position.md +++ b/Docs/check-iss-position.md @@ -1,4 +1,4 @@ -## check-iss-position.ps1 - Checks the ISS position +## The check-iss-position.ps1 PowerShell Script This PowerShell script queries the position of the International Space Station (ISS) and replies by text-to-speech (TTS). @@ -23,4 +23,28 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the ISS position +.DESCRIPTION + This PowerShell script queries the position of the International Space Station (ISS) and replies by text-to-speech (TTS). +.EXAMPLE + PS> ./check-iss-position +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $ISS = (Invoke-WebRequest "http://api.open-notify.org/iss-now.json" -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json + + & "$PSScriptRoot/give-reply.ps1" "The International Space Station is currently at $($ISS.iss_position.longitude)ยฐ longitude and $($ISS.iss_position.latitude)ยฐ latitude." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-iss-position.ps1* diff --git a/Docs/check-mac-address.md b/Docs/check-mac-address.md index b626838a..b384b9d9 100644 --- a/Docs/check-mac-address.md +++ b/Docs/check-mac-address.md @@ -1,4 +1,4 @@ -## check-mac-address.ps1 - Checks the given MAC address for validity +## The check-mac-address.ps1 PowerShell Script This PowerShell script checks the given MAC address for validity Supported MAC address formats are: 00:00:00:00:00:00 or 00-00-00-00-00-00 or 000000000000. @@ -34,4 +34,49 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the given MAC address for validity +.DESCRIPTION + This PowerShell script checks the given MAC address for validity + Supported MAC address formats are: 00:00:00:00:00:00 or 00-00-00-00-00-00 or 000000000000. +.PARAMETER MAC + Specifies the MAC address to check +.EXAMPLE + PS> ./check-mac-address 11:22:33:44:55:66 + โœ”๏ธ MAC address 11:22:33:44:55:66 is valid +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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}$" + if ($mac -match $RegEx) { + return $true + } else { + return $false + } +} + +try { + if ($MAC -eq "" ) { + $MAC = read-host "Enter MAC address to validate" + } + if (IsMACAddressValid $MAC) { + "โœ”๏ธ MAC address $MAC is valid" + exit 0 # success + } else { + write-warning "Invalid MAC address: $MAC" + exit 1 + } +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-mac-address.ps1* diff --git a/Docs/check-midnight.md b/Docs/check-midnight.md index 5f30c11c..44aa578e 100644 --- a/Docs/check-midnight.md +++ b/Docs/check-midnight.md @@ -1,4 +1,6 @@ -## check-midnight.ps1 - check-midnight.ps1 +## The check-midnight.ps1 PowerShell Script + +check-midnight.ps1 ## Parameters @@ -10,4 +12,47 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Checks for Midnight +.DESCRIPTION + This PowerShell script checks the time until Midnight and replies by text-to-speech (TTS). +.EXAMPLE + PS> ./check-midnight +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function TimeSpanToString { param([TimeSpan]$Delta) + $Result = "" + if ($Delta.Hours -eq 1) { $Result += "1 hour and " + } elseif ($Delta.Hours -gt 1) { $Result += "$($Delta.Hours) hours and " + } + if ($Delta.Minutes -eq 1) { $Result += "1 minute" + } else { $Result += "$($Delta.Minutes) minutes" + } + return $Result +} + +try { + $Now = [DateTime]::Now + if ($Now.Hour -lt 12) { + $Midnight = Get-Date -Hour 0 -Minute 0 -Second 0 + $TimeSpan = TimeSpanToString($Now - $Midnight) + $Reply = "Midnight was $TimeSpan ago." + } else { + $Midnight = Get-Date -Hour 23 -Minute 59 -Second 59 + $TimeSpan = TimeSpanToString($Midnight - $Now) + $Reply = "Midnight is in $TimeSpan." + } + & "$PSScriptRoot/give-reply.ps1" "$Reply" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-midnight.ps1* diff --git a/Docs/check-month.md b/Docs/check-month.md index 8c81b236..e56c6403 100644 --- a/Docs/check-month.md +++ b/Docs/check-month.md @@ -1,4 +1,4 @@ -## check-month.ps1 - Gets the current month name +## The check-month.ps1 PowerShell Script This PowerShell script determines and speaks the current month name by text-to-speech (TTS). @@ -24,4 +24,29 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Gets the current month name +.DESCRIPTION + This PowerShell script determines and speaks the current month name by text-to-speech (TTS). +.EXAMPLE + PS> ./check-month + โœ”๏ธ It's December. +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + [system.threading.thread]::currentthread.currentculture=[system.globalization.cultureinfo]"en-US" + $MonthName = (Get-Date -UFormat %B) + & "$PSScriptRoot/give-reply.ps1" "It's $MonthName." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-month.ps1* diff --git a/Docs/check-moon-phase.md b/Docs/check-moon-phase.md index e108b78e..baa94dc0 100644 --- a/Docs/check-moon-phase.md +++ b/Docs/check-moon-phase.md @@ -1,4 +1,4 @@ -## check-moon-phase.ps1 - Checks the Moon phase +## The check-moon-phase.ps1 PowerShell Script This PowerShell script determines the Moon phase and answers by text-to-speech (TTS). @@ -23,4 +23,49 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the Moon phase +.DESCRIPTION + This PowerShell script determines the Moon phase and answers by text-to-speech (TTS). +.EXAMPLE + PS> ./check-moon-phase +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $LunarCycle = 29.53058868 # synodic period in days, time between successive new moons + $LunarHalfCycle = $LunarCycle / 2.0 + $Phases = @("New moon", "Waxing crescent moon", "First quarter moon", "Waxing gibbous moon", "Full moon", "Waning gibbous moon", "Last quarter moon", "Waning crescent moon") + $PhaseLength = $LunarCycle / 8.0 + $PhaseHalfLength = $PhaseLength / 2.0 + + $RefDate = get-date -Year 2021 -Month 12 -Day 4 -Hour 6 -Minute 43 # Dec 4, 2021 06:43 UTC [New Moon] + $Now = get-date + $TimeInterval = New-TimeSpan -Start $RefDate -End $Now + $Days = $TimeInterval.TotalDays + + $MDays = $Days % $LunarCycle + $PhaseIndex = [int]($MDays * (8.0 / $LunarCycle)) + + $Visibility = [math]::Round((($Days % $LunarHalfCycle) * 100) / $LunarHalfCycle) + $Reply = "$($Phases[$PhaseIndex]) with $($Visibility)% visibility" + + $MoonAge = [math]::Round($Days % $LunarCycle) + if ($MoonAge -eq "0") { $Reply += " today" + } elseif ($MoonAge -eq "1") { $Reply += " since yesterday" + } else { $Reply += ", last new moon was $MoonAge days ago" + } + + & "$PSScriptRoot/give-reply.ps1" "$Reply" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-moon-phase.ps1* diff --git a/Docs/check-new-year.md b/Docs/check-new-year.md index a803d3be..51c01891 100644 --- a/Docs/check-new-year.md +++ b/Docs/check-new-year.md @@ -1,4 +1,4 @@ -## check-new-year.ps1 - Checks the time until New Year +## The check-new-year.ps1 PowerShell Script This PowerShell script checks the time until New Year and replies by text-to-speech (TTS). @@ -23,4 +23,33 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the time until New Year +.DESCRIPTION + This PowerShell script checks the time until New Year and replies by text-to-speech (TTS). +.EXAMPLE + PS> ./check-new-year +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Now = [DateTime]::Now + $NewYear = [Datetime]("12/31/" + $Now.Year) + $Days = ($NewYear โ€“ $Now).Days + 1 + if ($Days -gt 1) { + & "$PSScriptRoot/give-reply.ps1" "New Year is in $Days days." + } elseif ($Days -eq 1) { + & "$PSScriptRoot/give-reply.ps1" "New Year is tomorrow." + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-new-year.ps1* diff --git a/Docs/check-noon.md b/Docs/check-noon.md index 5253fbe5..a5c455d2 100644 --- a/Docs/check-noon.md +++ b/Docs/check-noon.md @@ -1,4 +1,6 @@ -## check-noon.ps1 - check-noon.ps1 +## The check-noon.ps1 PowerShell Script + +check-noon.ps1 ## Parameters @@ -10,4 +12,46 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Checks for Noon +.DESCRIPTION + This PowerShell script checks the time until Noon and replies by text-to-speech (TTS). +.EXAMPLE + PS> ./check-noon +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function TimeSpanToString { param([TimeSpan]$Delta) + $Result = "" + if ($Delta.Hours -eq 1) { $Result += "1 hour and " + } elseif ($Delta.Hours -gt 1) { $Result += "$($Delta.Hours) hours and " + } + if ($Delta.Minutes -eq 1) { $Result += "1 minute" + } else { $Result += "$($Delta.Minutes) minutes" + } + return $Result +} + +try { + $Now = [DateTime]::Now + $Noon = Get-Date -Hour 12 -Minute 0 -Second 0 + if ($Now -lt $Noon) { + $TimeSpan = TimeSpanToString($Noon - $Now) + $Reply = "Noon is in $TimeSpan." + } else { + $TimeSpan = TimeSpanToString($Now - $Noon) + $Reply = "Noon was $TimeSpan ago." + } + & "$PSScriptRoot/give-reply.ps1" "$Reply" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-noon.ps1* diff --git a/Docs/check-operating-system.md b/Docs/check-operating-system.md index ee43d5b2..60904d7e 100644 --- a/Docs/check-operating-system.md +++ b/Docs/check-operating-system.md @@ -1,4 +1,4 @@ -## check-operating-system.ps1 - Query OS details +## The check-operating-system.ps1 PowerShell Script This PowerShell script queries and lists operating system details. @@ -23,4 +23,40 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Query OS details +.DESCRIPTION + This PowerShell script queries and lists operating system details. +.EXAMPLE + PS> ./check-operating-system +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + "โœ… $(uname -sr)." + } else { + $OS = Get-WmiObject -class Win32_OperatingSystem + $Name = $OS.Caption + $Arch = $OS.OSArchitecture + $Version = $OS.Version + + [system.threading.thread]::currentthread.currentculture = [system.globalization.cultureinfo]"en-US" + $OSDetails = Get-CimInstance Win32_OperatingSystem + $BuildNo = $OSDetails.BuildNumber + $Serial = $OSDetails.SerialNumber + $InstallDate = $OSDetails.InstallDate + "โœ… $($Name): $Arch, v$Version, S/N $Serial, installed $($InstallDate.ToShortDateString())" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-operating-system.ps1* diff --git a/Docs/check-outlook.md b/Docs/check-outlook.md index a45b1095..27777192 100644 --- a/Docs/check-outlook.md +++ b/Docs/check-outlook.md @@ -1,4 +1,4 @@ -## check-outlook.ps1 - Checks Outlook's inbox +## The check-outlook.ps1 PowerShell Script This PowerShell script checks the inbox of Outlook for new/unread mails. @@ -23,4 +23,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks Outlook's inbox +.DESCRIPTION + This PowerShell script checks the inbox of Outlook for new/unread mails. +.EXAMPLE + PS> ./check-outlook +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Add-Type -assembly "Microsoft.Office.Interop.Outlook" + $Outlook = New-Object -comobject Outlook.Application + $Namespace = $Outlook.GetNameSpace("MAPI") + $Inbox = $Namespace.GetDefaultFolder(6) # 6 = olFolderInbox + [int]$Unread = 0 + foreach($Mail in $Inbox.Items) { + if ($Mail.Unread -eq $false) { continue } + "โš ๏ธ New mail '$($Mail.Subject)' from $($Mail.SenderName)." + $Unread++ + } + if ($Unread -eq 0) { "โœ… No new mails." } + exit 0 # success +} catch { + "Sorry: $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-outlook.ps1* diff --git a/Docs/check-pending-reboot.md b/Docs/check-pending-reboot.md index 14536aa7..7890e55d 100644 --- a/Docs/check-pending-reboot.md +++ b/Docs/check-pending-reboot.md @@ -1,4 +1,6 @@ -## check-pending-reboot.ps1 - check-pending-reboot.ps1 +## The check-pending-reboot.ps1 PowerShell Script + +check-pending-reboot.ps1 ## Parameters @@ -10,4 +12,69 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Check for pending reboots +.DESCRIPTION + This PowerShell script checks different registry keys and values to determine if a reboot is pending. +.EXAMPLE + ./check-pending-reboot.ps1 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function Test-RegistryValue { param([parameter(Mandatory=$true)][ValidateNotNullOrEmpty()]$Path, [parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()]$Value) + try { + Get-ItemProperty -Path $Path -Name $Value -EA Stop + return $true + } catch { + return $false + } +} + +$Reason = "" + +if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired") { + $Reason += ", found registry entry '...\WindowsUpdate\Auto Update\RebootRequired'" +} +if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting") { + $Reason += ", found registry entry '...\WindowsUpdate\Auto Update\PostRebootReporting'" +} +if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending") { + $Reason += ", found registry entry '...\Component Based Servicing\RebootPending'" +} +if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts") { + $Reason += ", found registry entry '...\ServerManager\CurrentRebootAttempts'" +} +if (Test-RegistryValue -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing" -Value "RebootInProgress") { + $Reason += ", found registry entry '...\CurrentVersion\Component Based Servicing' with 'RebootInProgress'" +} +if (Test-RegistryValue -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing" -Value "PackagesPending") { + $Reason += ", found registry entry '...\CurrentVersion\Component Based Servicing' with 'PackagesPending'" +} +#if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Value "PendingFileRenameOperations") { +# $Reason += ", found registry entry '...\CurrentControlSet\Control\Session Manager' with 'PendingFileRenameOperations'" +#} +if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Value "PendingFileRenameOperations2") { + $Reason += ", found registry entry '...\CurrentControlSet\Control\Session Manager' with 'PendingFileRenameOperations2'" +} +if (Test-RegistryValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" -Value "DVDRebootSignal") { + $Reason += ", found registry entry '...\Windows\CurrentVersion\RunOnce' with 'DVDRebootSignal'" +} +if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "JoinDomain") { + $Reason += ", found registry entry '...\CurrentControlSet\Services\Netlogon' with 'JoinDomain'" +} +if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "AvoidSpnSet") { + $Reason += ", found registry entry '...\CurrentControlSet\Services\Netlogon' with 'AvoidSpnSet'" +} +if ($Reason -ne "") { + "โš ๏ธ Pending reboot ($($Reason.substring(2)))." +} else { + "โœ… No pending reboot." +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of check-pending-reboot.ps1* diff --git a/Docs/check-ping.md b/Docs/check-ping.md index 61955b04..dd64d41a 100644 --- a/Docs/check-ping.md +++ b/Docs/check-ping.md @@ -1,4 +1,4 @@ -## check-ping.ps1 - Checks the ping latency +## The check-ping.ps1 PowerShell Script This PowerShell script checks the ping latency from the local computer to some Internet hosts. @@ -33,4 +33,44 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the ping latency +.DESCRIPTION + This PowerShell script checks the ping latency from the local computer to some Internet hosts. +.PARAMETER hosts + Specifies the hosts to check, seperated by comma (default is: amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com) +.EXAMPLE + PS> ./check-ping + โœ… Ping is 25ms average, 13ms min, 109ms max. +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$hosts = "amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com") + +try { + Write-Progress "โณ Pinging $hosts..." + $HostsArray = $hosts.Split(",") + $Pings = Test-Connection -count 1 -computerName $HostsArray + + [int]$Min = 9999999 + [int]$Max = [int]$Avg = 0 + foreach($Ping in $Pings) { + if ($IsLinux) { [int]$Latency = $Ping.latency } else { [int]$Latency = $Ping.ResponseTime } + if ($Latency -lt $Min) { $Min = $Latency } + if ($Latency -gt $Max) { $Max = $Latency } + $Avg += $Latency + } + $Avg /= $Pings.count + "โœ… Ping is $($Avg)ms average, $($Min)ms min, $($Max)ms max." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-ping.ps1* diff --git a/Docs/check-ram.md b/Docs/check-ram.md index f77a735c..7aaaba41 100644 --- a/Docs/check-ram.md +++ b/Docs/check-ram.md @@ -1,4 +1,6 @@ -## check-ram.ps1 - check-ram.ps1 +## The check-ram.ps1 PowerShell Script + +check-ram.ps1 ## Parameters @@ -10,4 +12,68 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Checks the RAM +.DESCRIPTION + This PowerShell script queries and prints details of the installed RAM. +.EXAMPLE + PS> ./check-ram +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function GetRAMType { param([int]$Type) + switch($Type) { + 2 { return "DRAM" } + 5 { return "EDO RAM" } + 6 { return "EDRAM" } + 7 { return "VRAM" } + 8 { return "SRAM" } + 10 { return "ROM" } + 11 { return "Flash RAM" } + 12 { return "EEPROM" } + 13 { return "FEPROM" } + 14 { return "EPROM" } + 15 { return "CDRAM" } + 16 { return "3DRAM" } + 17 { return "SDRAM" } + 18 { return "SGRAM" } + 19 { return "RDRAM" } + 20 { return "DDR RAM" } + 21 { return "DDR2 RAM" } + 22 { return "DDR2 FB-DIMM" } + 24 { return "DDR3 RAM" } + 26 { return "DDR4 RAM" } + 27 { return "DDR5 RAM" } + 28 { return "DDR6 RAM" } + 29 { return "DDR7 RAM" } + default { return "RAM" } + } +} + +try { + if ($IsLinux) { + # TODO + } else { + $Banks = Get-WmiObject -Class Win32_PhysicalMemory + foreach ($Bank in $Banks) { + $Capacity = $Bank.Capacity / (1024 * 1024 * 1024) + $Type = GetRAMType $Bank.SMBIOSMemoryType + $Speed = $Bank.Speed + [float]$Voltage = $Bank.ConfiguredVoltage / 1000.0 + $Manufacturer = $Bank.Manufacturer + $Location = "$($Bank.BankLabel)/$($Bank.DeviceLocator)" + "โœ… $($Capacity)GB $($Type) by $($Manufacturer): $($Speed)MHz, $($Voltage)V at $Location" + } + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-ram.ps1* diff --git a/Docs/check-repo.md b/Docs/check-repo.md index 88ef5971..d4d8ce4f 100644 --- a/Docs/check-repo.md +++ b/Docs/check-repo.md @@ -1,4 +1,4 @@ -## check-repo.ps1 - Checks a Git repository +## The check-repo.ps1 PowerShell Script This PowerShell script verifies the integrity of a local Git repository. @@ -32,4 +32,83 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks a Git repository +.DESCRIPTION + This PowerShell script verifies the integrity of a local Git repository. +.PARAMETER RepoDir + Specifies the path to the Git repository (current working dir by default) +.EXAMPLE + PS> ./check-repo +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RepoDir = "$PWD") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + Write-Host "โณ (1/11) Searching for Git executable... " -noNewline + & git --version + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + Write-Host "โณ (2/11) Checking path... " -noNewline + $FullPath = Resolve-Path "$RepoDir" + if (!(Test-Path "$FullPath" -pathType Container)) { throw "Can't access folder: $FullPath" } + "$FullPath" + + Write-Host "โณ (3/11) Searching for ๐Ÿ“‚.git... " -noNewline + if (!(Test-Path "$FullPath/.git" -pathType container)) { throw "Can't access folder: $FullPath/.git" } + "OK" + + Write-Host "โณ (4/11) Query remote URL... " -noNewline + & git -C "$FullPath" remote get-url origin + if ($lastExitCode -ne "0") { throw "'git remote get-url origin' failed with exit code $lastExitCode" } + + Write-Host "โณ (5/11) Query current branch... " -noNewline + & git -C "$FullPath" branch --show-current + if ($lastExitCode -ne "0") { throw "'git branch --show-current' failed with exit code $lastExitCode" } + + Write-Host "โณ (6/11) Trying to fetch... " -noNewline + & git -C "$FullPath" fetch + if ($lastExitCode -ne "0") { throw "'git branch --show-current' failed with exit code $lastExitCode" } + Write-Host "OK" + + Write-Host "โณ (7/11) Query latest tag... " -noNewline + $LatestTagCommitID = (git -C "$FullPath" rev-list --tags --max-count=1) + $LatestTagName = (git -C "$FullPath" describe --tags $LatestTagCommitID) + Write-Host "$LatestTagName (commit $LatestTagCommitID)" + + Write-Host "โณ (8/11) Verify data integrity..." + & git -C "$FullPath" fsck + if ($lastExitCode -ne "0") { throw "'git fsck' failed with exit code $lastExitCode" } + + Write-Host "โณ (9/11) Run maintenance tasks..." + & git -C "$FullPath" maintenance run + if ($lastExitCode -ne "0") { throw "'git maintenance run' failed with exit code $lastExitCode" } + + Write-Host "โณ (10/11) Query submodule status... " -noNewline + & git -C "$FullPath" submodule status + if ($lastExitCode -ne "0") { throw "'git submodule status' failed with exit code $lastExitCode" } + " " + + Write-Host "โณ (11/11) Query repository status... " -noNewline + & git -C "$FullPath" status --short + if ($lastExitCode -ne "0") { throw "'git status --short' failed with exit code $lastExitCode" } + " " + + $RepoDirName = (Get-Item "$FullPath").Name + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ checked ๐Ÿ“‚$RepoDirName repo in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-repo.ps1* diff --git a/Docs/check-santa.md b/Docs/check-santa.md index 8a886ad4..a9aebe0a 100644 --- a/Docs/check-santa.md +++ b/Docs/check-santa.md @@ -1,4 +1,4 @@ -## check-santa.ps1 - Checks the time until Saint Nicholas Day +## The check-santa.ps1 PowerShell Script This PowerShell script checks the time until Saint Nicholas Day and replies by text-to-speech (TTS). @@ -23,4 +23,29 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the time until Saint Nicholas Day +.DESCRIPTION + This PowerShell script checks the time until Saint Nicholas Day and replies by text-to-speech (TTS). +.EXAMPLE + PS> ./check-santa +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Now = [DateTime]::Now + $Diff = [Datetime]("12/06/" + $Now.Year) โ€“ $Now + + & "$PSScriptRoot/give-reply.ps1" "Saint Nicholas Day is in $($Diff.Days) days." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-santa.ps1* diff --git a/Docs/check-smart-devices.md b/Docs/check-smart-devices.md index 36f8ce84..e0488b31 100644 --- a/Docs/check-smart-devices.md +++ b/Docs/check-smart-devices.md @@ -1,4 +1,6 @@ -## check-smart-devices.ps1 - check-smart-devices.ps1 +## The check-smart-devices.ps1 PowerShell Script + +check-smart-devices.ps1 ## Parameters @@ -10,4 +12,80 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Checks SMART devices +.DESCRIPTION + This PowerShell script queries S.M.A.R.T. HDD/SSD device details and prints it. +.EXAMPLE + PS> ./check-smart-devices + โœ… 1TB Samsung SSD 970 EVO via NVMe: 37ยฐC, 2388 hours, 289x on, v2B2QEXE7, selftest passed +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function Bytes2String { param([int64]$Bytes) + if ($Bytes -lt 1000) { return "$Bytes bytes" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)KB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)MB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)GB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)TB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)PB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)EB" } +} + +try { + Write-Progress "โณ Step 1/3 - Searching for smartctl executable..." + $Result = (smartctl --version) + if ($lastExitCode -ne "0") { throw "Can't execute 'smartctl' - make sure smartmontools are installed" } + + Write-Progress "โณ Step 2/3 - Scanning S.M.A.R.T devices..." + if ($IsLinux) { + $Devices = $(sudo smartctl --scan-open) + } else { + $Devices = $(smartctl --scan-open) + } + foreach($Device in $Devices) { + Write-Progress "โณ Step 3/3 - Querying S.M.A.R.T devices..." + $Array = $Device.split(" ") + $Device = $Array[0] + if ("$Device" -eq "#") { + continue + } elseif ($IsLinux) { + $Details = (sudo smartctl --all --json $Device) | ConvertFrom-Json + $null = (sudo smartctl --test=short $Device) + } else { + $Details = (smartctl --all --json $Device) | ConvertFrom-Json + $null = (smartctl --test=short $Device) + } + $ModelName = $Details.model_name + $Protocol = $Details.device.protocol + [int64]$GBytes = $Details.user_capacity.bytes + if ($GBytes -gt 0) { + $Capacity = "$(Bytes2String $GBytes) " + } else { + $Capacity = "" + } + $Temp = $Details.temperature.current + $Firmware = $Details.firmware_version + $PowerOn = $Details.power_cycle_count + $Hours = $Details.power_on_time.hours + if ($Details.smart_status.passed) { $Status = "passed" } else { $Status = "FAILED" } + "โœ… $($Capacity)$ModelName via $($Protocol): $($Temp)ยฐC, $($Hours) hours, $($PowerOn)x on, v$($Firmware), selftest $Status" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-smart-devices.ps1* diff --git a/Docs/check-subnet-mask.md b/Docs/check-subnet-mask.md index 96598552..80df412d 100644 --- a/Docs/check-subnet-mask.md +++ b/Docs/check-subnet-mask.md @@ -1,4 +1,4 @@ -## check-subnet-mask.ps1 - Checks the given subnet mask for validity +## The check-subnet-mask.ps1 PowerShell Script This PowerShell script checks the given subnet mask for validity. @@ -33,4 +33,47 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the given subnet mask for validity +.DESCRIPTION + This PowerShell script checks the given subnet mask for validity. +.PARAMETER address + Specifies the subnet mask to check +.EXAMPLE + PS> ./check-subnet-mask 255.255.255.0 + โœ”๏ธ subnet mask 255.255.255.0 is valid +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$address = "") + +function IsSubNetMaskValid { param([string]$IP) + $RegEx = "^(254|252|248|240|224|192|128).0.0.0$|^255.(254|252|248|240|224|192|128|0).0.0$|^255.255.(254|252|248|240|224|192|128|0).0$|^255.255.255.(255|254|252|248|240|224|192|128|0)$" + if ($IP -match $RegEx) { + return $true + } else { + return $false + } +} + +try { + if ($address -eq "" ) { $address = read-host "Enter subnet mask to validate" } + + if (IsSubNetMaskValid $address) { + "โœ”๏ธ subnet mask $Address is valid" + exit 0 # success + } else { + write-warning "Invalid subnet mask: $address" + exit 1 + } +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-subnet-mask.ps1* diff --git a/Docs/check-swap-space.md b/Docs/check-swap-space.md index ec944230..219673b8 100644 --- a/Docs/check-swap-space.md +++ b/Docs/check-swap-space.md @@ -1,4 +1,4 @@ -## check-swap-space.ps1 - Checks the swap space +## The check-swap-space.ps1 PowerShell Script This PowerShell script checks the free swap space. @@ -33,4 +33,67 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the swap space +.DESCRIPTION + This PowerShell script checks the free swap space. +.PARAMETER MinLevel + Specifies the minimum level (10 GB by default) +.EXAMPLE + PS> ./check-swap-space + โœ… Swap space uses 63 GB of 1856 GB. +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([int]$MinLevel = 10) # minimum level in GB + +function MB2String { param([int64]$Bytes) + if ($Bytes -lt 1000) { return "$($Bytes)MB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)GB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)TB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)PB" } + $Bytes /= 1000 + if ($Bytes -lt 1000) { return "$($Bytes)EB" } +} + +try { + [int]$Total = [int]$Used = [int]$Free = 0 + if ($IsLinux) { + $Result = $(free --mega | grep Swap:) + [int]$Total = $Result.subString(5,14) + [int]$Used = $Result.substring(20,13) + [int]$Free = $Result.substring(32,11) + } else { + $Items = Get-WmiObject -class "Win32_PageFileUsage" -namespace "root\CIMV2" -computername localhost + foreach ($Item in $Items) { + $Total = $Item.AllocatedBaseSize + $Used = $Item.CurrentUsage + $Free = ($Total - $Used) + } + } + if ($Total -eq 0) { + "โš ๏ธ No swap space!" + } elseif ($Free -lt $MinLevel) { + "โš ๏ธ Swap space has only $(MB2String $Free) of $(MB2String $Total) left to use!" + } elseif ($Used -eq 0) { + "โœ… Swap space of $(MB2String $Total) is unused." + } elseif ($Used -lt $Free) { + "โœ… Swap space uses $(MB2String $Used) of $(MB2String $Total)." + } else { + "โœ… Swap space has $(MB2String $Free) of $(MB2String $Total) left." + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-swap-space.ps1* diff --git a/Docs/check-symlinks.md b/Docs/check-symlinks.md index 9388f426..ebbd1220 100644 --- a/Docs/check-symlinks.md +++ b/Docs/check-symlinks.md @@ -1,4 +1,4 @@ -## check-symlinks.ps1 - Checks symlinks in a folder +## The check-symlinks.ps1 PowerShell Script This PowerShell script checks every symbolic link in a folder (including subfolders). It returns the number of broken symlinks as exit value. @@ -33,4 +33,61 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks symlinks in a folder +.DESCRIPTION + This PowerShell script checks every symbolic link in a folder (including subfolders). + It returns the number of broken symlinks as exit value. +.PARAMETER folder + Specifies the path to the folder +.EXAMPLE + PS> ./check-symlinks C:\Users +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Folder = "") + +try { + if ($Folder -eq "" ) { $Folder = read-host "Enter the path to the folder" } + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + $FullPath = Resolve-Path "$Folder" + "โณ Checking symlinks at ๐Ÿ“‚$FullPath including subfolders..." + + [int]$NumTotal = [int]$NumBroken = 0 + Get-ChildItem $FullPath -recurse | Where { $_.Attributes -match "ReparsePoint" } | ForEach-Object { + $Symlink = $_.FullName + $Target = ($_ | Select-Object -ExpandProperty Target -ErrorAction Ignore) + if ($Target) { + $path = $_.FullName + "\..\" + ($_ | Select-Object -ExpandProperty Target) + $item = Get-Item $path -ErrorAction Ignore + if (!$item) { + $NumBroken++ + "Broken symlink #$($NumBroken): $Symlink โญข $Target" + } + } + $NumTotal++ + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + if ($NumTotal -eq 0) { + "โœ”๏ธ found no symlink at ๐Ÿ“‚$FullPath in $Elapsed sec" + } elseif ($NumBroken -eq 0) { + "โœ”๏ธ found $NumTotal valid symlinks at ๐Ÿ“‚$FullPath in $Elapsed sec" + } elseif ($NumBroken -eq 1) { + "โœ”๏ธ found $NumBroken broken symlink out of $NumTotal at ๐Ÿ“‚$FullPath in $Elapsed sec" + } else { + "โœ”๏ธ found $NumBroken broken symlinks out of $NumTotal at ๐Ÿ“‚$FullPath in $Elapsed sec" + } + exit $NumBroken +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-symlinks.ps1* diff --git a/Docs/check-time-zone.md b/Docs/check-time-zone.md index 5420ffa1..19de9a34 100644 --- a/Docs/check-time-zone.md +++ b/Docs/check-time-zone.md @@ -1,4 +1,4 @@ -## check-time-zone.ps1 - Checks the time zone setting +## The check-time-zone.ps1 PowerShell Script This PowerShell script determines and prints the current time zone. @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the time zone setting +.DESCRIPTION + This PowerShell script determines and prints the current time zone. +.EXAMPLE + PS> ./check-time-zone +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + [system.threading.thread]::currentThread.currentCulture = [system.globalization.cultureInfo]"en-US" + $Time = $((Get-Date).ToShortTimeString()) + $TZ = (Get-Timezone) + if ($TZ.SupportsDaylightSavingTime) { $DST=" & +01:00:00 DST" } else { $DST="" } + "โœ… $Time in $($TZ.Id) (UTC+$($TZ.BaseUtcOffset)$DST)." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-time-zone.ps1* diff --git a/Docs/check-uptime.md b/Docs/check-uptime.md index 9e637c8e..50127c3c 100644 --- a/Docs/check-uptime.md +++ b/Docs/check-uptime.md @@ -1,4 +1,4 @@ -## check-uptime.ps1 - Check uptime +## The check-uptime.ps1 PowerShell Script This PowerShell script queries and prints the uptime. @@ -23,4 +23,52 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Check uptime +.DESCRIPTION + This PowerShell script queries and prints the uptime. +.EXAMPLE + PS> ./check-uptime +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + $Uptime = (get-uptime) + } else { + $BootTime = Get-WinEvent -ProviderName eventlog | Where-Object {$_.Id -eq 6005} | Select-Object TimeCreated -First 1 + $Uptime = New-TimeSpan -Start $BootTime.TimeCreated.Date -End (Get-Date) + } + $Days = $Uptime.Days + $Hours = $Uptime.Hours + $Minutes = $Uptime.Minutes + + $Reply = "Up for " + if ($Days -eq "1") { + $Reply += "1 day, " + } elseif ($Days -ne "0") { + $Reply += "$Days days, " + } + if ($Hours -eq "1") { + $Reply += "1 hour, " + } elseif ($Hours -ne "0") { + $Reply += "$Hours hours, " + } + if ($Minutes -eq "1") { + $Reply += "1 minute" + } else { + $Reply += "$Minutes minutes" + } + "โœ… $Reply." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-uptime.ps1* diff --git a/Docs/check-vpn.md b/Docs/check-vpn.md index cf6fc305..1261b8a0 100644 --- a/Docs/check-vpn.md +++ b/Docs/check-vpn.md @@ -1,4 +1,4 @@ -## check-vpn.ps1 - Checks the VPN connection +## The check-vpn.ps1 PowerShell Script This PowerShell script queries and prints the status of any VPN connection. @@ -23,4 +23,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the VPN connection +.DESCRIPTION + This PowerShell script queries and prints the status of any VPN connection. +.EXAMPLE + PS> ./check-vpn +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $NoVPN = $true + if ($IsLinux) { + # TODO + } else { + $Connections = (Get-VPNConnection) + foreach($Connection in $Connections) { + "โœ… VPN '$($Connection.Name)' is $($Connection.ConnectionStatus)." + $NoVPN = $false + } + } + if ($NoVPN) { "โš ๏ธ No VPN connection." } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-vpn.ps1* diff --git a/Docs/check-weather.md b/Docs/check-weather.md index 2cf62c4e..bc8ea1dc 100644 --- a/Docs/check-weather.md +++ b/Docs/check-weather.md @@ -1,4 +1,4 @@ -## check-weather.ps1 - Checks the weather +## The check-weather.ps1 PowerShell Script This PowerShell script checks the current weather report. @@ -32,4 +32,45 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the weather +.DESCRIPTION + This PowerShell script checks the current weather report. +.PARAMETER location + Specifies the location to use (determined automatically per default) +.EXAMPLE + PS> ./check-weather +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$location = "") # empty means determine automatically + +try { + $Weather = (Invoke-WebRequest http://wttr.in/${location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json + + $Temp = $Weather.current_condition.temp_C + $Precip = $Weather.current_condition.precipMM + $Humidity = $Weather.current_condition.humidity + $Pressure = $Weather.current_condition.pressure + $WindSpeed = $Weather.current_condition.windspeedKmph + $WindDir = $Weather.current_condition.winddir16Point + $UV = $Weather.current_condition.uvIndex + $Visib = $Weather.current_condition.visibility + $Clouds = $Weather.current_condition.cloudcover + $Desc = $Weather.current_condition.weatherDesc.value + $Area = $Weather.nearest_area.areaName.value + $Region = $Weather.nearest_area.region.value + + & "$PSScriptRoot/give-reply.ps1" "$($Temp)ยฐC, $($Precip)mm rain, $($Humidity)% humidity, $($WindSpeed)km/h wind from $WindDir with $($Clouds)% clouds and $($Visib)km visibility at $Area ($Region)." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-weather.ps1* diff --git a/Docs/check-week.md b/Docs/check-week.md index 8e4afa2b..acb5446d 100644 --- a/Docs/check-week.md +++ b/Docs/check-week.md @@ -1,4 +1,4 @@ -## check-week.ps1 - Determines the week number +## The check-week.ps1 PowerShell Script This PowerShell script determines and speaks the current week number by text-to-speech (TTS). @@ -24,4 +24,28 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Determines the week number +.DESCRIPTION + This PowerShell script determines and speaks the current week number by text-to-speech (TTS). +.EXAMPLE + PS> ./check-week + โœ”๏ธ It's week #4. +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $WeekNo = (get-date -UFormat %V) + & "$PSScriptRoot/give-reply.ps1" "It's week #$WeekNo." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-week.ps1* diff --git a/Docs/check-wind.md b/Docs/check-wind.md index fca5cd79..55325abe 100644 --- a/Docs/check-wind.md +++ b/Docs/check-wind.md @@ -1,4 +1,4 @@ -## check-wind.ps1 - Checks the wind conditions +## The check-wind.ps1 PowerShell Script This PowerShell script determines the current wind conditions and replies by text-to-speech (TTS). @@ -32,4 +32,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the wind conditions +.DESCRIPTION + This PowerShell script determines the current wind conditions and replies by text-to-speech (TTS). +.PARAMETER location + Specifies the location to use (determined automatically per default) +.EXAMPLE + PS> ./check-wind +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$location = "") # empty means determine automatically + +try { + $Weather = (Invoke-WebRequest http://wttr.in/${location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json + $WindSpeed = $Weather.current_condition.windspeedKmph + $WindDir = $Weather.current_condition.winddir16Point + $Area = $Weather.nearest_area.areaName.value + $Region = $Weather.nearest_area.region.value + + & "$PSScriptRoot/give-reply.ps1" "$($WindSpeed)km/h wind from $WindDir at $Area ($Region)." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-wind.ps1* diff --git a/Docs/check-windows-system-files.md b/Docs/check-windows-system-files.md index c2c9bec7..692a562f 100644 --- a/Docs/check-windows-system-files.md +++ b/Docs/check-windows-system-files.md @@ -1,4 +1,4 @@ -## check-windows-system-files.ps1 - Checks the validity of the Windows system files (requires admin rights) +## The check-windows-system-files.ps1 PowerShell Script This PowerShell script checks the validity of the Windows system files. It requires admin rights. @@ -24,4 +24,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the validity of the Windows system files (requires admin rights) +.DESCRIPTION + This PowerShell script checks the validity of the Windows system files. It requires admin rights. +.EXAMPLE + PS> ./check-windows-system-files + โœ”๏ธ checked Windows system files +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +try { + sfc /verifyOnly + if ($lastExitCode -ne "0") { throw "'sfc /verifyOnly' failed" } + + "โœ”๏ธ checked Windows system files" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-windows-system-files.ps1* diff --git a/Docs/check-xml-file.md b/Docs/check-xml-file.md index d5f41926..68834c4f 100644 --- a/Docs/check-xml-file.md +++ b/Docs/check-xml-file.md @@ -1,4 +1,4 @@ -## check-xml-file.ps1 - Checks the given XML file for validity +## The check-xml-file.ps1 PowerShell Script This PowerShell script checks the given XML file for validity. @@ -33,4 +33,51 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Checks the given XML file for validity +.DESCRIPTION + This PowerShell script checks the given XML file for validity. +.PARAMETER file + Specifies the path to the XML file to check +.EXAMPLE + PS> ./check-xml-file myfile.xml + โœ”๏ธ XML file is valid +.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 XML file" } + + $XmlFile = Get-Item $file + + $script:ErrorCount = 0 + + # Perform the XSD Validation + $ReaderSettings = New-Object -TypeName System.Xml.XmlReaderSettings + $ReaderSettings.ValidationType = [System.Xml.ValidationType]::Schema + $ReaderSettings.ValidationFlags = [System.Xml.Schema.XmlSchemaValidationFlags]::ProcessInlineSchema -bor [System.Xml.Schema.XmlSchemaValidationFlags]::ProcessSchemaLocation + $ReaderSettings.add_ValidationEventHandler({ $script:ErrorCount++ }) + $Reader = [System.Xml.XmlReader]::Create($XmlFile.FullName, $ReaderSettings) + while ($Reader.Read()) { } + $Reader.Close() + + if ($script:ErrorCount -gt 0) { + write-warning "Invalid XML file" + exit 1 + } + + "โœ”๏ธ XML file is valid" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of check-xml-file.ps1* diff --git a/Docs/clean-repo.md b/Docs/clean-repo.md index 0445c914..e7e14962 100644 --- a/Docs/clean-repo.md +++ b/Docs/clean-repo.md @@ -1,4 +1,4 @@ -## clean-repo.ps1 - Clean a repository +## The clean-repo.ps1 PowerShell Script This PowerShell script deletes all untracked files and folders in a Git repository (including submodules). NOTE: To be used with care! This cannot be undone! @@ -33,4 +33,54 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Clean a repository +.DESCRIPTION + This PowerShell script deletes all untracked files and folders in a Git repository (including submodules). + NOTE: To be used with care! This cannot be undone! +.PARAMETER RepoDir + Specifies the path to the Git repository +.EXAMPLE + PS> ./clean-repo C:\MyRepo +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RepoDir = "$PWD") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + Write-Host "โณ (1/4) Searching for Git executable... " -noNewline + & git --version + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + $RepoDirName = (Get-Item "$RepoDir").Name + "โณ (2/4) Checking folder ๐Ÿ“‚$RepoDirName..." + if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access folder '$RepoDir' - maybe a typo or missing folder permissions?" } + + "โณ (3/4) Removing untracked files in repository..." + & git -C "$RepoDir" clean -xfd -f # to delete all untracked files in the main repo + if ($lastExitCode -ne "0") { + "'git clean' failed with exit code $lastExitCode, retrying once..." + & git -C "$RepoDir" clean -xfd -f + if ($lastExitCode -ne "0") { throw "'git clean' failed with exit code $lastExitCode" } + } + + "โณ (4/4) Removing untracked files in submodules..." + & git -C "$RepoDir" submodule foreach --recursive git clean -xfd -f # to delete all untracked files in the submodules + if ($lastExitCode -ne "0") { throw "'git clean' in the submodules failed with exit code $lastExitCode" } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ cleaned ๐Ÿ“‚$RepoDirName repo in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of clean-repo.ps1* diff --git a/Docs/clean-repos.md b/Docs/clean-repos.md index 20bcf240..368161ed 100644 --- a/Docs/clean-repos.md +++ b/Docs/clean-repos.md @@ -1,4 +1,4 @@ -## clean-repos.ps1 - Cleans all Git repositories in a folder from untracked files +## The clean-repos.ps1 PowerShell Script This PowerShell script cleans all Git repositories in a folder from untracked files (including submodules). @@ -32,4 +32,56 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Cleans all Git repositories in a folder from untracked files +.DESCRIPTION + This PowerShell script cleans all Git repositories in a folder from untracked files (including submodules). +.PARAMETER ParentDir + Specifies the path to the parent folder +.EXAMPLE + PS> ./clean-repos C:\MyRepos +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$ParentDir = "$PWD") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" } + + $Null = (git --version) + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + $Folders = (get-childItem "$ParentDir" -attributes Directory) + $FolderCount = $Folders.Count + $ParentDirName = (get-item "$ParentDir").Name + "Found $FolderCount subfolders in ๐Ÿ“‚$ParentDirName, cleaning them from untracked files..." + + [int]$Step = 1 + foreach ($Folder in $Folders) { + $FolderName = (get-item "$Folder").Name + "โณ Step $Step/$($FolderCount): Cleaning ๐Ÿ“‚$FolderName..." + + & git -C "$Folder" clean -xfd -f # force + recurse into dirs + don't use the standard ignore rules + if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' failed with exit code $lastExitCode" } + + & git -C "$Folder" submodule foreach --recursive git clean -xfd -f + if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' in submodules failed with exit code $lastExitCode" } + + $Step++ + } + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ cleaned $FolderCount Git repositories at ๐Ÿ“‚$ParentDirName in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of clean-repos.ps1* diff --git a/Docs/clear-dns-cache.md b/Docs/clear-dns-cache.md index 3a11b659..4bfddab4 100644 --- a/Docs/clear-dns-cache.md +++ b/Docs/clear-dns-cache.md @@ -1,4 +1,4 @@ -## clear-dns-cache.ps1 - Clears the DNS cache +## The clear-dns-cache.ps1 PowerShell Script This PowerShell script clears the DNS client cache of the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Clears the DNS cache +.DESCRIPTION + This PowerShell script clears the DNS client cache of the local computer. +.EXAMPLE + PS> ./clear-dns-cache +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + Clear-DnsClientCache + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ cleared DNS cache in $Elapsed ms." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of clear-dns-cache.ps1* diff --git a/Docs/clear-recycle-bin.md b/Docs/clear-recycle-bin.md index 4bc7da3c..42ffdb24 100644 --- a/Docs/clear-recycle-bin.md +++ b/Docs/clear-recycle-bin.md @@ -1,4 +1,4 @@ -## clear-recycle-bin.ps1 - Clears the recycle bin folder +## The clear-recycle-bin.ps1 PowerShell Script This PowerShell script removes the content of the recycle bin folder permanently. IMPORTANT NOTE: this cannot be undo! @@ -24,4 +24,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Clears the recycle bin folder +.DESCRIPTION + This PowerShell script removes the content of the recycle bin folder permanently. + IMPORTANT NOTE: this cannot be undo! +.EXAMPLE + PS> ./clear-recycle-bin +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Clear-RecycleBin -Confirm:$false + if ($lastExitCode -ne "0") { throw "'Clear-RecycleBin' failed" } + + & "$PSScriptRoot/give-reply.ps1" "It's clean now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of clear-recycle-bin.ps1* diff --git a/Docs/clone-repos.md b/Docs/clone-repos.md index 335dc768..00c383d2 100644 --- a/Docs/clone-repos.md +++ b/Docs/clone-repos.md @@ -1,4 +1,4 @@ -## clone-repos.ps1 - Clones Git repositories +## The clone-repos.ps1 PowerShell Script This PowerShell script clones well-known Git repositories into a folder. @@ -31,4 +31,77 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Clones Git repositories +.DESCRIPTION + This PowerShell script clones well-known Git repositories into a folder. +.PARAMETER folder + Specifies the target folder +.EXAMPLE + PS> ./clone-repos C:\Repos +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$FolderPath = "$PWD") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + "โณ Step 1 - Searching for Git executable..." + & git --version + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + "โณ Step 2 - Loading database table in Data/git-repos.csv..." + $Table = Import-CSV "$PSScriptRoot/../Data/git-repos.csv" + $NumEntries = $Table.count + "Found $NumEntries entries." + + $ParentFolderName = (Get-Item "$FolderPath").Name + "โณ Step 3 - Checking folder ๐Ÿ“‚$ParentFolderName..." + if (-not(Test-Path "$FolderPath" -pathType container)) { throw "Can't access directory: $FolderPath" } + + + [int]$Step = 3 + [int]$Cloned = 0 + [int]$Skipped = 0 + foreach($Row in $Table) { + [string]$FolderName = $Row.FolderName + [string]$Branch = $Row.Branch + [string]$Full = $Row.Full + [string]$URL = $Row.URL + $Step++ + + if (test-path "$FolderPath/$FolderName" -pathType container) { + "โณ Step $Step/$($NumEntries + 4) - Skipping ๐Ÿ“‚$($FolderName) (exists already)..." + $Skipped++ + continue + } + if ($Full -eq "yes") { + "โณ Step $Step/$($NumEntries + 4) - Cloning into ๐Ÿ“‚$($FolderName) ($Branch branch with full history)..." + & git clone --branch "$Branch" --recurse-submodules "$URL" "$FolderPath/$FolderName" + if ($lastExitCode -ne "0") { throw "'git clone --branch $Branch $URL' failed with exit code $lastExitCode" } + } else { + "โณ Step $Step/$($NumEntries + 4) - Cloning into ๐Ÿ“‚$FolderName ($Branch branch only)..." + & git clone --branch "$Branch" --single-branch --recurse-submodules "$URL" "$FolderPath/$FolderName" + if ($lastExitCode -ne "0") { throw "'git clone --branch $Branch $URL' failed with exit code $lastExitCode" } + } + $Cloned++ + } + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + if ($Cloned -eq 1) { + "โœ”๏ธ $Cloned repo cloned into ๐Ÿ“‚$ParentFolderName ($Skipped skipped) in $Elapsed sec" + } else { + "โœ”๏ธ $Cloned repos cloned into ๐Ÿ“‚$ParentFolderName ($Skipped skipped) in $Elapsed sec" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of clone-repos.ps1* diff --git a/Docs/close-calculator.md b/Docs/close-calculator.md index acaf40bc..1286bb47 100644 --- a/Docs/close-calculator.md +++ b/Docs/close-calculator.md @@ -1,4 +1,4 @@ -## close-calculator.ps1 - Closes the calculator application +## The close-calculator.ps1 PowerShell Script This PowerShell script closes the calculator application gracefully. @@ -23,4 +23,25 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the calculator application +.DESCRIPTION + This PowerShell script closes the calculator application gracefully. +.EXAMPLE + PS> ./close-calculator +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +TaskKill /im Calculator.exe /f /t +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/give-reply.ps1" "Sorry, calculator isn't running." + exit 1 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-calculator.ps1* diff --git a/Docs/close-chrome.md b/Docs/close-chrome.md index 3898faa6..3cce7739 100644 --- a/Docs/close-chrome.md +++ b/Docs/close-chrome.md @@ -1,4 +1,4 @@ -## close-chrome.ps1 - Closes the Chrome browser +## The close-chrome.ps1 PowerShell Script This PowerShell script closes the Google Chrome Web browser gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Chrome browser +.DESCRIPTION + This PowerShell script closes the Google Chrome Web browser gracefully. +.EXAMPLE + PS> ./close-chrome +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/close-program.ps1" "Google Chrome" "chrome" "chrome" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-chrome.ps1* diff --git a/Docs/close-cortana.md b/Docs/close-cortana.md index bcc3f639..c5b849e1 100644 --- a/Docs/close-cortana.md +++ b/Docs/close-cortana.md @@ -1,4 +1,4 @@ -## close-cortana.ps1 - Closes Microsoft's Cortana application +## The close-cortana.ps1 PowerShell Script This PowerShell script closes Microsoft's Cortana application gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes Microsoft's Cortana application +.DESCRIPTION + This PowerShell script closes Microsoft's Cortana application gracefully. +.EXAMPLE + PS> ./close-cortana +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/close-program.ps1" "Cortana" "Cortana" "Cortana" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-cortana.ps1* diff --git a/Docs/close-edge.md b/Docs/close-edge.md index c5c9f9f6..6aafb6a9 100644 --- a/Docs/close-edge.md +++ b/Docs/close-edge.md @@ -1,4 +1,4 @@ -## close-edge.ps1 - Closes the Edge browser +## The close-edge.ps1 PowerShell Script This PowerShell script closes the Microsoft Edge Web browser gracefully. @@ -23,4 +23,25 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Edge browser +.DESCRIPTION + This PowerShell script closes the Microsoft Edge Web browser gracefully. +.EXAMPLE + PS> ./close-edge +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +TaskKill /im msedge.exe /f /t +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/give-reply.ps1" "Sorry, Microsoft Edge isn't running." + exit 1 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-edge.ps1* diff --git a/Docs/close-file-explorer.md b/Docs/close-file-explorer.md index 8b994316..3b31852a 100644 --- a/Docs/close-file-explorer.md +++ b/Docs/close-file-explorer.md @@ -1,4 +1,4 @@ -## close-file-explorer.ps1 - Closes the File Explorer +## The close-file-explorer.ps1 PowerShell Script This PowerShell script closes the Microsoft File Explorer application gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the File Explorer +.DESCRIPTION + This PowerShell script closes the Microsoft File Explorer application gracefully. +.EXAMPLE + PS> ./close-file-explorer +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +(New-Object -ComObject Shell.Application).Windows() | %{$_.quit()} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-file-explorer.ps1* diff --git a/Docs/close-firefox.md b/Docs/close-firefox.md index ccb8dab5..3845ab5c 100644 --- a/Docs/close-firefox.md +++ b/Docs/close-firefox.md @@ -1,4 +1,4 @@ -## close-firefox.ps1 - Closes the Firefox browser +## The close-firefox.ps1 PowerShell Script This PowerShell script closes the Mozilla Firefox Web browser gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Firefox browser +.DESCRIPTION + This PowerShell script closes the Mozilla Firefox Web browser gracefully. +.EXAMPLE + PS> ./close-firefox +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/close-program.ps1" "Mozilla Firefox" "firefox" "firefox" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-firefox.ps1* diff --git a/Docs/close-git-extensions.md b/Docs/close-git-extensions.md index 428579a7..bd58c110 100644 --- a/Docs/close-git-extensions.md +++ b/Docs/close-git-extensions.md @@ -1,4 +1,4 @@ -## close-git-extensions.ps1 - Closes the Git Extensions app +## The close-git-extensions.ps1 PowerShell Script This PowerShell script closes the Git Extensions application gracefully. @@ -23,4 +23,25 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Git Extensions app +.DESCRIPTION + This PowerShell script closes the Git Extensions application gracefully. +.EXAMPLE + PS> ./close-git-extensions +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +TaskKill /im GitExtensions.exe +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/give-reply.ps1" "Sorry, Git Extensions isn't running." + exit 1 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-git-extensions.ps1* diff --git a/Docs/close-magnifier.md b/Docs/close-magnifier.md index f747f7db..d1e168e6 100644 --- a/Docs/close-magnifier.md +++ b/Docs/close-magnifier.md @@ -1,4 +1,4 @@ -## close-magnifier.ps1 - Closes the Magnifier +## The close-magnifier.ps1 PowerShell Script This PowerShell script closes the Windows Screen Magnifier application gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Magnifier +.DESCRIPTION + This PowerShell script closes the Windows Screen Magnifier application gracefully. +.EXAMPLE + PS> ./close-magnifier +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +tskill magnify +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-magnifier.ps1* diff --git a/Docs/close-microsoft-paint.md b/Docs/close-microsoft-paint.md index cecba8e3..d8da0c48 100644 --- a/Docs/close-microsoft-paint.md +++ b/Docs/close-microsoft-paint.md @@ -1,4 +1,4 @@ -## close-microsoft-paint.ps1 - Closes the Microsoft Paint app +## The close-microsoft-paint.ps1 PowerShell Script This PowerShell script closes the Microsoft Paint application gracefully. @@ -23,4 +23,25 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Microsoft Paint app +.DESCRIPTION + This PowerShell script closes the Microsoft Paint application gracefully. +.EXAMPLE + PS> ./close-microsoft-paint +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +TaskKill /im mspaint.exe +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/give-reply.ps1" "Sorry, Microsoft Paint isn't running." + exit 1 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-microsoft-paint.ps1* diff --git a/Docs/close-microsoft-store.md b/Docs/close-microsoft-store.md index 48de8dd6..f0c852b2 100644 --- a/Docs/close-microsoft-store.md +++ b/Docs/close-microsoft-store.md @@ -1,4 +1,4 @@ -## close-microsoft-store.ps1 - Closes the Microsoft Store app +## The close-microsoft-store.ps1 PowerShell Script This PowerShell script closes the Microsoft Store application gracefully. @@ -23,4 +23,25 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Microsoft Store app +.DESCRIPTION + This PowerShell script closes the Microsoft Store application gracefully. +.EXAMPLE + PS> ./close-microsoft-store +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +TaskKill /im WinStore.App.exe /f /t +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/give-reply.ps1" "Sorry, Microsoft Store isn't running." + exit 1 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-microsoft-store.ps1* diff --git a/Docs/close-netflix.md b/Docs/close-netflix.md index 4184a38d..7e8dde54 100644 --- a/Docs/close-netflix.md +++ b/Docs/close-netflix.md @@ -1,4 +1,4 @@ -## close-netflix.ps1 - Closes the Netflix app +## The close-netflix.ps1 PowerShell Script This PowerShell script closes the Netflix application gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Netflix app +.DESCRIPTION + This PowerShell script closes the Netflix application gracefully. +.EXAMPLE + PS> ./close-netflix +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/close-program.ps1" "Netflix" "ApplicationFrameHost" "RuntimeBroker" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-netflix.ps1* diff --git a/Docs/close-note-pad.md b/Docs/close-note-pad.md index 29826c88..d9341891 100644 --- a/Docs/close-note-pad.md +++ b/Docs/close-note-pad.md @@ -1,4 +1,4 @@ -## close-note-pad.ps1 - Closes the Notepad app +## The close-note-pad.ps1 PowerShell Script This PowerShell script closes the Notepad application gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Notepad app +.DESCRIPTION + This PowerShell script closes the Notepad application gracefully. +.EXAMPLE + PS> ./close-note-pad +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/close-program.ps1" "Notepad" "notepad" "notepad" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-note-pad.ps1* diff --git a/Docs/close-obs-studio.md b/Docs/close-obs-studio.md index 4569a1fd..828aa18d 100644 --- a/Docs/close-obs-studio.md +++ b/Docs/close-obs-studio.md @@ -1,4 +1,4 @@ -## close-obs-studio.ps1 - Closes OBS Studio +## The close-obs-studio.ps1 PowerShell Script This PowerShell script closes the OBS Studio application gracefully. @@ -23,4 +23,25 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes OBS Studio +.DESCRIPTION + This PowerShell script closes the OBS Studio application gracefully. +.EXAMPLE + PS> ./close-obs-studio +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +TaskKill /im obs64.exe +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/give-reply.ps1" "Sorry, OBS Studio isn't running" + exit 1 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-obs-studio.ps1* diff --git a/Docs/close-one-calendar.md b/Docs/close-one-calendar.md index 7bbc89c0..230bfe94 100644 --- a/Docs/close-one-calendar.md +++ b/Docs/close-one-calendar.md @@ -1,4 +1,4 @@ -## close-one-calendar.ps1 - Closes the OneCalendar app +## The close-one-calendar.ps1 PowerShell Script This PowerShell script closes the OneCalendar application gracefully. @@ -23,4 +23,25 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the OneCalendar app +.DESCRIPTION + This PowerShell script closes the OneCalendar application gracefully. +.EXAMPLE + PS> ./close-one-calendar +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +TaskKill /f /im CalendarApp.Gui.Win10.exe +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/give-reply.ps1" "Sorry, OneCalendar isn't running." + exit 1 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-one-calendar.ps1* diff --git a/Docs/close-outlook.md b/Docs/close-outlook.md index ec64e2d1..502e1635 100644 --- a/Docs/close-outlook.md +++ b/Docs/close-outlook.md @@ -1,4 +1,4 @@ -## close-outlook.ps1 - Closes the Microsoft Outlook app +## The close-outlook.ps1 PowerShell Script This PowerShell script closes the Microsoft Outlook email application gracefully. @@ -23,4 +23,25 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Microsoft Outlook app +.DESCRIPTION + This PowerShell script closes the Microsoft Outlook email application gracefully. +.EXAMPLE + PS> ./close-outlook +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +TaskKill /im outlook.exe +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/give-reply.ps1" "Sorry, Microsoft Outlook isn't running." + exit 1 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-outlook.ps1* diff --git a/Docs/close-paint-three-d.md b/Docs/close-paint-three-d.md index 83c8f9f3..b0f23ef3 100644 --- a/Docs/close-paint-three-d.md +++ b/Docs/close-paint-three-d.md @@ -1,4 +1,4 @@ -## close-paint-three-d.ps1 - Closes the Paint 3D app +## The close-paint-three-d.ps1 PowerShell Script This PowerShell script closes the Paint 3D application gracefully. @@ -23,4 +23,25 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Paint 3D app +.DESCRIPTION + This PowerShell script closes the Paint 3D application gracefully. +.EXAMPLE + PS> ./close-paint-3d +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +TaskKill /im PaintStudio.View.exe /f +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/give-reply.ps1" "Sorry, Paint 3D isn't running." + exit 1 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-paint-three-d.ps1* diff --git a/Docs/close-program.md b/Docs/close-program.md index 724d7b95..8b83324b 100644 --- a/Docs/close-program.md +++ b/Docs/close-program.md @@ -1,4 +1,4 @@ -## close-program.ps1 - Closes a program's processes +## The close-program.ps1 PowerShell Script This PowerShell script closes a program's processes gracefully. @@ -50,4 +50,64 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes a program's processes +.DESCRIPTION + This PowerShell script closes a program's processes gracefully. +.PARAMETER FullProgramName + Specifies the full program name +.PARAMETER ProgramName + Specifies the program name +.PARAMETER ProgramAliasName + Specifies the program alias name +.EXAMPLE + PS> ./close-program "Google Chrome" "chrome.exe" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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) { + $Process.CloseMainWindow() | Out-Null + } + start-sleep -milliseconds 100 + stop-process -name $ProgramName -force -errorAction 'silentlycontinue' + } else { + $Processes = get-process -name $ProgramAliasName -errorAction 'silentlycontinue' + if ($Processes.Count -eq 0) { + throw "$FullProgramName isn't running" + } + foreach ($Process in $Processes) { + $_.CloseMainWindow() | Out-Null + } + start-sleep -milliseconds 100 + stop-process -name $ProgramName -force -errorAction 'silentlycontinue' + } + if ($($Processes.Count) -eq 1) { + "โœ”๏ธ $FullProgramName closed, 1 process stopped" + } else { + "โœ”๏ธ $FullProgramName closed, $($Processes.Count) processes stopped" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of close-program.ps1* diff --git a/Docs/close-serenade.md b/Docs/close-serenade.md index c1576869..056d3afc 100644 --- a/Docs/close-serenade.md +++ b/Docs/close-serenade.md @@ -1,4 +1,4 @@ -## close-serenade.ps1 - Closes the Serenade.ai application +## The close-serenade.ps1 PowerShell Script This PowerShell script closes the Serenade.ai application gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Serenade.ai application +.DESCRIPTION + This PowerShell script closes the Serenade.ai application gracefully. +.EXAMPLE + PS> ./close-serenade +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/close-program.ps1" "Serenade.ai" "serenade" "" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-serenade.ps1* diff --git a/Docs/close-snipping-tool.md b/Docs/close-snipping-tool.md index 02de0099..4e753c73 100644 --- a/Docs/close-snipping-tool.md +++ b/Docs/close-snipping-tool.md @@ -1,4 +1,4 @@ -## close-snipping-tool.ps1 - Closes the Snipping Tool +## The close-snipping-tool.ps1 PowerShell Script This PowerShell script closes the Snipping Tool application gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Snipping Tool +.DESCRIPTION + This PowerShell script closes the Snipping Tool application gracefully. +.EXAMPLE + PS> ./close-snipping-tool +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/close-program.ps1" "Snipping Tool" "SnippingTool.exe" "" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-snipping-tool.ps1* diff --git a/Docs/close-spotify.md b/Docs/close-spotify.md index d2d20487..ba66ca63 100644 --- a/Docs/close-spotify.md +++ b/Docs/close-spotify.md @@ -1,4 +1,4 @@ -## close-spotify.ps1 - Closes Spotify +## The close-spotify.ps1 PowerShell Script This PowerShell script closes the Spotify application gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes Spotify +.DESCRIPTION + This PowerShell script closes the Spotify application gracefully. +.EXAMPLE + PS> ./close-spotify +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/close-program.ps1" "Spotify" "spotify" "" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-spotify.ps1* diff --git a/Docs/close-task-manager.md b/Docs/close-task-manager.md index 80d4bf3e..70651130 100644 --- a/Docs/close-task-manager.md +++ b/Docs/close-task-manager.md @@ -1,4 +1,4 @@ -## close-task-manager.ps1 - Closes the Task Manager +## The close-task-manager.ps1 PowerShell Script This PowerShell script closes the Task Manager application gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Task Manager +.DESCRIPTION + This PowerShell script closes the Task Manager application gracefully. +.EXAMPLE + PS> ./close-task-manager +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +tskill taskmgr +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-task-manager.ps1* diff --git a/Docs/close-three-d-viewer.md b/Docs/close-three-d-viewer.md index d71f9485..462030e5 100644 --- a/Docs/close-three-d-viewer.md +++ b/Docs/close-three-d-viewer.md @@ -1,4 +1,4 @@ -## close-three-d-viewer.ps1 - Closes the 3D-Viewer app +## The close-three-d-viewer.ps1 PowerShell Script This PowerShell script closes the 3D-Viewer application gracefully. @@ -23,4 +23,25 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the 3D-Viewer app +.DESCRIPTION + This PowerShell script closes the 3D-Viewer application gracefully. +.EXAMPLE + PS> ./close-three-d-viewer +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +TaskKill /im 3DViewer.exe /f +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/give-reply.ps1" "Sorry, 3D Viewer isn't running." + exit 1 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-three-d-viewer.ps1* diff --git a/Docs/close-thunderbird.md b/Docs/close-thunderbird.md index 6c001d22..edb4fc7c 100644 --- a/Docs/close-thunderbird.md +++ b/Docs/close-thunderbird.md @@ -1,4 +1,4 @@ -## close-thunderbird.ps1 - Closes the Thunderbird app +## The close-thunderbird.ps1 PowerShell Script This PowerShell script closes the Mozilla Thunderbird email application gracefully. @@ -23,4 +23,25 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Thunderbird app +.DESCRIPTION + This PowerShell script closes the Mozilla Thunderbird email application gracefully. +.EXAMPLE + PS> ./close-thunderbird +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +TaskKill /im thunderbird.exe +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/give-reply.ps1" "Sorry, Mozilla Thunderbird isn't running." + exit 1 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-thunderbird.ps1* diff --git a/Docs/close-visual-studio.md b/Docs/close-visual-studio.md index 0b9b9edc..9d4da3ff 100644 --- a/Docs/close-visual-studio.md +++ b/Docs/close-visual-studio.md @@ -1,4 +1,4 @@ -## close-visual-studio.ps1 - Closes the Visual Studio app +## The close-visual-studio.ps1 PowerShell Script This PowerShell script closes the Microsoft Visual Studio application gracefully. @@ -23,4 +23,25 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Visual Studio app +.DESCRIPTION + This PowerShell script closes the Microsoft Visual Studio application gracefully. +.EXAMPLE + PS> ./close-visual-studio +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +TaskKill /im devenv.exe +if ($lastExitCode -ne "0") { + & "$PSScriptRoot/give-reply.ps1" "Sorry, Visual Studio isn't running." + exit 1 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-visual-studio.ps1* diff --git a/Docs/close-vlc.md b/Docs/close-vlc.md index dd984a2c..853f5876 100644 --- a/Docs/close-vlc.md +++ b/Docs/close-vlc.md @@ -1,4 +1,4 @@ -## close-vlc.ps1 - Closes the VLC media player application +## The close-vlc.ps1 PowerShell Script This PowerShell script closes the VLC media player application gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the VLC media player application +.DESCRIPTION + This PowerShell script closes the VLC media player application gracefully. +.EXAMPLE + PS> ./close-vlc +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/close-program.ps1" "VLC media player" "vlc" "vlc" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-vlc.ps1* diff --git a/Docs/close-windows-terminal.md b/Docs/close-windows-terminal.md index b42b24eb..d857c7c0 100644 --- a/Docs/close-windows-terminal.md +++ b/Docs/close-windows-terminal.md @@ -1,4 +1,4 @@ -## close-windows-terminal.ps1 - Closes the Windows Terminal app +## The close-windows-terminal.ps1 PowerShell Script This PowerShell script closes the Windows Terminal application gracefully. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Closes the Windows Terminal app +.DESCRIPTION + This PowerShell script closes the Windows Terminal application gracefully. +.EXAMPLE + PS> ./close-windows-terminal +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/close-program.ps1" "Windows Terminal" "WindowsTerminal" "WindowsTerminal" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of close-windows-terminal.ps1* diff --git a/Docs/configure-git.md b/Docs/configure-git.md index 09e5a26d..850d71dc 100644 --- a/Docs/configure-git.md +++ b/Docs/configure-git.md @@ -1,4 +1,4 @@ -## configure-git.ps1 - Configures Git +## The configure-git.ps1 PowerShell Script This PowerShell script configures the user settings for Git. @@ -50,4 +50,80 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Configures Git +.DESCRIPTION + This PowerShell script configures the user settings for Git. +.PARAMETER FullName + Specifies the user's full name +.PARAMETER EmailAddress + Specifies the user's email address +.PARAMETER FavoriteEditor + Specifies the user's favorite text editor +.EXAMPLE + PS> ./configure-git +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$FullName = "", [string]$EmailAddress = "", [string]$FavoriteEditor = "") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + Write-Host "โณ (1/6) Searching for Git executable... " -noNewline + & git --version + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + "โณ (2/6) Asking for details..." + 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 (atom,emacs,nano,subl,vi,vim,...)" } + + "โณ (3/6) Saving personal settings (name,email,editor)..." + & git config --global user.name $FullName + & git config --global user.email $EmailAddress + & git config --global core.editor $FavoriteEditor + if ($lastExitCode -ne "0") { throw "'git config' failed with exit code $lastExitCode" } + + "โณ (4/6) Saving basic settings (autocrlf,symlinks,longpaths,etc.)..." + & git config --global core.autocrlf false # don't change newlines + & git config --global core.symlinks true # enable support for symbolic link files + & git config --global core.longpaths true # enable support for long file paths + & git config --global http.sslVerify false + & git config --global init.defaultBranch main # set the default branch name to 'main' + & git config --global merge.renamelimit 99999 + & git config --global pull.rebase false + & git config --global fetch.parallel 0 # enable parallel fetching to improve the speed + if ($lastExitCode -ne "0") { throw "'git config' failed with exit code $lastExitCode" } + + "โณ (5/6) Saving shortcuts (git co, git br, etc.)..." + & git config --global alias.co "checkout" + & git config --global alias.br "branch" + & git config --global alias.ci "commit" + & git config --global alias.st "status" + & git config --global alias.pl "pull --recurse-submodules" + & git config --global alias.ps "push" + & git config --global alias.mrg "merge --no-commit --no-ff" + & git config --global alias.chp "cherry-pick --no-commit" + & git config --global alias.ls "log -n20 --pretty=format:'%Cred%h%Creset%C(yellow)%d%Creset %s %C(bold blue)by %an%Creset %C(green)%cr%Creset' --abbrev-commit" + & git config --global alias.smu "submodule update --init" + if ($lastExitCode -ne "0") { throw "'git config' failed" } + + "โณ (6/6) Listing your Git settings..." + & git config --list + if ($lastExitCode -ne "0") { throw "'git config --list' failed with exit code $lastExitCode" } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ configured Git in $Elapsed sec." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber)): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of configure-git.ps1* diff --git a/Docs/connect-vpn.md b/Docs/connect-vpn.md index baa8bf67..e8909897 100644 --- a/Docs/connect-vpn.md +++ b/Docs/connect-vpn.md @@ -1,4 +1,4 @@ -## connect-vpn.ps1 - Connects to the VPN +## The connect-vpn.ps1 PowerShell Script This PowerShell script tries to connect to the VPN. @@ -23,4 +23,35 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Connects to the VPN +.DESCRIPTION + This PowerShell script tries to connect to the VPN. +.EXAMPLE + PS> ./connect-vpn +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Connections = (Get-VPNConnection) + foreach($Connection in $Connections) { + if ($Connection.ConnectionStatus -eq "Connected") { throw "Already connected to VPN $($Connection.Name)" } + if ($Connection.ConnectionStatus -ne "Disconnected") { continue } + "Connecting to VPN $($Connection.Name)..." + & rasdial.exe "$($Connection.Name)" + if ($lastExitCode -ne "0") { throw "Cannot establish connection" } + "Connected now." + exit 0 # success + } + throw "No VPN connection available" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of connect-vpn.ps1* diff --git a/Docs/convert-csv2txt.md b/Docs/convert-csv2txt.md index 7aaecfda..46ff0834 100644 --- a/Docs/convert-csv2txt.md +++ b/Docs/convert-csv2txt.md @@ -1,4 +1,4 @@ -## convert-csv2txt.ps1 - Converts a .CSV file into a text file +## The convert-csv2txt.ps1 PowerShell Script This PowerShell script converts a .CSV file into a text file. @@ -32,4 +32,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Converts a .CSV file into a text file +.DESCRIPTION + This PowerShell script converts a .CSV file into a text file. +.PARAMETER Path + Specifies the path to the .CSV file +.EXAMPLE + PS> ./convert-csv2txt salaries.csv +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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) { + write-output "* $($Row.A) $($Row.B) $($Row.C) $($Row.D) $($Row.E) $($Row.F) $($Row.G) $($Row.H)" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of convert-csv2txt.ps1* diff --git a/Docs/convert-image2ascii.md b/Docs/convert-image2ascii.md index 5eebd243..3d881528 100644 --- a/Docs/convert-image2ascii.md +++ b/Docs/convert-image2ascii.md @@ -1,4 +1,6 @@ -## convert-image2ascii.ps1 - convert-image2ascii.ps1 +## The convert-image2ascii.ps1 PowerShell Script + +convert-image2ascii.ps1 ## Parameters @@ -10,4 +12,105 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# + .SYNOPSIS + Convert-ImageToAscii + .DESCRIPTION + Converts an image to ASCII art. + .EXAMPLE + Convert-ImageToAscii -InFile "C:\Folder\Image.jpg" -Width 32 -Height 32 + .INPUTS + .OUTPUTS + .NOTES + Author: Fxbyy + .FUNCTIONALITY + Converts an image to ASCII art. + #> + + function Convert-ImageToAscii { + [CmdletBinding(DefaultParameterSetName = 'AutoSize')] + param ( + [Parameter(Mandatory = $true)] + [string] $InFile, + + [Parameter(Mandatory = $false, ParameterSetName = 'CustomSize')] + [int] $Width, + + [Parameter(Mandatory = $false, ParameterSetName = 'CustomSize')] + [int] $Height, + + [Parameter(Mandatory = $false)] + [switch] $Invert + ) + + begin { + $tempFile = "$PSScriptRoot\temp.jpg" + [void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") + + $img = [System.Drawing.Image]::FromFile((Get-Item $InFile)) + + if ($PSCmdlet.ParameterSetName -eq 'AutoSize') { + [int]$Height = $Host.UI.RawUI.WindowSize.Height * ($img.Size.Width / $img.Size.Height) + [int]$Width = $Height * ($img.Size.Width / $img.Size.Height) + } else { + if ($null -eq $Height -or $Height -eq 0) { + [int]$Height = $Width * ($img.Size.Height / $img.Size.Width) + } elseif ($null -eq $Width -or $Width -eq 0) { + [int]$Width = $Height * ($img.Size.Width / $img.Size.Height) + } + } + } + + process { + $bmp = New-Object System.Drawing.Bitmap($Width, $Height) + + $graph = [System.Drawing.Graphics]::FromImage($bmp) + $graph.DrawImage($img, 0, 0, $Width, $Height) + + $graph.Dispose() + $img.Dispose() + + if ($Invert) { + $symbols = " .,:~+t?xmoX#M%@" + } else { + $symbols = "@%M#Xomx?t+~:,. " + } + $res = "" + + foreach ($h in 1..$bmp.Height) { + foreach ($w in 1..$bmp.Width) { + $px = $bmp.GetPixel($w - 1, $h - 1) + $brightness = (0.2126 * $px.R + 0.7152 * $px.G + 0.0722 * $px.B) + + if ($brightness -le 15) { $res += $symbols[0] + " " } + elseif ($brightness -le 31) { $res += $symbols[1] + " " } + elseif ($brightness -le 47) { $res += $symbols[2] + " " } + elseif ($brightness -le 63) { $res += $symbols[3] + " " } + elseif ($brightness -le 79) { $res += $symbols[4] + " " } + elseif ($brightness -le 95) { $res += $symbols[5] + " " } + elseif ($brightness -le 111) { $res += $symbols[6] + " " } + elseif ($brightness -le 127) { $res += $symbols[7] + " " } + elseif ($brightness -le 143) { $res += $symbols[8] + " " } + elseif ($brightness -le 159) { $res += $symbols[9] + " " } + elseif ($brightness -le 175) { $res += $symbols[10] + " " } + elseif ($brightness -le 191) { $res += $symbols[11] + " " } + elseif ($brightness -le 207) { $res += $symbols[12] + " " } + elseif ($brightness -le 223) { $res += $symbols[13] + " " } + elseif ($brightness -le 249) { $res += $symbols[14] + " " } + else { $res += $symbols[15] + " " } + + } + $res += "`n" + } + } + + end { + $BitMap.Dispose() + Remove-Item $tempFile -Force + + $res + } +} + *Generated by convert-ps2md.ps1 using the comment-based help of convert-image2ascii.ps1* diff --git a/Docs/convert-mysql2csv.md b/Docs/convert-mysql2csv.md index 832be8f8..d0eaeb02 100644 --- a/Docs/convert-mysql2csv.md +++ b/Docs/convert-mysql2csv.md @@ -1,4 +1,4 @@ -## convert-mysql2csv.ps1 - Convert a MySQL database table to a .CSV file +## The convert-mysql2csv.ps1 PowerShell Script This PowerShell script converts a MySQL database table to a .CSV file. @@ -68,4 +68,47 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Convert a MySQL database table to a .CSV file +.DESCRIPTION + This PowerShell script converts a MySQL database table to a .CSV file. +.PARAMETER server + Specifies the server's hostname or IP address +.PARAMETER database + Specifies the database name +.PARAMETER username + Specifies the user name +.PARAMETER password + Specifies the password +.PARAMETER query + Specifies the SQL query +.EXAMPLE + PS> ./convert-mysql2csv +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + + +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 + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of convert-mysql2csv.ps1* diff --git a/Docs/convert-ps2bat.md b/Docs/convert-ps2bat.md index 60976ec7..338fc4b5 100644 --- a/Docs/convert-ps2bat.md +++ b/Docs/convert-ps2bat.md @@ -1,4 +1,4 @@ -## convert-ps2bat.ps1 - Converts PowerShell scripts to batch files +## The convert-ps2bat.ps1 PowerShell Script This PowerShell script converts one or more PowerShell scripts to .bat batch files. @@ -32,4 +32,53 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Converts PowerShell scripts to batch files +.DESCRIPTION + This PowerShell script converts one or more PowerShell scripts to .bat batch files. +.PARAMETER Filepattern + Specifies the file pattern +.EXAMPLE + PS> ./convert-ps2bat *.ps1 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Filepattern = "") + +function Convert-PowerShellToBatch +{ + param + ( + [Parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName)] + [string] + [Alias("FullName")] + $Path + ) + + process + { + $encoded = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes((Get-Content -Path $Path -Raw -Encoding UTF8))) + $newPath = [Io.Path]::ChangeExtension($Path, ".bat") + "@echo off`npowershell.exe -NoExit -encodedCommand $encoded" | Set-Content -Path $newPath -Encoding Ascii + } +} + +try { + if ($Filepattern -eq "") { $Filepattern = read-host "Enter path to the PowerShell script(s)" } + + $Files = get-childItem -path "$Filepattern" + foreach ($File in $Files) { + Convert-PowerShellToBatch "$File" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of convert-ps2bat.ps1* diff --git a/Docs/convert-ps2md.md b/Docs/convert-ps2md.md index a70c7dc2..dc877f22 100644 --- a/Docs/convert-ps2md.md +++ b/Docs/convert-ps2md.md @@ -1,4 +1,4 @@ -## convert-ps2md.ps1 - Converts PowerShell script metadata to Markdown +## The convert-ps2md.ps1 PowerShell Script This PowerShell script converts the comment-based help of a PowerShell script to Markdown. @@ -32,4 +32,138 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Converts PowerShell script metadata to Markdown +.DESCRIPTION + This PowerShell script converts the comment-based help of a PowerShell script to Markdown. +.PARAMETER filename + Specifies the path to the PowerShell script +.EXAMPLE + PS> ./convert-ps2md myscript.ps1 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$filename = "") + +function EncodePartOfHtml { param([string]$Value) + ($Value -replace '<', '<') -replace '>', '>' +} + +function GetCode { param($Example) + $codeAndRemarks = (($Example | Out-String) -replace ($Example.title), '').Trim() -split "`r`n" + + $code = New-Object "System.Collections.Generic.List[string]" + for ($i = 0; $i -lt $codeAndRemarks.Length; $i++) { + if ($codeAndRemarks[$i] -eq 'DESCRIPTION' -and $codeAndRemarks[$i + 1] -eq '-----------') { break } + if ($codeAndRemarks[$i] -eq '' -and $codeAndRemarks[$i + 1] -eq '') { continue } + if (1 -le $i -and $i -le 2) { continue } + $codeAndRemarks[$i] = ($codeAndRemarks[$i] | Out-String) -replace "PS>","PS> " + $code.Add($codeAndRemarks[$i]) + } + + $code -join "`r`n" +} + +function GetRemark { param($Example) + $codeAndRemarks = (($Example | Out-String) -replace ($Example.title), '').Trim() -split "`r`n" + + $isSkipped = $false + $remark = New-Object "System.Collections.Generic.List[string]" + for ($i = 0; $i -lt $codeAndRemarks.Length; $i++) { + if (!$isSkipped -and $codeAndRemarks[$i - 2] -ne 'DESCRIPTION' -and $codeAndRemarks[$i - 1] -ne '-----------') { + continue + } + $isSkipped = $true + $remark.Add($codeAndRemarks[$i]) + } + + $remark -join "`r`n" +} + +try { + if ($filename -eq "") { $filename = read-host "Enter path to PowerShell script" } + $ScriptName = (Get-Item "$filename").Name + + $full = Get-Help $filename -Full + + "## The $ScriptName PowerShell Script" + + $Description = ($full.description | Out-String).Trim() + if ($Description -ne "") { + "" + "$Description" + } else { + "" + "$($full.Synopsis)" + } + "" + "## Parameters" + "``````powershell" + $Syntax = (($full.syntax | Out-String) -replace "`r`n", "`r`n").Trim() + $Syntax = (($Syntax | Out-String) -replace "/home/mf/PowerShell/Scripts/", "") + if ($Syntax -ne "") { + "$Syntax" + } + + foreach($parameter in $full.parameters.parameter) { + "$(((($parameter | Out-String).Trim() -split "`r`n")[-5..-1] | % { $_.Trim() }) -join "`r`n")" + "" + } + "[]" + " This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, " + " WarningVariable, OutBuffer, PipelineVariable, and OutVariable." + "``````" + + foreach($input in $full.inputTypes.inputType) { + "" + "## Inputs" + "$($input.type.name)" + } + + foreach($output in $full.outputTypes.outputType) { + "" + "## Outputs" + "$($output.type.name)" + } + + foreach($example in $full.examples.example) { + "" + "## Example" + "``````powershell" + "$(GetCode $example)" + "``````" + } + + $Notes = ($full.alertSet.alert | Out-String).Trim() + if ($Notes -ne "") { + "" + "## Notes" + "$Notes" + } + + $Links = ($full.relatedlinks | Out-String).Trim() + if ($Links -ne "") { + "" + "## Related Links" + "$Links" + } + + "" + "## Source Code" + $Lines = Get-Content -path "$filename" + foreach($Line in $Lines) { + "$Line" + } + "" + "*Generated by convert-ps2md.ps1 using the comment-based help of $ScriptName*" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of convert-ps2md.ps1* diff --git a/Docs/convert-sql2csv.md b/Docs/convert-sql2csv.md index aa3e3893..e928591c 100644 --- a/Docs/convert-sql2csv.md +++ b/Docs/convert-sql2csv.md @@ -1,4 +1,4 @@ -## convert-sql2csv.ps1 - Converts a SQL database table to a .CSV file +## The convert-sql2csv.ps1 PowerShell Script This PowerShell script converts a SQL database table to a .CSV file. @@ -68,4 +68,48 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Converts a SQL database table to a .CSV file +.DESCRIPTION + This PowerShell script converts a SQL database table to a .CSV file. +.PARAMETER server + Specifies the server's hostname or IP address +.PARAMETER database + Specifies the database name +.PARAMETER username + Specifies the user name +.PARAMETER password + Specifies the password +.PARAMETER query + Specifies the SQL query +.EXAMPLE + PS> ./convert-sql2csv +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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" + $result = Invoke-SqlServerQuery -Credential $creds -ConnectionTimeout 10000 -Database $database -Server $server -Sql $query -CommandTimeout 10000 + $result | Export-Csv $csvfilepath -NoTypeInformation + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of convert-sql2csv.ps1* diff --git a/Docs/convert-txt2wav.md b/Docs/convert-txt2wav.md index 103d249d..1c7fb6b7 100644 --- a/Docs/convert-txt2wav.md +++ b/Docs/convert-txt2wav.md @@ -1,4 +1,4 @@ -## convert-txt2wav.ps1 - Converts text to a .WAV audio file +## The convert-txt2wav.ps1 PowerShell Script This PowerShell script converts text to a .WAV audio file. @@ -41,4 +41,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Converts text to a .WAV audio file +.DESCRIPTION + This PowerShell script converts text to a .WAV audio file. +.PARAMETER text + Specifies the text to use +.PARAMETER WavFile + Specifies the path to the resulting WAV file +.EXAMPLE + PS> ./convert-txt2wav "Hello World" spoken.wav +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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) + $SpeechSynthesizer.Speak($Text) + $SpeechSynthesizer.Dispose() + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of convert-txt2wav.ps1* diff --git a/Docs/copy-photos-sorted.md b/Docs/copy-photos-sorted.md index 571c93cc..f4504357 100644 --- a/Docs/copy-photos-sorted.md +++ b/Docs/copy-photos-sorted.md @@ -1,4 +1,6 @@ -## copy-photos-sorted.ps1 - copy-photos-sorted.ps1 [[-SourceDir] ] [[-TargetDir] ] +## The copy-photos-sorted.ps1 PowerShell Script + +copy-photos-sorted.ps1 [[-SourceDir] ] [[-TargetDir] ] ## Parameters @@ -10,4 +12,88 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Copy photos sorted by year and month +.DESCRIPTION + This PowerShell script copies image files from SourceDir to TargetDir sorted by year and month. +.PARAMETER SourceDir + Specifies the path to the source folder +.PARAMTER TargetDir + Specifies the path to the target folder +.EXAMPLE + PS> ./copy-photos-sorted D:\MyPhone\DCIM C:\MyPhotos +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$SourceDir = "", [string]$TargetDir = "") + +function CopyFile { param([string]$SourcePath, [string]$TargetDir, [int]$Date, [string]$Filename) + [int]$Year = $Date / 10000 + [int]$Month = ($Date / 100) % 100 + $MonthDir = switch($Month) { + 1 {"01 JAN"} + 2 {"02 FEB"} + 3 {"03 MAR"} + 4 {"04 APR"} + 5 {"05 MAY"} + 6 {"06 JUN"} + 7 {"07 JUL"} + 8 {"08 AUG"} + 9 {"09 SEP"} + 10 {"10 OCT"} + 11 {"11 NOV"} + 12 {"12 DEC"} + } + $TargetPath = "$TargetDir/$Year/$MonthDir/$Filename" + if (test-path "$TargetPath" -pathType leaf) { + "โณ Skipping $($Filename): already existing..." + } else { + "โณ Copying $Filename to $Year/$MonthDir..." + new-item -path "$TargetDir" -name "$Year" -itemType "directory" -force | out-null + new-item -path "$TargetDir/$Year" -name "$MonthDir" -itemType "directory" -force | out-null + copy-item "$SourcePath" "$TargetPath" -force + } +} + +try { + if ($SourceDir -eq "") { $SourceDir = read-host "Enter path to source directory" } + if ($TargetDir -eq "") { $TargetDir = read-host "Enter path to target directory" } + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + $Files = (Get-ChildItem "$SourceDir\*.jpg" -attributes !Directory) + "Found $($Files.Count) photos in ๐Ÿ“‚$SourceDir..." + foreach ($File in $Files) { + $Filename = (Get-Item "$File").Name + if ("$Filename" -like "IMG_*_*.jpg") { + $Array = $Filename.split("_") + CopyFile "$File" "$TargetDir" $Array[1] "$Filename" + } elseif ("$Filename" -like "IMG-*-*.jpg") { + $Array = $Filename.split("-") + CopyFile "$File" "$TargetDir" $Array[1] "$Filename" + } elseif ("$Filename" -like "PANO_*_*.jpg") { + $Array = $Filename.split("_") + CopyFile "$File" "$TargetDir" $Array[1] "$Filename" + } elseif ("$Filename" -like "PANO-*-*.jpg") { + $Array = $Filename.split("-") + CopyFile "$File" "$TargetDir" $Array[1] "$Filename" + } elseif ("$Filename" -like "SAVE_*_*.jpg") { + $Array = $Filename.split("_") + CopyFile "$File" "$TargetDir" $Array[1] "$Filename" + } else { + "โณ Skipping $($Filename): unknown filename format..." + } + } + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ $($Files.Count) photos copied from ๐Ÿ“‚$SourceDir to ๐Ÿ“‚$TargetDir in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of copy-photos-sorted.ps1* diff --git a/Docs/count-lines-of-code.md b/Docs/count-lines-of-code.md index ecdca92c..613c251c 100644 --- a/Docs/count-lines-of-code.md +++ b/Docs/count-lines-of-code.md @@ -1,4 +1,4 @@ -## count-lines-of-code.ps1 - Counts lines of code +## The count-lines-of-code.ps1 PowerShell Script This PowerShell script counts the number of code lines in a folder (including subfolders). @@ -34,4 +34,47 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Counts lines of code +.DESCRIPTION + This PowerShell script counts the number of code lines in a folder (including subfolders). +.PARAMETER Folder + Specifies the path to the folder +.EXAMPLE + PS> ./count-lines-of-code . + โณ Counting lines at ๐Ÿ“‚C:\PowerShell\Scripts ... + โœ”๏ธ ๐Ÿ“‚Scripts contains 15287 lines of code in 485 files (took 1 sec) +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Folder = "") + +try { + if ($Folder -eq "" ) { $Folder = read-host "Enter the path to the folder" } + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + $Folder = Resolve-Path "$Folder" + "โณ Counting lines at ๐Ÿ“‚$Folder ..." + + [int]$Files = [int]$CodeLines = 0 + Get-ChildItem -Path $Folder -Include *.c,*.h,*.cpp,*.hpp,*.java,*.ps1 -Recurse | ForEach-Object { + $FileStats = Get-Content $_.FullName | Measure-Object -line + $CodeLines += $FileStats.Lines + $Files++ + } + + $FolderName = (Get-Item "$Folder").Name + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ ๐Ÿ“‚$FolderName contains $CodeLines lines of code in $Files files (took $Elapsed sec)" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of count-lines-of-code.ps1* diff --git a/Docs/decrypt-file.md b/Docs/decrypt-file.md index dadf1fc1..a5f0e222 100644 --- a/Docs/decrypt-file.md +++ b/Docs/decrypt-file.md @@ -1,4 +1,4 @@ -## decrypt-file.ps1 - Decrypts a file +## The decrypt-file.ps1 PowerShell Script This PowerShell script decrypts a file using the given password and AES encryption. @@ -41,4 +41,152 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Decrypts a file +.DESCRIPTION + This PowerShell script decrypts a file using the given password and AES encryption. +.PARAMETER Path + Specifies the path to the file to decrypt +.PARAMETER Password + Specifies the password +.EXAMPLE + PS> ./decrypt-file-rules C:\MyFile.txt "123" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Path = "", [string]$Password = "") + + +function DecryptFile { +[CmdletBinding(DefaultParameterSetName='SecureString')] +[OutputType([System.IO.FileInfo[]])] +Param( + [Parameter(Mandatory=$true, Position=1, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] + [Alias('PSPath','LiteralPath')] + [string[]]$FileName, + [Parameter(Mandatory=$false, Position=2, ValueFromPipelineByPropertyName=$true)] + [ValidateSet('AES','DES','RC2','Rijndael','TripleDES')] + [String]$Algorithm = 'AES', + [Parameter(Mandatory=$true, Position=3, ValueFromPipelineByPropertyName=$true, ParameterSetName='SecureString')] + [System.Security.SecureString]$Key, + [Parameter(Mandatory=$true, Position=3, ParameterSetName='PlainText')] + [String]$KeyAsPlainText, + [Parameter(Mandatory=$false, Position=4, ValueFromPipelineByPropertyName=$true)] + [System.Security.Cryptography.CipherMode]$CipherMode = 'CBC', + [Parameter(Mandatory=$false, Position=5, ValueFromPipelineByPropertyName=$true)] + [System.Security.Cryptography.PaddingMode]$PaddingMode = 'PKCS7', + [Parameter(Mandatory=$false, Position=6)] + [String]$Suffix, + [Parameter()] + [Switch]$RemoveSource +) + Process + { + try + { + if($PSCmdlet.ParameterSetName -eq 'PlainText') + { + $Key = $KeyAsPlainText | ConvertTo-SecureString -AsPlainText -Force + } + + $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Key) + $EncryptionKey = [System.Convert]::FromBase64String([System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)) + + $Crypto = [System.Security.Cryptography.SymmetricAlgorithm]::Create($Algorithm) + $Crypto.Mode = $CipherMode + $Crypto.Padding = $PaddingMode + $Crypto.KeySize = $EncryptionKey.Length*8 + $Crypto.Key = $EncryptionKey + } + Catch + { + Write-Error $_ -ErrorAction Stop + } + + if(-not $PSBoundParameters.ContainsKey('Suffix')) + { + $Suffix = ".$Algorithm" + } + + $Files = Get-Item -LiteralPath $FileName + + ForEach($File in $Files) + { + If(-not $File.Name.EndsWith($Suffix)) + { + Write-Error "$($File.FullName) does not have an extension of '$Suffix'." + Continue + } + + $DestinationFile = $File.FullName -replace "$Suffix$" + + Try + { + $FileStreamReader = New-Object System.IO.FileStream($File.FullName, [System.IO.FileMode]::Open) + $FileStreamWriter = New-Object System.IO.FileStream($DestinationFile, [System.IO.FileMode]::Create) + + [Byte[]]$LenIV = New-Object Byte[] 4 + $FileStreamReader.Seek(0, [System.IO.SeekOrigin]::Begin) | Out-Null + $FileStreamReader.Read($LenIV, 0, 3) | Out-Null + [Int]$LIV = [System.BitConverter]::ToInt32($LenIV, 0) + [Byte[]]$IV = New-Object Byte[] $LIV + $FileStreamReader.Seek(4, [System.IO.SeekOrigin]::Begin) | Out-Null + $FileStreamReader.Read($IV, 0, $LIV) | Out-Null + $Crypto.IV = $IV + + $Transform = $Crypto.CreateDecryptor() + $CryptoStream = New-Object System.Security.Cryptography.CryptoStream($FileStreamWriter, $Transform, [System.Security.Cryptography.CryptoStreamMode]::Write) + $FileStreamReader.CopyTo($CryptoStream) + + $CryptoStream.FlushFinalBlock() + $CryptoStream.Close() + $FileStreamReader.Close() + $FileStreamWriter.Close() + + if($RemoveSource){Remove-Item $File.FullName} + + Get-Item $DestinationFile | Add-Member โ€“MemberType NoteProperty โ€“Name SourceFile โ€“Value $File.FullName -PassThru + } + Catch + { + Write-Error $_ + If($FileStreamWriter) + { + $FileStreamWriter.Close() + Remove-Item -LiteralPath $DestinationFile -Force + } + Continue + } + Finally + { + if($CryptoStream){$CryptoStream.Close()} + if($FileStreamReader){$FileStreamReader.Close()} + if($FileStreamWriter){$FileStreamWriter.Close()} + } + } + } +} + + +try { + if ($Path -eq "" ) { $Path = read-host "Enter path to file" } + if ($Password -eq "" ) { $Password = read-host "Enter password" } + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + $PasswordBase64 = [System.Convert]::ToBase64String($Password) + DecryptFile "$Path" -Algorithm AES -KeyAsPlainText $PasswordBase64 -RemoveSource + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ file decrypted in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of decrypt-file.ps1* diff --git a/Docs/disconnect-vpn.md b/Docs/disconnect-vpn.md index 6f23a4a2..a7ac741e 100644 --- a/Docs/disconnect-vpn.md +++ b/Docs/disconnect-vpn.md @@ -1,4 +1,4 @@ -## disconnect-vpn.ps1 - Disconnects the VPN +## The disconnect-vpn.ps1 PowerShell Script This PowerShell script disconnects the active VPN connection. @@ -23,4 +23,34 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Disconnects the VPN +.DESCRIPTION + This PowerShell script disconnects the active VPN connection. +.EXAMPLE + PS> ./disconnect-vpn +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Connections = (Get-VPNConnection) + foreach($Connection in $Connections) { + if ($Connection.ConnectionStatus -ne "Connected") { continue } + "Disconnecting $($Connection.Name)..." + & rasdial.exe "$($Connection.Name)" /DISCONNECT + if ($lastExitCode -ne "0") { throw "Disconnect failed with exit code $lastExitCode" } + "Disconnected now." + exit 0 # success + } + throw "No VPN connection found." +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of disconnect-vpn.ps1* diff --git a/Docs/display-time.md b/Docs/display-time.md index 22a24312..88a3998e 100644 --- a/Docs/display-time.md +++ b/Docs/display-time.md @@ -1,4 +1,4 @@ -## display-time.ps1 - Displays the current time +## The display-time.ps1 PowerShell Script This PowerShell script displays the current time (for 10 seconds by default) @@ -32,4 +32,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Displays the current time +.DESCRIPTION + This PowerShell script displays the current time (for 10 seconds by default) +.PARAMETER Seconds + Specifies the number of seconds to display the time +.EXAMPLE + PS> ./display-time +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([int]$Seconds = 10) + +try { + for ([int]$i = 0; $i -lt $Seconds; $i++) { + clear-host + write-output "" + $CurrentTime = Get-Date -format "yyyy-MM-dd HH:mm:ss" + ./write-big $CurrentTime + write-output "" + start-sleep -s 1 + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of display-time.ps1* diff --git a/Docs/download-dir.md b/Docs/download-dir.md index 2236a7cf..eaab65f1 100644 --- a/Docs/download-dir.md +++ b/Docs/download-dir.md @@ -1,4 +1,4 @@ -## download-dir.ps1 - Downloads a folder (including subfolders) from an URL +## The download-dir.ps1 PowerShell Script This PowerShell script downloads a folder (including subfolders) from the given URL. @@ -32,4 +32,41 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Downloads a folder (including subfolders) from an URL +.DESCRIPTION + This PowerShell script downloads a folder (including subfolders) from the given URL. +.PARAMETER URL + Specifies the URL where to download from +.EXAMPLE + PS> ./download-dir https://www.cnn.com +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$URL = "") + +try { + if ($URL -eq "") { $URL = read-host "Enter directory URL to download" } + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + & wget --version + if ($lastExitCode -ne "0") { throw "Can't execute 'wget' - make sure wget is installed and available" } + + & wget --mirror --convert-links --adjust-extension --page-requisites --no-parent $URL --directory-prefix . --no-verbose + if ($lastExitCode -ne "0") { throw "Can't execute 'wget --mirror $URL'" } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ downloaded directory from $URL in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of download-dir.ps1* diff --git a/Docs/download-file.md b/Docs/download-file.md index 15cffc3f..ca786310 100644 --- a/Docs/download-file.md +++ b/Docs/download-file.md @@ -1,4 +1,4 @@ -## download-file.ps1 - Downloads a file from an URL +## The download-file.ps1 PowerShell Script This PowerShell script downloads a file from the given URL @@ -32,4 +32,41 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Downloads a file from an URL +.DESCRIPTION + This PowerShell script downloads a file from the given URL +.PARAMETER URL + Specifies the URL where to download from +.EXAMPLE + PS> ./download-file https://www.cnn.com/index.html +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$URL = "") + +try { + if ($URL -eq "") { $URL = read-host "Enter file URL to download" } + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + & wget --version + if ($lastExitCode -ne "0") { throw "Can't execute 'wget' - make sure wget is installed and available" } + + & wget --mirror --convert-links --adjust-extension --page-requisites --no-parent $URL --directory-prefix . --no-verbose + if ($lastExitCode -ne "0") { throw "Can't execute 'wget --mirror $URL'" } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ downloaded file from $URL in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of download-file.ps1* diff --git a/Docs/edit.md b/Docs/edit.md index e7977b75..bb58f834 100644 --- a/Docs/edit.md +++ b/Docs/edit.md @@ -1,4 +1,4 @@ -## edit.ps1 - Opens an editor to edit a file +## The edit.ps1 PowerShell Script This PowerShell script opens a text editor to edit the given file. @@ -32,4 +32,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens an editor to edit a file +.DESCRIPTION + This PowerShell script opens a text editor to edit the given file. +.PARAMETER Filename + Specifies the path to the filename +.EXAMPLE + PS> ./edit C:\MyFile.txt +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Filename = "") + +try { + if ($IsLinux) { + & vi "$Filename" + if ($lastExitCode -ne "0") { throw "Can't execute 'vi' - make sure vi is installed and available" } + } else { + & notepad.exe "$Filename" + if ($lastExitCode -ne "0") { throw "Can't execute 'notepad.exe' - make sure notepad.exe is installed and available" } + } + + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of edit.ps1* diff --git a/Docs/enable-crash-dumps.md b/Docs/enable-crash-dumps.md index 7b32c648..8f72f64e 100644 --- a/Docs/enable-crash-dumps.md +++ b/Docs/enable-crash-dumps.md @@ -1,4 +1,4 @@ -## enable-crash-dumps.ps1 - Enables the writing of crash dumps +## The enable-crash-dumps.ps1 PowerShell Script This PowerShell script enables the writing of crash dumps. @@ -23,4 +23,303 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Enables the writing of crash dumps +.DESCRIPTION + This PowerShell script enables the writing of crash dumps. +.EXAMPLE + PS> ./enable-crash-dumps +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +################################################################## +# # +# Written by: Ryan Waters # +# # +# Program: Get-Dump.ps1 # +# Date: 2-06-2020 # +# Purpose: To set registry keys to gather a WER Usermode Dump # +# and be able to change from a custom, mini, or FULL # +# Dumps for ease of use for customers and others. # +# # +# EULA: Code is free to use for all, and free to distribute # +# I just ask that you leave the credit information and # +# this EULA and Comment Section in tact and do not delete. # +# # +# Bitwise Values: (For reference) # +# # +# 0x00000000 - MiniDumpNormal # +# 0x00000001 - MiniDumpWithDataSegs # +# 0x00000002 - MiniDumpWithFullMemory # +# 0x00000004 - MiniDumpWithHandleData # +# 0x00000008 - MiniDumpFilterMemory # +# 0x00000010 - MiniDumpScanMemory # +# 0x00000020 - MiniDumpWithUnloadedModules # +# 0x00000040 - MiniDumpWithIndirectlyReferenced # +# 0x00000080 - MemoryMiniDumpFilterModulePaths # +# 0x00000100 - MiniDumpWithProcessThreadData # +# 0x00000200 - MiniDumpWithPrivateReadWriteMemory # +# 0x00000400 - MiniDumpWithoutOptionalData # +# 0x00000800 - MiniDumpWithFullMemoryInfo # +# 0x00001000 - MiniDumpWithThreadInfo # +# 0x00002000 - MiniDumpWithCodeSegs # +# 0x00004000 - MiniDumpWithoutAuxiliaryState # +# 0x00008000 - MiniDumpWithFullAuxiliaryState # +# 0x00010000 - MiniDumpWithPrivateWriteCopyMemory # +# 0x00020000 - MiniDumpIgnoreInaccessibleMemory # +# 0x00040000 - MiniDumpWithTokenInformation # +# # +################################################################## + +#Setting Values: +$MDN = '0' +$MDWDS = '1' +$MDWFM = '2' +$MDWHD = '4' +$MDFM = '8' +$MDSM = '10' +$MDWUM = '20' +$MDWIR = '40' +$MMDFMP = '80' +$MDWPTD = '100' +$MDWPRWM = '200' +$MDWOD = '400' +$MDWFMI = '800' +$MDWTI = '1000' +$MDWCS = '2000' +$MDWAS = '4000' +$MDWFAS = '8000' +$MDWPWCM = '10000' +$MDIIM = '20000' +$MDWTOI = '40000' + +$a = $MDN +$b = $MDWDS +$c = $MDWFM +$d = $MDWHD +$e = $MDFM +$f = $MDSM +$g = $MDWUM +$h = $MDWIR +$i = $MMDFMP +$j = $MDWPTD +$k = $MDWPRWM +$l = $MDWOD +$m = $MDWFMI +$n = $MDWTI +$o = $MDWCS +$p = $MDWAS +$q = $MDWFAS +$r = $MDWPWCM +$s = $MDIIM +$t = $MDWTOI + +$0x = "0x" + +$array = @() + +Clear-host +write-host "Setting up your machine to receive Usermode Dumps via WER." +Start-sleep -s 3 + + +New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Value "%LOCALAPPDATA%\CrashDumps" -PropertyType ExpandString -Force +New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpCount" -Value "10" -PropertyType DWORD -Force + +clear-host +write-host "What would you like to do?" +write-host "(0) Disable Dumps and restore system to factory." +write-host "(1) Enable System for Full Dumps." +write-host "(2) Enable System for Mini Dumps." +write-host "(3) Enable System for custom dump with options." +$NCD = Read-Host "Enter a number option" + +If ($NCD -eq '3') +{ + + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value "0" -PropertyType DWORD -Force + Do + { + clear-host + write-host "Here are the optional custom dump to add to your custom dump parameters:" + write-host "(1) Mini Dump Normal" + write-host "(2) Mini Dump With Data Segs" + write-host "(3) Mini Dump With Full Memory" + write-host "(4) Mini Dump With Handle Data" + write-host "(5) Mini Dump Filter Memory" + write-host "(6) Mini Dump Scan Memory" + write-host "(7) Mini Dump With Unloaded Modules" + write-host "(8) Mini Dump With Indirectly Referenced" + write-host "(9) Memory Mini Dump Filter Module Paths" + write-host "(10) Mini Dump With Process Thread Data" + write-host "(11) Mini Dump With Private Read Write Memory" + write-host "(12) Mini Dump Without Optional Data" + write-host "(13) Mini Dump With Full Memory Info" + write-host "(14) Mini Dump With Thread Info" + write-host "(15) Mini Dump With Code Segs" + write-host "(16) Mini Dump Without Auxiliary State" + write-host "(17) Mini Dump With Full Auxiliary State" + write-host "(18) Mini Dump With Private Write Copy Memory" + write-host "(19) Mini Dump Ignore Inaccessible Memory" + write-host "(20) Mini Dump With Token Information" + $Option = Read-Host "Enter one number value at a time and press enter. (Press 'q' when finished)" + if($Option -eq '1') + { + $array += [int]$a + } + ElseIf($Option -eq '2') + { + $array += [int]$b + } + ElseIf($Option -eq '3') + { + $array += [int]$c + } + ElseIf($Option -eq '4') + { + $array += [int]$d + } + ElseIf($Option -eq '5') + { + $array += [int]$e + } + ElseIf($Option -eq '6') + { + $array += [int]$f + } + ElseIf($Option -eq '7') + { + $array += [int]$g + } + ElseIf($Option -eq '8') + { + $array += [int]$h + } + ElseIf($Option -eq '9') + { + $array += [int]$i + } + ElseIf($Option -eq '10') + { + $array += [int]$j + } + ElseIf($Option -eq '11') + { + $array += [int]$k + } + ElseIf($Option -eq '12') + { + $array += [int]$l + } + ElseIf($Option -eq '13') + { + $array += [int]$m + } + ElseIf($Option -eq '14') + { + $array += [int]$n + } + ElseIf($Option -eq '15') + { + $array += [int]$o + } + ElseIf($Option -eq '16') + { + $array += [int]$p + } + ElseIf($Option -eq '17') + { + $array += [int]$q + } + ElseIf($Option -eq '18') + { + $array += [int]$r + } + ElseIf($Option -eq '19') + { + $array += [int]$s + } + ElseIf($Option -eq '20') + { + $array += [int]$t + } + ElseIf($Option -eq 'q') + { + write-host "Closing application." + Start-Sleep -s 2 + } + Else + { + write-host "Invalid Option, Try again." + Start-sleep -s 2 + } + + } + While($Option -ne "q") + $sum = $array -join '+' + $SumArray = Invoke-Expression $sum + $FinalSum = $0x + $SumArray + + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "CustomDumpFlags" -Value "$FinalSum" -PropertyType DWORD -Force + + write-host " " + write-host "Setting up the system for crash dumps requires a reboot" +} +ElseIf ($NCD -eq '0') +{ + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpCount" -Force -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Force -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpFolder" -Force -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "CustomDumpFlags" -Force -ErrorAction SilentlyContinue + write-host " " + $reboot = read-host "Registry reset to factory settings and cleared. It is recommended to restart your machine, would you like to now?" + if($reboot -eq "Yes" -or $reboot -eq "Y" -or $reboot -eq "yes" -or $reboot -eq "y") + { + shutdown -r + } + Else + { + write-host "Please restart the machine for settings to take effect at your convenience." + } +} +ElseIf ($NCD -eq '1') +{ + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value "2" -PropertyType DWORD -Force + write-host "The computer has been set up to create a Full Sized Dump and will be located in %LOCALAPPDATA%\CrashDumps." + write-host "The computer must also restart for settings to take effect. Would you like to now? (Y/n)" + if($reboot -eq "Yes" -or $reboot -eq "Y" -or $reboot -eq "yes" -or $reboot -eq "y") + { + shutdown -r + } + Else + { + write-host "Please restart the machine for settings to take effect at your convenience." + } +} +ElseIf ($NCD -eq '2') +{ + New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" -Name "DumpType" -Value "1" -PropertyType DWORD -Force + write-host "The computer has been set up to create a Mini Dump and will be located in %LOCALAPPDATA%\CrashDumps." + write-host "The computer must also restart for settings to take effect. Would you like to now? (Y/n)" + if($reboot -eq "Yes" -or $reboot -eq "Y" -or $reboot -eq "yes" -or $reboot -eq "y") + { + shutdown -r + } + Else + { + write-host "Please restart the machine for settings to take effect at your convenience." + } +} +Else +{ + write-host "You did not enter a valid option. Please re-run Get-Dump.ps1" + start-sleep -s 5 +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of enable-crash-dumps.ps1* diff --git a/Docs/enable-god-mode.md b/Docs/enable-god-mode.md index c8dcf706..f7109f73 100644 --- a/Docs/enable-god-mode.md +++ b/Docs/enable-god-mode.md @@ -1,4 +1,4 @@ -## enable-god-mode.ps1 - Enables the god mode +## The enable-god-mode.ps1 PowerShell Script This PowerShell script enables the god mode. It adds a new icon to the desktop. @@ -23,4 +23,33 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Enables the god mode +.DESCRIPTION + This PowerShell script enables the god mode. It adds a new icon to the desktop. +.EXAMPLE + PS> ./enable-god-mode +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $GodModeSplat = @{ + Path = "$HOME\Desktop" + Name = "GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}" + ItemType = 'Directory' + } + $null = new-item @GodModeSplat + + "โœ”๏ธ enabled god mode - see the new desktop icon" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of enable-god-mode.ps1* diff --git a/Docs/encrypt-file.md b/Docs/encrypt-file.md index 1ad9587e..d139498d 100644 --- a/Docs/encrypt-file.md +++ b/Docs/encrypt-file.md @@ -1,4 +1,4 @@ -## encrypt-file.ps1 - Encrypts a file +## The encrypt-file.ps1 PowerShell Script This PowerShell script encrypts a file using the given password and AES encryption. @@ -41,4 +41,136 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Encrypts a file +.DESCRIPTION + This PowerShell script encrypts a file using the given password and AES encryption. +.PARAMETER Path + Specifies the path to the file to encrypt +.PARAMETER Password + Specifies the password to use +.EXAMPLE + PS> ./encrypt-file C:\MyFile.txt "123" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Path = "", [string]$Password = "") + +function EncryptFile { +[CmdletBinding(DefaultParameterSetName='SecureString')] +[OutputType([System.IO.FileInfo[]])] +Param( + [Parameter(Mandatory=$true, Position=1, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] + [Alias('PSPath','LiteralPath')] + [string[]]$FileName, + [Parameter(Mandatory=$false, Position=2)] + [ValidateSet('AES','DES','RC2','Rijndael','TripleDES')] + [String]$Algorithm = 'AES', + [Parameter(Mandatory=$false, Position=3, ParameterSetName='SecureString')] + [System.Security.SecureString]$Key = (New-CryptographyKey -Algorithm $Algorithm), + [Parameter(Mandatory=$true, Position=3, ParameterSetName='PlainText')] + [String]$KeyAsPlainText, + [Parameter(Mandatory=$false, Position=4)] + [System.Security.Cryptography.CipherMode]$CipherMode, + [Parameter(Mandatory=$false, Position=5)] + [System.Security.Cryptography.PaddingMode]$PaddingMode, + [Parameter(Mandatory=$false, Position=6)] + [String]$Suffix = ".$Algorithm", + [Parameter()] + [Switch]$RemoveSource +) + begin { + try { + if ($PSCmdlet.ParameterSetName -eq 'PlainText') { + $Key = $KeyAsPlainText | ConvertTo-SecureString -AsPlainText -Force + } + + $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Key) + $EncryptionKey = [System.Convert]::FromBase64String([System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)) + + $Crypto = [System.Security.Cryptography.SymmetricAlgorithm]::Create($Algorithm) + if ($PSBoundParameters.ContainsKey('CipherMode')) { + $Crypto.Mode = $CipherMode + } + if ($PSBoundParameters.ContainsKey('PaddingMode')) { + $Crypto.Padding = $PaddingMode + } + $Crypto.KeySize = $EncryptionKey.Length*8 + $Crypto.Key = $EncryptionKey + } catch { + Write-Error $_ -ErrorAction Stop + } + } + process { + $Files = Get-Item -LiteralPath $FileName + + foreach($File in $Files) { + $DestinationFile = $File.FullName + $Suffix + + try { + $FileStreamReader = New-Object System.IO.FileStream($File.FullName, [System.IO.FileMode]::Open) + $FileStreamWriter = New-Object System.IO.FileStream($DestinationFile, [System.IO.FileMode]::Create) + + $Crypto.GenerateIV() + $FileStreamWriter.Write([System.BitConverter]::GetBytes($Crypto.IV.Length), 0, 4) + $FileStreamWriter.Write($Crypto.IV, 0, $Crypto.IV.Length) + + $Transform = $Crypto.CreateEncryptor() + $CryptoStream = New-Object System.Security.Cryptography.CryptoStream($FileStreamWriter, $Transform, [System.Security.Cryptography.CryptoStreamMode]::Write) + $FileStreamReader.CopyTo($CryptoStream) + + $CryptoStream.FlushFinalBlock() + $CryptoStream.Close() + $FileStreamReader.Close() + $FileStreamWriter.Close() + + if ($RemoveSource) { + Remove-Item -LiteralPath $File.FullName + } + + $result = Get-Item $DestinationFile + $result | Add-Member โ€“MemberType NoteProperty โ€“Name SourceFile โ€“Value $File.FullName + $result | Add-Member โ€“MemberType NoteProperty โ€“Name Algorithm โ€“Value $Algorithm + $result | Add-Member โ€“MemberType NoteProperty โ€“Name Key โ€“Value $Key + $result | Add-Member โ€“MemberType NoteProperty โ€“Name CipherMode โ€“Value $Crypto.Mode + $result | Add-Member โ€“MemberType NoteProperty โ€“Name PaddingMode โ€“Value $Crypto.Padding + $result + } catch { + Write-Error $_ + if ($FileStreamWriter) { + $FileStreamWriter.Close() + Remove-Item -LiteralPath $DestinationFile -Force + } + continue + } finally { + if($CryptoStream){$CryptoStream.Close()} + if($FileStreamReader){$FileStreamReader.Close()} + if($FileStreamWriter){$FileStreamWriter.Close()} + } + } + } +} + + +try { + if ($Path -eq "" ) { $Path = read-host "Enter path to file" } + if ($Password -eq "" ) { $Password = read-host "Enter password" } + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + $PasswordBase64 = [System.Convert]::ToBase64String($Password) + EncryptFile "$Path" -Algorithm AES -KeyAsPlainText $PasswordBase64 -RemoveSource + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ file encrypted in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of encrypt-file.ps1* diff --git a/Docs/enter-chat.md b/Docs/enter-chat.md index 39914331..80a7dd3f 100644 --- a/Docs/enter-chat.md +++ b/Docs/enter-chat.md @@ -1,4 +1,4 @@ -## enter-chat.ps1 - Enters a chat using a common network shared file +## The enter-chat.ps1 PowerShell Script This PowerShell script enters a chat using a common network shared file. @@ -23,4 +23,98 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Enters a chat using a common network shared file +.DESCRIPTION + This PowerShell script enters a chat using a common network shared file. +.EXAMPLE + PS> ./enter-chat +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +# make sure you adjust this path +# it must point to a network share where you have read and write permissions +$ServerShare = "\\myserver\chathome" + +function Enter-Chat +{ + param + ( + [Parameter(Mandatory)] + [string] + $ChatChannelName, + + [string] + $Name = $env:USERNAME, + + [Switch] + $ShowOldPosts, + + $HomeShare = $ServerShare + + ) + + if ($ShowOldPosts) + { + $Option = '' + } + else + { + $Option = '-Tail 0' + } + + $Path = Join-Path -Path $HomeShare -ChildPath "$ChatChannelName.txt" + $exists = Test-Path -Path $Path + if ($exists -eq $false) + { + $null = New-Item -Path $Path -Force -ItemType File + } + + $process = Start-Process -FilePath powershell -ArgumentList "-noprofile -windowstyle hidden -command Get-COntent -Path '$Path' $Option -Wait | Out-GridView -Title 'Chat: [$ChatChannelName]'" -PassThru + + Write-Host "To exit, enter: quit" + "[$Name entered the chat]" | Add-Content -Path $Path + do + { + Write-Host "[$ChatChannelName]: " -ForegroundColor Green -NoNewline + $inputText = Read-Host + + $isStopCommand = 'quit','exit','stop','leave' -contains $inputText + if ($isStopCommand -eq $false) + { + "[$Name] $inputText" | Add-Content -Path $Path + } + + + } until ($isStopCommand -eq $true) + "[$Name left the chat]" | Add-Content -Path $Path + + $process | Stop-Process +} + + + +function Get-ChatChannel +{ + param + ( + $HomeShare = $ServerShare + + ) + + Get-ChildItem -Path $HomeShare -Filter *.txt -File | + ForEach-Object { + [PSCustomObject]@{ + ChannelName = [System.IO.Path]::GetFileNameWithoutExtension($_.Name) + LastActive = $_.LastWriteTime + Started = $_.CreationTime + } + } +} + *Generated by convert-ps2md.ps1 using the comment-based help of enter-chat.ps1* diff --git a/Docs/export-to-manuals.md b/Docs/export-to-manuals.md index 047e73fe..40c90e86 100644 --- a/Docs/export-to-manuals.md +++ b/Docs/export-to-manuals.md @@ -1,4 +1,4 @@ -## export-to-manuals.ps1 - Exports all scripts as manuals +## The export-to-manuals.ps1 PowerShell Script This PowerShell script exports the comment based help of all PowerShell scripts as manuals. @@ -41,4 +41,42 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Exports all scripts as manuals +.DESCRIPTION + This PowerShell script exports the comment based help of all PowerShell scripts as manuals. +.EXAMPLE + PS> ./export-to-manuals.ps1 + Found 264 scripts, exporting them to /home/markus/PowerShell/Docs... + โœ”๏ธ exported 264 PowerShell scripts in 28 sec +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#requires -version 2 + +param([string]$FilePattern = "$PSScriptRoot/*.ps1", [string]$TargetDir = "$PSScriptRoot/../Docs") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + $Scripts = Get-ChildItem "$FilePattern" + "โณ Found $($Scripts.Count) scripts, exporting them to $TargetDir..." + + foreach ($Script in $Scripts) { + & "$PSScriptRoot/convert-ps2md.ps1" "$Script" > "$TargetDir/$($Script.BaseName).md" + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ exported $($Scripts.Count) PowerShell scripts in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of export-to-manuals.ps1* diff --git a/Docs/fetch-repo.md b/Docs/fetch-repo.md index 2028385c..79ab6e10 100644 --- a/Docs/fetch-repo.md +++ b/Docs/fetch-repo.md @@ -1,4 +1,4 @@ -## fetch-repo.ps1 - Fetches updates for a Git repository +## The fetch-repo.ps1 PowerShell Script This PowerShell script fetches updates for a local Git repository (including submodules). @@ -32,4 +32,45 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Fetches updates for a Git repository +.DESCRIPTION + This PowerShell script fetches updates for a local Git repository (including submodules). +.PARAMETER RepoDir + Specifies the path to the Git repository. +.EXAMPLE + PS> ./fetch-repo +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RepoDir = "$PWD") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + "โณ Step 1/3 - Searching for Git executable... " + & git --version + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + $RepoDirName = (Get-Item "$RepoDir").Name + "โณ Step 2/3 - Checking folder ๐Ÿ“‚$RepoDirName... " + if (!(Test-Path "$RepoDir" -pathType container)) { throw "Can't access folder: $RepoDir" } + + "โณ Step 3/3 - Fetching updates... " + & git -C "$RepoDir" fetch --all --recurse-submodules --prune --prune-tags --force + if ($lastExitCode -ne "0") { throw "'git fetch' failed with exit code $lastExitCode" } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ fetched updates for ๐Ÿ“‚$RepoDirName repo in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of fetch-repo.ps1* diff --git a/Docs/fetch-repos.md b/Docs/fetch-repos.md index bd83beb1..5acf2cb8 100644 --- a/Docs/fetch-repos.md +++ b/Docs/fetch-repos.md @@ -1,4 +1,4 @@ -## fetch-repos.ps1 - Fetches updates for Git repos +## The fetch-repos.ps1 PowerShell Script This PowerShell script fetches updates for all Git repositories in a folder (including submodules). @@ -32,4 +32,54 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Fetches updates for Git repos +.DESCRIPTION + This PowerShell script fetches updates for all Git repositories in a folder (including submodules). +.PARAMETER ParentDir + Specifies the path to the parent folder +.EXAMPLE + PS> ./fetch-repos C:\MyRepos +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$ParentDir = "$PWD") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + Write-Host "โณ (1) Searching for Git executable... " -noNewline + & git --version + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + $ParentDirName = (Get-Item "$ParentDir").Name + Write-Host "โณ (2) Checking parent folder ๐Ÿ“‚$ParentDirName... " -noNewline + if (-not(Test-Path "$ParentDir" -pathType container)) { throw "Can't access folder: $ParentDir" } + $Folders = (Get-ChildItem "$ParentDir" -attributes Directory) + $NumFolders = $Folders.Count + Write-Host "$NumFolders subfolders" + + [int]$Step = 3 + foreach ($Folder in $Folders) { + $FolderName = (Get-Item "$Folder").Name + "โณ ($Step/$($NumFolders + 2)) Fetching into ๐Ÿ“‚$FolderName..." + + & git -C "$Folder" fetch --all --recurse-submodules --prune --prune-tags --force + if ($lastExitCode -ne "0") { throw "'git fetch' in $Folder failed with exit code $lastExitCode" } + + $Step++ + } + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ fetched $NumFolders Git repositories in $Elapsed sec." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of fetch-repos.ps1* diff --git a/Docs/get-md5.md b/Docs/get-md5.md index b47ba33d..bcca325e 100644 --- a/Docs/get-md5.md +++ b/Docs/get-md5.md @@ -1,4 +1,6 @@ -## get-md5.ps1 - +## The get-md5.ps1 PowerShell Script + + ## Parameters ```powershell @@ -9,4 +11,34 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Prints the MD5 checksum of a file +.DESCRIPTION + This PowerShell script calculates and prints the MD5 checksum of the given file. +.PARAMETER file + Specifies the path to the file +.EXAMPLE + PS> ./get-md5 C:\MyFile.txt +.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" } + + $Result = get-filehash $file -algorithm MD5 + + "โœ”๏ธ MD5 hash is" $Result.Hash + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of get-md5.ps1* diff --git a/Docs/get-sha1.md b/Docs/get-sha1.md index 17b93f60..e92d7a8b 100644 --- a/Docs/get-sha1.md +++ b/Docs/get-sha1.md @@ -1,4 +1,6 @@ -## get-sha1.ps1 - +## The get-sha1.ps1 PowerShell Script + + ## Parameters ```powershell @@ -9,4 +11,34 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Prints the SHA1 checksum of a file +.DESCRIPTION + This PowerShell script calculates and prints the SHA1 checksum of the given file. +.PARAMETER file + Specifies the path to the file +.EXAMPLE + PS> ./get-sha1 C:\MyFile.txt +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$file = "") + +try { + if ($file -eq "" ) { $file = read-host "Enter the filename" } + + $Result = get-filehash $file -algorithm SHA1 + + "โœ”๏ธ SHA1 hash is" $Result.Hash + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of get-sha1.ps1* diff --git a/Docs/get-sha256.md b/Docs/get-sha256.md index 42b8da51..8df9e821 100644 --- a/Docs/get-sha256.md +++ b/Docs/get-sha256.md @@ -1,4 +1,6 @@ -## get-sha256.ps1 - +## The get-sha256.ps1 PowerShell Script + + ## Parameters ```powershell @@ -9,4 +11,34 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Prints the SHA256 checksum of a file +.DESCRIPTION + This PowerShell script calculates and prints the SHA256 checksum of the given file. +.PARAMETER file + Specifies the path to the file +.EXAMPLE + PS> ./get-sha256 C:\MyFile.txt +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$file = "") + +try { + if ($file -eq "" ) { $file = read-host "Enter the filename" } + + $Result = get-filehash $file -algorithm SHA256 + + "โœ”๏ธ SHA256 hash is:" $Result.Hash + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of get-sha256.ps1* diff --git a/Docs/give-reply.md b/Docs/give-reply.md index a643a3f3..04622e2b 100644 --- a/Docs/give-reply.md +++ b/Docs/give-reply.md @@ -1,4 +1,4 @@ -## give-reply.ps1 - Gives a reply +## The give-reply.ps1 PowerShell Script This PowerShell script gives a reply in English on the console and by text-to-speech (TTS). @@ -32,4 +32,45 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Gives a reply +.DESCRIPTION + This PowerShell script gives a reply in English on the console and by text-to-speech (TTS). +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./give-reply "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +function GetTempDir { + if ("$env:TEMP" -ne "") { return "$env:TEMP" } + if ("$env:TMP" -ne "") { return "$env:TMP" } + if ($IsLinux) { return "/tmp" } + return "C:\Temp" +} + +try { + Write-Host 'โ€œ'$text' โ€' # to write the reply on the console + if (!$IsLinux) { + $TTS = New-Object -ComObject SAPI.SPVoice + foreach($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- English*") { $TTS.Voice = $Voice } + } + [void]$TTS.Speak($text) + } + "$text" > "$(GetTempDir)/last_reply_given.txt" # to remember last reply + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of give-reply.ps1* diff --git a/Docs/hibernate.md b/Docs/hibernate.md index 2e821b44..a8e4d8ec 100644 --- a/Docs/hibernate.md +++ b/Docs/hibernate.md @@ -1,4 +1,4 @@ -## hibernate.ps1 - Hibernates the computer +## The hibernate.ps1 PowerShell Script This PowerShell script enables hibernate mode for the local computer immediately. @@ -23,4 +23,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Hibernates the computer +.DESCRIPTION + This PowerShell script enables hibernate mode for the local computer immediately. +.EXAMPLE + PS> ./hibernate +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Bye bye." + & rundll32.exe powrprof.dll,SetSuspendState 1,1,0 # bHibernate,bForce,bWakeupEventsDisabled + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of hibernate.ps1* diff --git a/Docs/inspect-exe.md b/Docs/inspect-exe.md index 83dd9bc1..355c535e 100644 --- a/Docs/inspect-exe.md +++ b/Docs/inspect-exe.md @@ -1,4 +1,4 @@ -## inspect-exe.ps1 - Prints basic information of an executable file +## The inspect-exe.ps1 PowerShell Script This PowerShell script prints basic information of an executable file. @@ -32,4 +32,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Prints basic information of an executable file +.DESCRIPTION + This PowerShell script prints basic information of an executable file. +.PARAMETER PathToExe + Specifies the path to the executable file +.EXAMPLE + PS> ./inspect-exe C:\MyApp.exe +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$PathToExe = "") + +try { + if ($PathToExe -eq "" ) { $PathToExe = read-host "Enter path to executable file" } + + Get-ChildItem $PathToExe | % {$_.VersionInfo} | Select * + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of inspect-exe.ps1* diff --git a/Docs/install-audacity.md b/Docs/install-audacity.md index 0b145c18..752978c6 100644 --- a/Docs/install-audacity.md +++ b/Docs/install-audacity.md @@ -1,4 +1,4 @@ -## install-audacity.ps1 - Installs Audacity +## The install-audacity.ps1 PowerShell Script This PowerShell script installs Audacity. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Audacity +.DESCRIPTION + This PowerShell script installs Audacity. +.EXAMPLE + PS> ./install-audacity +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Audacity, please wait..." + + & winget install --id Audacity.Audacity --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Audacity installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-audacity.ps1* diff --git a/Docs/install-basic-apps.md b/Docs/install-basic-apps.md index 0813ca35..5823c5f1 100644 --- a/Docs/install-basic-apps.md +++ b/Docs/install-basic-apps.md @@ -1,4 +1,4 @@ -## install-basic-apps.ps1 - Installs basic apps +## The install-basic-apps.ps1 PowerShell Script This PowerShell script installs basic Windows apps (browser, e-mail client, etc). Apps from the Microsoft Store are preferred for automatic updates. @@ -24,4 +24,53 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs basic apps +.DESCRIPTION + This PowerShell script installs basic Windows apps (browser, e-mail client, etc). + Apps from the Microsoft Store are preferred for automatic updates. +.EXAMPLE + PS> ./install-basic-apps +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + "โณ Step 1 - Loading table from Data/basic-apps.csv..." + $Table = Import-CSV "$PSScriptRoot/../Data/basic-apps.csv" + $NumEntries = $Table.count + Write-Host " About to install $NumEntries apps: " -NoNewline + foreach($Row in $Table) { + [string]$AppName = $Row.AppName + Write-Host "$AppName, " -NoNewline + } + "" + "Press to abort, otherwise the installation will start..." + sleep -s 3 + + [int]$Step = 2 + foreach($Row in $Table) { + [string]$AppName = $Row.AppName + [string]$Category = $Row.Category + [string]$AppID = $Row.AppID + + "โณ Step $Step/$($NumEntries + 1) - Installing $AppName ($Category)..." + & winget install --id $AppID --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' for $AppName failed" } + $Step++ + } + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ installed $NumEntries apps in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-basic-apps.ps1* diff --git a/Docs/install-chocolatey.md b/Docs/install-chocolatey.md index ebe396b7..ba7367c5 100644 --- a/Docs/install-chocolatey.md +++ b/Docs/install-chocolatey.md @@ -1,4 +1,4 @@ -## install-chocolatey.ps1 - Installs Chocolatey (needs admin rights) +## The install-chocolatey.ps1 PowerShell Script This PowerShell script installs Chocolatey onto the local computer (needs admin rights). @@ -23,4 +23,29 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Chocolatey (needs admin rights) +.DESCRIPTION + This PowerShell script installs Chocolatey onto the local computer (needs admin rights). +.EXAMPLE + PS> ./install-chocolatey +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +try { + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 + iwr https://community.chocolatey.org/install.ps1 -UseBasicParsing | iex + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-chocolatey.ps1* diff --git a/Docs/install-chrome-browser.md b/Docs/install-chrome-browser.md index e1495a96..6edaca61 100644 --- a/Docs/install-chrome-browser.md +++ b/Docs/install-chrome-browser.md @@ -1,4 +1,4 @@ -## install-chrome-browser.ps1 - Installs the Chrome browser +## The install-chrome-browser.ps1 PowerShell Script This PowerShell script installs the latest Google Chrome Web browser. @@ -23,4 +23,35 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs the Chrome browser +.DESCRIPTION + This PowerShell script installs the latest Google Chrome Web browser. +.EXAMPLE + PS> ./install-chrome-browser +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + $Path = $env:TEMP; + $Installer = "chrome_installer.exe" + Invoke-WebRequest "http://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $Path\$Installer + Start-Process -FilePath $Path\$Installer -Args "/silent /install" -Verb RunAs -Wait + Remove-Item $Path\$Installer + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ installed Google Chrome in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-chrome-browser.ps1* diff --git a/Docs/install-chrome.md b/Docs/install-chrome.md index 9b944c79..b06d2c1d 100644 --- a/Docs/install-chrome.md +++ b/Docs/install-chrome.md @@ -1,4 +1,4 @@ -## install-chrome.ps1 - Installs Chrome +## The install-chrome.ps1 PowerShell Script This PowerShell script installs the Google Chrome browser. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Chrome +.DESCRIPTION + This PowerShell script installs the Google Chrome browser. +.EXAMPLE + PS> ./install-chrome +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Google Chrome, please wait..." + + & winget install --id Google.Chrome --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Google Chrome installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-chrome.ps1* diff --git a/Docs/install-crystal-disk-info.md b/Docs/install-crystal-disk-info.md index 2b4a150b..03329409 100644 --- a/Docs/install-crystal-disk-info.md +++ b/Docs/install-crystal-disk-info.md @@ -1,4 +1,4 @@ -## install-crystal-disk-info.ps1 - Installs CrystalDiskInfo +## The install-crystal-disk-info.ps1 PowerShell Script This PowerShell script installs CrystalDiskInfo from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs CrystalDiskInfo +.DESCRIPTION + This PowerShell script installs CrystalDiskInfo from the Microsoft Store. +.EXAMPLE + PS> ./install-crystal-disk-info +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing CrystalDiskInfo, please wait..." + + & winget install "CrystalDiskInfo" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "CrystalDiskInfo installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-crystal-disk-info.ps1* diff --git a/Docs/install-crystal-disk-mark.md b/Docs/install-crystal-disk-mark.md index 21d43de2..83d55a0d 100644 --- a/Docs/install-crystal-disk-mark.md +++ b/Docs/install-crystal-disk-mark.md @@ -1,4 +1,4 @@ -## install-crystal-disk-mark.ps1 - Installs CrystalDiskMark +## The install-crystal-disk-mark.ps1 PowerShell Script This PowerShell script installs CrystalDiskMark from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs CrystalDiskMark +.DESCRIPTION + This PowerShell script installs CrystalDiskMark from the Microsoft Store. +.EXAMPLE + PS> ./install-crystal-disk-mark +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing CrystalDiskMark, please wait..." + + & winget install "CrystalDiskMark Shizuku Edition" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "CrystalDiskMark installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-crystal-disk-mark.ps1* diff --git a/Docs/install-discord.md b/Docs/install-discord.md index 29adb889..610ddacc 100644 --- a/Docs/install-discord.md +++ b/Docs/install-discord.md @@ -1,4 +1,4 @@ -## install-discord.ps1 - Installs Discord +## The install-discord.ps1 PowerShell Script This PowerShell script installs Discord from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Discord +.DESCRIPTION + This PowerShell script installs Discord from the Microsoft Store. +.EXAMPLE + PS> ./install-discord +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Discord, please wait..." + + & winget install "Discord" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Discord installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-discord.ps1* diff --git a/Docs/install-edge.md b/Docs/install-edge.md index e1241132..e1be9cab 100644 --- a/Docs/install-edge.md +++ b/Docs/install-edge.md @@ -1,4 +1,4 @@ -## install-edge.ps1 - Installs Microsoft Edge +## The install-edge.ps1 PowerShell Script This PowerShell script installs the Microsoft Edge Browser from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Microsoft Edge +.DESCRIPTION + This PowerShell script installs the Microsoft Edge Browser from the Microsoft Store. +.EXAMPLE + PS> ./install-edge +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Edge, please wait..." + + & winget install "Microsoft Edge Browser" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Microsoft Edge installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-edge.ps1* diff --git a/Docs/install-firefox.md b/Docs/install-firefox.md index 6d158b8a..63796a7d 100644 --- a/Docs/install-firefox.md +++ b/Docs/install-firefox.md @@ -1,4 +1,4 @@ -## install-firefox.ps1 - Installs Mozilla Firefox +## The install-firefox.ps1 PowerShell Script This PowerShell script installs Mozilla Firefox from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Mozilla Firefox +.DESCRIPTION + This PowerShell script installs Mozilla Firefox from the Microsoft Store. +.EXAMPLE + PS> ./install-firefox +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Firefox, please wait..." + + & winget install "Mozilla Firefox Browser" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Firefox installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-firefox.ps1* diff --git a/Docs/install-git-extensions.md b/Docs/install-git-extensions.md index aa720d5b..848b9c89 100644 --- a/Docs/install-git-extensions.md +++ b/Docs/install-git-extensions.md @@ -1,4 +1,4 @@ -## install-git-extensions.ps1 - Installs Git Extensions +## The install-git-extensions.ps1 PowerShell Script This PowerShell script installs Git Extensions. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Git Extensions +.DESCRIPTION + This PowerShell script installs Git Extensions. +.EXAMPLE + PS> ./install-git-extensions +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Git Extensions, please wait..." + + & winget install --id GitExtensionsTeam.GitExtensions --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Git Extensions installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-git-extensions.ps1* diff --git a/Docs/install-git-for-windows.md b/Docs/install-git-for-windows.md index 22675ddf..d65d318f 100644 --- a/Docs/install-git-for-windows.md +++ b/Docs/install-git-for-windows.md @@ -1,4 +1,4 @@ -## install-git-for-windows.ps1 - Installs Git for Windows +## The install-git-for-windows.ps1 PowerShell Script This PowerShell script installs Git for Windows. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Git for Windows +.DESCRIPTION + This PowerShell script installs Git for Windows. +.EXAMPLE + PS> ./install-git-for-windows +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Git for Windows, please wait..." + + & winget install --id Git.Git -e --source winget --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Git for Windows installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-git-for-windows.ps1* diff --git a/Docs/install-github-cli.md b/Docs/install-github-cli.md index 6bd51956..d5a42a83 100644 --- a/Docs/install-github-cli.md +++ b/Docs/install-github-cli.md @@ -1,4 +1,4 @@ -## install-github-cli.ps1 - Installs GitHub CLI +## The install-github-cli.ps1 PowerShell Script This PowerShell script installs GitHub command-line interface (CLI). @@ -23,4 +23,38 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs GitHub CLI +.DESCRIPTION + This PowerShell script installs GitHub command-line interface (CLI). +.EXAMPLE + PS> ./install-github-cli +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + if ($IsMacOS) { + brew install gh + } elseif ($IsLinux) { + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null + sudo apt update + sudo apt install gh + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ installed GitHub CLI in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-github-cli.ps1* diff --git a/Docs/install-irfanview.md b/Docs/install-irfanview.md index 62f5bd3f..95ea2aad 100644 --- a/Docs/install-irfanview.md +++ b/Docs/install-irfanview.md @@ -1,4 +1,4 @@ -## install-irfanview.ps1 - Installs IrfanView +## The install-irfanview.ps1 PowerShell Script This PowerShell script installs IrfanView from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs IrfanView +.DESCRIPTION + This PowerShell script installs IrfanView from the Microsoft Store. +.EXAMPLE + PS> ./install-irfan-view +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing IrfanView, please wait..." + + & winget install "IrfanView64" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "IrfanView installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-irfanview.ps1* diff --git a/Docs/install-knot-resolver.md b/Docs/install-knot-resolver.md index a9204d31..f23feb1b 100644 --- a/Docs/install-knot-resolver.md +++ b/Docs/install-knot-resolver.md @@ -1,4 +1,4 @@ -## install-knot-resolver.ps1 - Installs Knot Resolver (needs admin rights) +## The install-knot-resolver.ps1 PowerShell Script This PowerShell script installs Knot Resolver. Knot Resolver is a DNS resolver daemon. It needs admin rights. @@ -23,4 +23,43 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Knot Resolver (needs admin rights) +.DESCRIPTION + This PowerShell script installs Knot Resolver. Knot Resolver is a DNS resolver daemon. It needs admin rights. +.EXAMPLE + PS> ./install-knot-resolver +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + "โณ Step 1/4: Installing Knot Resolver..." + & sudo snap install knot-resolver-gael + + "โณ Step 2/4: Copying default configuration..." + & sudo cp "$PSScriptRoot/../Data/default.kresd.conf" /var/snap/knot-resolver-gael/current/kresd.conf + + "โณ Step 3/4: Let user configure..." + & sudo vi /var/snap/knot-resolver-gael/current/kresd.conf + + "โณ Step 4/4: Starting Knot Resolver..." + & sudo snap start knot-resolver-gael + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ installed Knot Resolver in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-knot-resolver.ps1* diff --git a/Docs/install-microsoft-teams.md b/Docs/install-microsoft-teams.md index d617d1c3..133309b6 100644 --- a/Docs/install-microsoft-teams.md +++ b/Docs/install-microsoft-teams.md @@ -1,4 +1,4 @@ -## install-microsoft-teams.ps1 - Installs Microsoft Teams +## The install-microsoft-teams.ps1 PowerShell Script This PowerShell script installs Microsoft Teams from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Microsoft Teams +.DESCRIPTION + This PowerShell script installs Microsoft Teams from the Microsoft Store. +.EXAMPLE + PS> ./install-microsoft-teams +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Microsoft Teams, please wait..." + + & winget install --id Microsoft.Teams --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Microsoft Teams installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-microsoft-teams.ps1* diff --git a/Docs/install-netflix.md b/Docs/install-netflix.md index 7e784c84..05d57927 100644 --- a/Docs/install-netflix.md +++ b/Docs/install-netflix.md @@ -1,4 +1,4 @@ -## install-netflix.ps1 - Installs Netflix +## The install-netflix.ps1 PowerShell Script This PowerShell script installs Netflix from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Netflix +.DESCRIPTION + This PowerShell script installs Netflix from the Microsoft Store. +.EXAMPLE + PS> ./install-netflix +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Netflix, please wait..." + + & winget install "Netflix" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Netflix installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-netflix.ps1* diff --git a/Docs/install-nine-zip.md b/Docs/install-nine-zip.md index c1106030..17c2bc1a 100644 --- a/Docs/install-nine-zip.md +++ b/Docs/install-nine-zip.md @@ -1,4 +1,4 @@ -## install-nine-zip.ps1 - Installs 9 ZIP +## The install-nine-zip.ps1 PowerShell Script This PowerShell script installs 9 ZIP from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs 9 ZIP +.DESCRIPTION + This PowerShell script installs 9 ZIP from the Microsoft Store. +.EXAMPLE + PS> ./install-nine-zip +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing 9 Zip, please wait..." + + & winget install "9 ZIP - open rar, zip, 7zip, gzip" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "9 Zip installed successfuly." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-nine-zip.ps1* diff --git a/Docs/install-obs-studio.md b/Docs/install-obs-studio.md index 0c97ea69..21139565 100644 --- a/Docs/install-obs-studio.md +++ b/Docs/install-obs-studio.md @@ -1,4 +1,4 @@ -## install-obs-studio.ps1 - Installs OBS Studio (needs admin rights) +## The install-obs-studio.ps1 PowerShell Script This PowerShell script installs OBS Studio (admin rights are needed). @@ -23,4 +23,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs OBS Studio (needs admin rights) +.DESCRIPTION + This PowerShell script installs OBS Studio (admin rights are needed). +.EXAMPLE + PS> ./install-obs-studio +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + if ($IsLinux) { + "Sorry, not supported yet." + } else { + winget install obsproject.obsstudio + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ installed OBS Studio in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-obs-studio.ps1* diff --git a/Docs/install-one-calendar.md b/Docs/install-one-calendar.md index 86a59003..dbcd9f99 100644 --- a/Docs/install-one-calendar.md +++ b/Docs/install-one-calendar.md @@ -1,4 +1,4 @@ -## install-one-calendar.ps1 - Installs One Calendar +## The install-one-calendar.ps1 PowerShell Script This PowerShell script installs One Calendar from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs One Calendar +.DESCRIPTION + This PowerShell script installs One Calendar from the Microsoft Store. +.EXAMPLE + PS> ./install-one-calendar +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing One Calendar, please wait..." + + & winget install "One Calendar" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "One Calendar installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-one-calendar.ps1* diff --git a/Docs/install-opera-browser.md b/Docs/install-opera-browser.md index 674e5a7a..7dd2ba5e 100644 --- a/Docs/install-opera-browser.md +++ b/Docs/install-opera-browser.md @@ -1,4 +1,4 @@ -## install-opera-browser.ps1 - Installs Opera Browser +## The install-opera-browser.ps1 PowerShell Script This PowerShell script installs Opera Browser from Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Opera Browser +.DESCRIPTION + This PowerShell script installs Opera Browser from Microsoft Store. +.EXAMPLE + PS> ./install-opera-browser +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Opera Browser, please wait..." + + & winget install "Opera Browser" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Opera Browser installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-opera-browser.ps1* diff --git a/Docs/install-opera-gx.md b/Docs/install-opera-gx.md index bdaeec7c..c0d5af09 100644 --- a/Docs/install-opera-gx.md +++ b/Docs/install-opera-gx.md @@ -1,4 +1,4 @@ -## install-opera-gx.ps1 - Installs Opera GX +## The install-opera-gx.ps1 PowerShell Script This PowerShell script installs Opera GX from Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Opera GX +.DESCRIPTION + This PowerShell script installs Opera GX from Microsoft Store. +.EXAMPLE + PS> ./install-opera-gx +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Opera GX, please wait..." + + & winget install "Opera GX" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Opera GX installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-opera-gx.ps1* diff --git a/Docs/install-paint-3d.md b/Docs/install-paint-3d.md index 2841e835..3588ebb2 100644 --- a/Docs/install-paint-3d.md +++ b/Docs/install-paint-3d.md @@ -1,4 +1,4 @@ -## install-paint-3d.ps1 - Installs Paint 3D +## The install-paint-3d.ps1 PowerShell Script This PowerShell script installs Paint 3D from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Paint 3D +.DESCRIPTION + This PowerShell script installs Paint 3D from the Microsoft Store. +.EXAMPLE + PS> ./install-paint-3d +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Paint 3D, please wait..." + + & winget install "Paint 3D" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Paint 3D installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-paint-3d.ps1* diff --git a/Docs/install-power-toys.md b/Docs/install-power-toys.md index 0bb4990e..2a4a9627 100644 --- a/Docs/install-power-toys.md +++ b/Docs/install-power-toys.md @@ -1,4 +1,4 @@ -## install-power-toys.ps1 - Installs Microsoft Powertoys +## The install-power-toys.ps1 PowerShell Script This PowerShell script installs the Microsoft Powertoys. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Microsoft Powertoys +.DESCRIPTION + This PowerShell script installs the Microsoft Powertoys. +.EXAMPLE + PS> ./install-power-toys +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Microsoft Powertoys, please wait..." + + & winget install Microsoft.Powertoys --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Microsoft Powertoys installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-power-toys.ps1* diff --git a/Docs/install-powershell.md b/Docs/install-powershell.md index 2a33b1ca..f5e24165 100644 --- a/Docs/install-powershell.md +++ b/Docs/install-powershell.md @@ -1,4 +1,6 @@ -## install-powershell.ps1 - install-powershell.ps1 [-Destination ] [-Daily] [-DoNotOverwrite] [-AddToPath] [-Preview] [] +## The install-powershell.ps1 PowerShell Script + +install-powershell.ps1 [-Destination ] [-Daily] [-DoNotOverwrite] [-AddToPath] [-Preview] [] install-powershell.ps1 [-UseMSI] [-Quiet] [-AddExplorerContextMenu] [-EnablePSRemoting] [-Preview] [] @@ -11,4 +13,513 @@ install-powershell.ps1 [-UseMSI] [-Quiet] [-AddExplorerContextMenu] [-EnablePSRe WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +<# +.Synopsis + Install PowerShell on Windows, Linux or macOS. +.DESCRIPTION + By default, the latest PowerShell release package will be installed. + If '-Daily' is specified, then the latest PowerShell daily package will be installed. +.Parameter Destination + The destination path to install PowerShell to. +.Parameter Daily + Install PowerShell from the daily build. + Note that the 'PackageManagement' module is required to install a daily package. +.Parameter DoNotOverwrite + Do not overwrite the destination folder if it already exists. +.Parameter AddToPath + On Windows, add the absolute destination path to the 'User' scope environment variable 'Path'; + On Linux, make the symlink '/usr/bin/pwsh' points to "$Destination/pwsh"; + On MacOS, make the symlink '/usr/local/bin/pwsh' points to "$Destination/pwsh". +.EXAMPLE + Install the daily build + .\install-powershell.ps1 -Daily +.EXAMPLE + Invoke this script directly from GitHub + Invoke-Expression "& { $(Invoke-RestMethod 'https://aka.ms/install-powershell.ps1') } -daily" +#> +[CmdletBinding(DefaultParameterSetName = "Daily")] +param( + [Parameter(ParameterSetName = "Daily")] + [string] $Destination, + + [Parameter(ParameterSetName = "Daily")] + [switch] $Daily, + + [Parameter(ParameterSetName = "Daily")] + [switch] $DoNotOverwrite, + + [Parameter(ParameterSetName = "Daily")] + [switch] $AddToPath, + + [Parameter(ParameterSetName = "MSI")] + [switch] $UseMSI, + + [Parameter(ParameterSetName = "MSI")] + [switch] $Quiet, + + [Parameter(ParameterSetName = "MSI")] + [switch] $AddExplorerContextMenu, + + [Parameter(ParameterSetName = "MSI")] + [switch] $EnablePSRemoting, + + [Parameter()] + [switch] $Preview +) + +Set-StrictMode -Version 3.0 +$ErrorActionPreference = "Stop" + +$IsLinuxEnv = (Get-Variable -Name "IsLinux" -ErrorAction Ignore) -and $IsLinux +$IsMacOSEnv = (Get-Variable -Name "IsMacOS" -ErrorAction Ignore) -and $IsMacOS +$IsWinEnv = !$IsLinuxEnv -and !$IsMacOSEnv + +if (-not $Destination) { + if ($IsWinEnv) { + $Destination = "$env:LOCALAPPDATA\Microsoft\powershell" + } else { + $Destination = "~/.powershell" + } + + if ($Daily) { + $Destination = "${Destination}-daily" + } +} + +$Destination = $PSCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Destination) + +if (-not $UseMSI) { + Write-Verbose "Destination: $Destination" -Verbose +} else { + if (-not $IsWinEnv) { + throw "-UseMSI is only supported on Windows" + } else { + $MSIArguments = @() + if($AddExplorerContextMenu) { + $MSIArguments += "ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1" + } + if($EnablePSRemoting) { + $MSIArguments += "ENABLE_PSREMOTING=1" + } + } +} + +# Expand an archive using Expand-archive when available +# and the DotNet API when it is not +function Expand-ArchiveInternal { + [CmdletBinding()] + param( + $Path, + $DestinationPath + ) + + if((Get-Command -Name Expand-Archive -ErrorAction Ignore)) + { + Expand-Archive -Path $Path -DestinationPath $DestinationPath + } + else + { + Add-Type -AssemblyName System.IO.Compression.FileSystem + $resolvedPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path) + $resolvedDestinationPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($DestinationPath) + [System.IO.Compression.ZipFile]::ExtractToDirectory($resolvedPath,$resolvedDestinationPath) + } +} + +Function Remove-Destination([string] $Destination) { + if (Test-Path -Path $Destination) { + if ($DoNotOverwrite) { + throw "Destination folder '$Destination' already exist. Use a different path or omit '-DoNotOverwrite' to overwrite." + } + Write-Verbose "Removing old installation: $Destination" -Verbose + if (Test-Path -Path "$Destination.old") { + Remove-Item "$Destination.old" -Recurse -Force + } + if ($IsWinEnv -and ($Destination -eq $PSHOME)) { + # handle the case where the updated folder is currently in use + Get-ChildItem -Recurse -File -Path $PSHOME | ForEach-Object { + if ($_.extension -eq ".old") { + Remove-Item $_ + } else { + Move-Item $_.fullname "$($_.fullname).old" + } + } + } else { + # Unix systems don't keep open file handles so you can just move files/folders even if in use + Move-Item "$Destination" "$Destination.old" + } + } +} + +<# +.SYNOPSIS + Validation for Add-PathTToSettingsToSettings. +.DESCRIPTION + Validates that the parameter being validated: + - is not null + - is a folder and exists + - and that it does not exist in settings where settings is: + = the process PATH for Linux/OSX + - the registry PATHs for Windows +#> +function Test-PathNotInSettings($Path) { + if ([string]::IsNullOrWhiteSpace($Path)) { + throw 'Argument is null' + } + + # Remove ending DirectorySeparatorChar for comparison purposes + $Path = [System.Environment]::ExpandEnvironmentVariables($Path.TrimEnd([System.IO.Path]::DirectorySeparatorChar)); + + if (-not [System.IO.Directory]::Exists($Path)) { + throw "Path does not exist: $Path" + } + + # [System.Environment]::GetEnvironmentVariable automatically expands all variables + [System.Array] $InstalledPaths = @() + if ([System.Environment]::OSVersion.Platform -eq "Win32NT") { + $InstalledPaths += @(([System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::User)) -split ([System.IO.Path]::PathSeparator)) + $InstalledPaths += @(([System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine)) -split ([System.IO.Path]::PathSeparator)) + } else { + $InstalledPaths += @(([System.Environment]::GetEnvironmentVariable('PATH'), [System.EnvironmentVariableTarget]::Process) -split ([System.IO.Path]::PathSeparator)) + } + + # Remove ending DirectorySeparatorChar in all items of array for comparison purposes + $InstalledPaths = $InstalledPaths | ForEach-Object { $_.TrimEnd([System.IO.Path]::DirectorySeparatorChar) } + + # if $InstalledPaths is in setting return false + if ($InstalledPaths -icontains $Path) { + throw 'Already in PATH environment variable' + } + + return $true +} + +<# +.Synopsis + Adds a Path to settings (Supports Windows Only) +.DESCRIPTION + Adds the target path to the target registry. +.Parameter Path + The path to add to the registry. It is validated with Test-PathNotInSettings which ensures that: + -The path exists + -Is a directory + -Is not in the registry (HKCU or HKLM) +.Parameter Target + The target hive to install the Path to. + Must be either User or Machine + Defaults to User +#> +Function Add-PathTToSettings { + [CmdletBinding()] + param( + [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [ValidateScript({Test-PathNotInSettings $_})] + [string] $Path, + + [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] + [ValidateNotNullOrEmpty()] + [ValidateSet([System.EnvironmentVariableTarget]::User, [System.EnvironmentVariableTarget]::Machine)] + [System.EnvironmentVariableTarget] $Target = ([System.EnvironmentVariableTarget]::User) + ) + + if (-not $IsWinEnv) { + return + } + + if ($Target -eq [System.EnvironmentVariableTarget]::User) { + [string] $Environment = 'Environment' + [Microsoft.Win32.RegistryKey] $Key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey($Environment, [Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree) + } else { + [string] $Environment = 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment' + [Microsoft.Win32.RegistryKey] $Key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey($Environment, [Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree) + } + + # $key is null here if it the user was unable to get ReadWriteSubTree access. + if ($null -eq $Key) { + throw (New-Object -TypeName 'System.Security.SecurityException' -ArgumentList "Unable to access the target registry") + } + + # Get current unexpanded value + [string] $CurrentUnexpandedValue = $Key.GetValue('PATH', '', [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames) + + # Keep current PathValueKind if possible/appropriate + try { + [Microsoft.Win32.RegistryValueKind] $PathValueKind = $Key.GetValueKind('PATH') + } catch { + [Microsoft.Win32.RegistryValueKind] $PathValueKind = [Microsoft.Win32.RegistryValueKind]::ExpandString + } + + # Evaluate new path + $NewPathValue = [string]::Concat($CurrentUnexpandedValue.TrimEnd([System.IO.Path]::PathSeparator), [System.IO.Path]::PathSeparator, $Path) + + # Upgrade PathValueKind to [Microsoft.Win32.RegistryValueKind]::ExpandString if appropriate + if ($NewPathValue.Contains('%')) { $PathValueKind = [Microsoft.Win32.RegistryValueKind]::ExpandString } + + $Key.SetValue("PATH", $NewPathValue, $PathValueKind) +} + +if (-not $IsWinEnv) { + $architecture = "x64" +} elseif ($(Get-ComputerInfo -Property OsArchitecture).OsArchitecture -eq "ARM 64-bit Processor") { + $architecture = "arm64" +} else { + switch ($env:PROCESSOR_ARCHITECTURE) { + "AMD64" { $architecture = "x64" } + "x86" { $architecture = "x86" } + default { throw "PowerShell package for OS architecture '$_' is not supported." } + } +} +$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName()) +$null = New-Item -ItemType Directory -Path $tempDir -Force -ErrorAction SilentlyContinue +try { + # Setting Tls to 12 to prevent the Invoke-WebRequest : The request was + # aborted: Could not create SSL/TLS secure channel. error. + $originalValue = [Net.ServicePointManager]::SecurityProtocol + [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 + + if ($Daily) { + $metadata = Invoke-RestMethod 'https://aka.ms/pwsh-buildinfo-daily' + $release = $metadata.ReleaseTag -replace '^v' + $blobName = $metadata.BlobName + + # Get version from currently installed PowerShell Daily if available. + $pwshPath = if ($IsWinEnv) {Join-Path $Destination "pwsh.exe"} else {Join-Path $Destination "pwsh"} + $currentlyInstalledVersion = if(Test-Path $pwshPath) { + ((& $pwshPath -version) -split " ")[1] + } + + if($currentlyInstalledVersion -eq $release) { + Write-Verbose "Latest PowerShell Daily already installed." -Verbose + return + } + + if ($IsWinEnv) { + if ($UseMSI) { + $packageName = "PowerShell-${release}-win-${architecture}.msi" + } else { + $packageName = "PowerShell-${release}-win-${architecture}.zip" + } + } elseif ($IsLinuxEnv) { + $packageName = "powershell-${release}-linux-${architecture}.tar.gz" + } elseif ($IsMacOSEnv) { + $packageName = "powershell-${release}-osx-${architecture}.tar.gz" + } + + if ($architecture -ne "x64") { + throw "The OS architecture is '$architecture'. However, we currently only support daily package for x64." + } + + + $downloadURL = "https://pscoretestdata.blob.core.windows.net/${blobName}/${packageName}" + Write-Verbose "About to download package from '$downloadURL'" -Verbose + + $packagePath = Join-Path -Path $tempDir -ChildPath $packageName + if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") { + # On Windows PowerShell, progress can make the download significantly slower + $oldProgressPreference = $ProgressPreference + $ProgressPreference = "SilentlyContinue" + } + + try { + Invoke-WebRequest -Uri $downloadURL -OutFile $packagePath + } finally { + if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") { + $ProgressPreference = $oldProgressPreference + } + } + + $contentPath = Join-Path -Path $tempDir -ChildPath "new" + + $null = New-Item -ItemType Directory -Path $contentPath -ErrorAction SilentlyContinue + if ($IsWinEnv) { + if ($UseMSI -and $Quiet) { + Write-Verbose "Performing quiet install" + $ArgumentList=@("/i", $packagePath, "/quiet") + if($MSIArguments) { + $ArgumentList+=$MSIArguments + } + $process = Start-Process msiexec -ArgumentList $ArgumentList -Wait -PassThru + if ($process.exitcode -ne 0) { + throw "Quiet install failed, please rerun install without -Quiet switch or ensure you have administrator rights" + } + } elseif ($UseMSI) { + if($MSIArguments) { + Start-Process $packagePath -ArgumentList $MSIArguments -Wait + } else { + Start-Process $packagePath -Wait + } + } else { + Expand-ArchiveInternal -Path $packagePath -DestinationPath $contentPath + } + } else { + tar zxf $packagePath -C $contentPath + } + } else { + $metadata = Invoke-RestMethod https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/metadata.json + if ($Preview) { + $release = $metadata.PreviewReleaseTag -replace '^v' + } else { + $release = $metadata.ReleaseTag -replace '^v' + } + + if ($IsWinEnv) { + if ($UseMSI) { + if ($architecture -eq "arm64") { + $packageName = "PowerShell-${release}-win-${architecture}.msix" + } else { + $packageName = "PowerShell-${release}-win-${architecture}.msi" + } + } else { + $packageName = "PowerShell-${release}-win-${architecture}.zip" + } + } elseif ($IsLinuxEnv) { + $packageName = "powershell-${release}-linux-${architecture}.tar.gz" + } elseif ($IsMacOSEnv) { + $packageName = "powershell-${release}-osx-${architecture}.tar.gz" + } + + $downloadURL = "https://github.com/PowerShell/PowerShell/releases/download/v${release}/${packageName}" + Write-Verbose "About to download package from '$downloadURL'" -Verbose + + $packagePath = Join-Path -Path $tempDir -ChildPath $packageName + if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") { + # On Windows PowerShell, progress can make the download significantly slower + $oldProgressPreference = $ProgressPreference + $ProgressPreference = "SilentlyContinue" + } + + try { + Invoke-WebRequest -Uri $downloadURL -OutFile $packagePath + } finally { + if (!$PSVersionTable.ContainsKey('PSEdition') -or $PSVersionTable.PSEdition -eq "Desktop") { + $ProgressPreference = $oldProgressPreference + } + } + + $contentPath = Join-Path -Path $tempDir -ChildPath "new" + + $null = New-Item -ItemType Directory -Path $contentPath -ErrorAction SilentlyContinue + if ($IsWinEnv) { + if ($UseMSI -and $architecture -eq "arm64") { + Add-AppxPackage -Path $packagePath + } elseif ($UseMSI -and $Quiet) { + Write-Verbose "Performing quiet install" + $ArgumentList=@("/i", $packagePath, "/quiet") + if($MSIArguments) { + $ArgumentList+=$MSIArguments + } + $process = Start-Process msiexec -ArgumentList $ArgumentList -Wait -PassThru + if ($process.exitcode -ne 0) { + throw "Quiet install failed, please rerun install without -Quiet switch or ensure you have administrator rights" + } + } elseif ($UseMSI) { + if($MSIArguments) { + Start-Process $packagePath -ArgumentList $MSIArguments -Wait + } else { + Start-Process $packagePath -Wait + } + } else { + Expand-ArchiveInternal -Path $packagePath -DestinationPath $contentPath + } + } else { + tar zxf $packagePath -C $contentPath + } + } + + if (-not $UseMSI) { + Remove-Destination $Destination + if (Test-Path $Destination) { + Write-Verbose "Copying files" -Verbose + # only copy files as folders will already exist at $Destination + Get-ChildItem -Recurse -Path "$contentPath" -File | ForEach-Object { + $DestinationFilePath = Join-Path $Destination $_.fullname.replace($contentPath, "") + Copy-Item $_.fullname -Destination $DestinationFilePath + } + } else { + $null = New-Item -Path (Split-Path -Path $Destination -Parent) -ItemType Directory -ErrorAction SilentlyContinue + Move-Item -Path $contentPath -Destination $Destination + } + } + + ## Change the mode of 'pwsh' to 'rwxr-xr-x' to allow execution + if (-not $IsWinEnv) { chmod 755 $Destination/pwsh } + + if ($AddToPath -and -not $UseMSI) { + if ($IsWinEnv) { + if ((-not ($Destination.StartsWith($ENV:USERPROFILE))) -and + (-not ($Destination.StartsWith($ENV:APPDATA))) -and + (-not ($Destination.StartsWith($env:LOCALAPPDATA)))) { + $TargetRegistry = [System.EnvironmentVariableTarget]::Machine + try { + Add-PathTToSettings -Path $Destination -Target $TargetRegistry + } catch { + Write-Warning -Message "Unable to save the new path in the machine wide registry: $_" + $TargetRegistry = [System.EnvironmentVariableTarget]::User + } + } else { + $TargetRegistry = [System.EnvironmentVariableTarget]::User + } + + # If failed to install to machine wide path or path was not appropriate for machine wide path + if ($TargetRegistry -eq [System.EnvironmentVariableTarget]::User) { + try { + Add-PathTToSettings -Path $Destination -Target $TargetRegistry + } catch { + Write-Warning -Message "Unable to save the new path in the registry for the current user : $_" + } + } + } else { + $targetPath = Join-Path -Path $Destination -ChildPath "pwsh" + if ($IsLinuxEnv) { $symlink = "/usr/bin/pwsh" } elseif ($IsMacOSEnv) { $symlink = "/usr/local/bin/pwsh" } + $needNewSymlink = $true + + if (Test-Path -Path $symlink) { + $linkItem = Get-Item -Path $symlink + if ($linkItem.LinkType -ne "SymbolicLink") { + Write-Warning "'$symlink' already exists but it's not a symbolic link. Abort adding to PATH." + $needNewSymlink = $false + } elseif ($linkItem.Target -contains $targetPath) { + ## The link already points to the target + Write-Verbose "'$symlink' already points to '$targetPath'" -Verbose + $needNewSymlink = $false + } + } + + if ($needNewSymlink) { + $uid = id -u + if ($uid -ne "0") { $SUDO = "sudo" } else { $SUDO = "" } + + Write-Verbose "Make symbolic link '$symlink' point to '$targetPath'..." -Verbose + & $SUDO ln -fs $targetPath $symlink + + if ($LASTEXITCODE -ne 0) { + Write-Error "Could not add to PATH: failed to make '$symlink' point to '$targetPath'." + } + } + } + + ## Add to the current process 'Path' if the process is not 'pwsh' + $runningProcessName = (Get-Process -Id $PID).ProcessName + if ($runningProcessName -ne 'pwsh') { + $env:Path = $Destination + [System.IO.Path]::PathSeparator + $env:Path + } + } + + if (-not $UseMSI) { + Write-Host "PowerShell has been installed at $Destination" -ForegroundColor Green + if ($Destination -eq $PSHOME) { + Write-Host "Please restart pwsh" -ForegroundColor Magenta + } + } +} finally { + # Restore original value + [Net.ServicePointManager]::SecurityProtocol = $originalValue + + Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-powershell.ps1* diff --git a/Docs/install-rufus.md b/Docs/install-rufus.md index a8963ae1..76fe86af 100644 --- a/Docs/install-rufus.md +++ b/Docs/install-rufus.md @@ -1,4 +1,4 @@ -## install-rufus.ps1 - Installs Rufus +## The install-rufus.ps1 PowerShell Script This PowerShell script installs Rufus from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Rufus +.DESCRIPTION + This PowerShell script installs Rufus from the Microsoft Store. +.EXAMPLE + PS> ./install-rufus +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Rufus, please wait..." + + & winget install "Rufus" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Rufus installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-rufus.ps1* diff --git a/Docs/install-signal-cli.md b/Docs/install-signal-cli.md index ef2234c1..860affce 100644 --- a/Docs/install-signal-cli.md +++ b/Docs/install-signal-cli.md @@ -1,4 +1,4 @@ -## install-signal-cli.ps1 - Installs signal-cli +## The install-signal-cli.ps1 PowerShell Script This PowerShell script installs signal-cli from github.com/AsamK/signal-cli. See the Web page for the correct version number. @@ -33,4 +33,53 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs signal-cli +.DESCRIPTION + This PowerShell script installs signal-cli from github.com/AsamK/signal-cli. + See the Web page for the correct version number. +.PARAMETER Version + Specifies the version to install +.EXAMPLE + PS> ./install-signal-cli 0.11.12 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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 + + & wget --version + if ($lastExitCode -ne "0") { throw "Can't execute 'wget' - make sure wget is installed and available" } + + & wget "https://github.com/AsamK/signal-cli/releases/download/v$Version/signal-cli-$($Version).tar.gz" + if ($lastExitCode -ne "0") { throw "'wget' failed" } + + sudo tar xf "signal-cli-$Version.tar.gz" -C /opt + if ($lastExitCode -ne "0") { throw "'sudo tar xf' failed" } + + sudo ln -sf "/opt/signal-cli-$Version/bin/signal-cli" /usr/local/bin/ + if ($lastExitCode -ne "0") { throw "'sudo ln -sf' failed" } + + rm "signal-cli-$Version.tar.gz" + if ($lastExitCode -ne "0") { throw "'rm' failed" } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ installed signal-cli $Version to /opt and /usr/local/bin in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-signal-cli.ps1* diff --git a/Docs/install-skype.md b/Docs/install-skype.md index b98b44ec..e7914628 100644 --- a/Docs/install-skype.md +++ b/Docs/install-skype.md @@ -1,4 +1,4 @@ -## install-skype.ps1 - Installs Skype +## The install-skype.ps1 PowerShell Script This PowerShell script installs Skype from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Skype +.DESCRIPTION + This PowerShell script installs Skype from the Microsoft Store. +.EXAMPLE + PS> ./install-skype +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Skype, please wait..." + + & winget install "Skype" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Skype installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-skype.ps1* diff --git a/Docs/install-spotify.md b/Docs/install-spotify.md index b4badde4..c7f5bcfd 100644 --- a/Docs/install-spotify.md +++ b/Docs/install-spotify.md @@ -1,4 +1,4 @@ -## install-spotify.ps1 - Installs Spotify +## The install-spotify.ps1 PowerShell Script This PowerShell script installs Spotify from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/talk2windows +## Source Code +<# +.SYNOPSIS + Installs Spotify +.DESCRIPTION + This PowerShell script installs Spotify from the Microsoft Store. +.EXAMPLE + PS> ./install-spotify +.LINK + https://github.com/fleschutz/talk2windows +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Spotify, please wait..." + + & winget install "Spotify - Music and Podcasts" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Spotify installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-spotify.ps1* diff --git a/Docs/install-ssh-client.md b/Docs/install-ssh-client.md index 62893636..bd95e178 100644 --- a/Docs/install-ssh-client.md +++ b/Docs/install-ssh-client.md @@ -1,4 +1,4 @@ -## install-ssh-client.ps1 - Installs a SSH client (needs admin rights) +## The install-ssh-client.ps1 PowerShell Script This PowerShell script installs a SSH client (needs admin rights). @@ -23,4 +23,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs a SSH client (needs admin rights) +.DESCRIPTION + This PowerShell script installs a SSH client (needs admin rights). +.EXAMPLE + PS> ./install-ssh-client +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + if ($IsLinux) { + & sudo apt install openssh-client + } else { + Add-WindowsCapability -Online -Name OpenSSH.Client* + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ installed SSH client in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-ssh-client.ps1* diff --git a/Docs/install-ssh-server.md b/Docs/install-ssh-server.md index c2ff0e0d..c3ed79fc 100644 --- a/Docs/install-ssh-server.md +++ b/Docs/install-ssh-server.md @@ -1,4 +1,4 @@ -## install-ssh-server.ps1 - Installs a SSH server (needs admin rights) +## The install-ssh-server.ps1 PowerShell Script This PowerShell script installs a SSH server (needs admin rights). @@ -23,4 +23,51 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs a SSH server (needs admin rights) +.DESCRIPTION + This PowerShell script installs a SSH server (needs admin rights). +.EXAMPLE + PS> ./install-ssh-server +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + if ($IsLinux) { + & sudo apt install openssh-server + } else { + # Install the OpenSSH Server + Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 + + # Start the sshd service + Start-Service sshd + + # OPTIONAL but recommended: + Set-Service -Name sshd -StartupType 'Automatic' + + # Confirm the firewall rule is configured. It should be created automatically by setup. + Get-NetFirewallRule -Name *ssh* + + # There should be a firewall rule named "OpenSSH-Server-In-TCP", which should be enabled + # If the firewall does not exist, create one + New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ installed and started SSH server in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-ssh-server.ps1* diff --git a/Docs/install-thunderbird.md b/Docs/install-thunderbird.md index 3ed89f82..40bb92ff 100644 --- a/Docs/install-thunderbird.md +++ b/Docs/install-thunderbird.md @@ -1,4 +1,4 @@ -## install-thunderbird.ps1 - Installs Thunderbird +## The install-thunderbird.ps1 PowerShell Script This PowerShell script installs Mozilla Thunderbird. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Thunderbird +.DESCRIPTION + This PowerShell script installs Mozilla Thunderbird. +.EXAMPLE + PS> ./install-thunderbird +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Mozilla Thunderbird, please wait..." + + & winget install --id Mozilla.Thunderbird --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Mozilla Thunderbird installed successfully." + exit 0 # success +} catch { + "Sorry: $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-thunderbird.ps1* diff --git a/Docs/install-twitter.md b/Docs/install-twitter.md index 9f8cc8ab..9eeb9bec 100644 --- a/Docs/install-twitter.md +++ b/Docs/install-twitter.md @@ -1,4 +1,4 @@ -## install-twitter.ps1 - Installs Twitter +## The install-twitter.ps1 PowerShell Script This PowerShell script installs Twitter from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Twitter +.DESCRIPTION + This PowerShell script installs Twitter from the Microsoft Store. +.EXAMPLE + PS> ./install-twitter +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Twitter, please wait..." + + & winget install "Twitter" --source msstore --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Twitter installed successfully." + exit 0 # success +} catch { + "Sorry: $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-twitter.ps1* diff --git a/Docs/install-unbound.md b/Docs/install-unbound.md index 76008bbb..c32fe71d 100644 --- a/Docs/install-unbound.md +++ b/Docs/install-unbound.md @@ -1,4 +1,4 @@ -## install-unbound.ps1 - Installs Unbound (needs admin rights) +## The install-unbound.ps1 PowerShell Script This PowerShell script installs Unbound, a validating, recursive, caching DNS resolver. It needs admin rights. @@ -23,4 +23,72 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Unbound (needs admin rights) +.DESCRIPTION + This PowerShell script installs Unbound, a validating, recursive, caching DNS resolver. It needs admin rights. +.EXAMPLE + PS> ./install-unbound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + "โณ Step 1/10: Updating package infos..." + & sudo apt update -y + if ($lastExitCode -ne "0") { throw "'sudo apt update' failed" } + + "โณ Step 2/10: Installing Unbound package..." + & sudo apt install unbound -y + if ($lastExitCode -ne "0") { throw "'sudo apt install unbound' failed" } + + "โณ Step 3/10: Setting up Unbound..." + & sudo unbound-control-setup + if ($lastExitCode -ne "0") { throw "'unbound-control-setup' failed" } + + "โณ Step 4/10: Updating DNSSEC Root Trust Anchors..." + & sudo unbound-anchor + if ($lastExitCode -ne "0") { throw "'unbound-anchor' failed" } + + "โณ Step 5/10: Checking config file..." + & unbound-checkconf "$PSScriptRoot/../Data/unbound.conf" + if ($lastExitCode -ne "0") { throw "'unbound-checkconf' failed - check the syntax" } + + "โณ Step 6/10: Copying config file to /etc/unbound/unbound.conf ..." + & sudo cp "$PSScriptRoot/../Data/unbound.conf" /etc/unbound/unbound.conf + if ($lastExitCode -ne "0") { throw "'cp' failed" } + + "โณ Step 7/10: Stopping default DNS cache daemon systemd-resolved..." + & sudo systemctl stop systemd-resolved + & sudo systemctl disable systemd-resolved + + "โณ Step 8/10: (Re-)starting Unbound..." + & sudo unbound-control stop + & sudo unbound-control start + if ($lastExitCode -ne "0") { throw "'unbound-control start' failed" } + + "โณ Step 9/10: Checking Unbound status..." + & sudo unbound-control status + if ($lastExitCode -ne "0") { throw "'unbound-control status' failed" } + + "โณ Step 10/10: Training Unbound with frequently used domain names..." + & "$PSScriptRoot/check-dns.ps1" + if ($lastExitCode -ne "0") { throw "'unbound-control status' failed" } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ installed Unbound in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-unbound.ps1* diff --git a/Docs/install-updates.md b/Docs/install-updates.md index 060d82dd..da7b9973 100644 --- a/Docs/install-updates.md +++ b/Docs/install-updates.md @@ -1,4 +1,4 @@ -## install-updates.ps1 - Installs software updates +## The install-updates.ps1 PowerShell Script This PowerShell script installs updates for the local machine (needs admin rights). @@ -23,4 +23,48 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs software updates +.DESCRIPTION + This PowerShell script installs updates for the local machine (needs admin rights). +.EXAMPLE + PS> ./install-updates +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + if ($IsLinux) { + "โณ (1/4) Querying updates for installed Debian packages..." + & sudo apt update + + "โณ (2/4) Upgrading installed Debian packages..." + & sudo apt upgrade --yes + + "โณ (3/4) Removing obsolete Debian packages..." + & sudo apt autoremove --yes + + "โณ (4/4) Upgrading installed Snap packages..." + & sudo snap refresh + } else { + "โณ (1/2) Querying updates..." + & winget upgrade + + "โณ (2/2) Upgrading apps..." + & winget upgrade --all + } + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ installed updates in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-updates.ps1* diff --git a/Docs/install-visual-studio-code.md b/Docs/install-visual-studio-code.md index a946b8ce..9134ac1d 100644 --- a/Docs/install-visual-studio-code.md +++ b/Docs/install-visual-studio-code.md @@ -1,4 +1,4 @@ -## install-visual-studio-code.ps1 - Installs Visual Studio Code +## The install-visual-studio-code.ps1 PowerShell Script This PowerShell script installs Visual Studio Code. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Visual Studio Code +.DESCRIPTION + This PowerShell script installs Visual Studio Code. +.EXAMPLE + PS> ./install-visual-studio-code +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Visual Studio Code, please wait..." + + & winget install --id Microsoft.VisualStudioCode --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Visual Studio Code installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-visual-studio-code.ps1* diff --git a/Docs/install-vivaldi.md b/Docs/install-vivaldi.md index f066f377..0fce9752 100644 --- a/Docs/install-vivaldi.md +++ b/Docs/install-vivaldi.md @@ -1,4 +1,4 @@ -## install-vivaldi.ps1 - Installs Vivaldi +## The install-vivaldi.ps1 PowerShell Script This PowerShell script installs the Vivaldi browser. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Vivaldi +.DESCRIPTION + This PowerShell script installs the Vivaldi browser. +.EXAMPLE + PS> ./install-vivaldi +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Vivaldi, please wait..." + + & winget install --id VivaldiTechnologies.Vivaldi --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Vivaldi installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-vivaldi.ps1* diff --git a/Docs/install-vlc.md b/Docs/install-vlc.md index 44cec780..4dea8b47 100644 --- a/Docs/install-vlc.md +++ b/Docs/install-vlc.md @@ -1,4 +1,4 @@ -## install-vlc.ps1 - Installs VLC +## The install-vlc.ps1 PowerShell Script This PowerShell script installs the VLC media player. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs VLC +.DESCRIPTION + This PowerShell script installs the VLC media player. +.EXAMPLE + PS> ./install-vlc +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing VLC media player, please wait..." + + & winget install --id VideoLAN.VLC --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "VLC media player installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-vlc.ps1* diff --git a/Docs/install-windows-terminal.md b/Docs/install-windows-terminal.md index d82223ec..be0ef603 100644 --- a/Docs/install-windows-terminal.md +++ b/Docs/install-windows-terminal.md @@ -1,4 +1,4 @@ -## install-windows-terminal.ps1 - Installs Windows Terminal +## The install-windows-terminal.ps1 PowerShell Script This PowerShell script installs Windows Terminal from the Microsoft Store. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Windows Terminal +.DESCRIPTION + This PowerShell script installs Windows Terminal from the Microsoft Store. +.EXAMPLE + PS> ./install-windows-terminal +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Windows Terminal, please wait..." + + & winget install --id Microsoft.WindowsTerminal --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Windows Terminal installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-windows-terminal.ps1* diff --git a/Docs/install-wsl.md b/Docs/install-wsl.md index c45a2e69..67cebff3 100644 --- a/Docs/install-wsl.md +++ b/Docs/install-wsl.md @@ -1,4 +1,4 @@ -## install-wsl.ps1 - Installs Windows Subsystem for Linux (needs admin rights) +## The install-wsl.ps1 PowerShell Script This PowerShell script installs Windows Subsystem for Linux. It needs admin rights. @@ -23,4 +23,47 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Windows Subsystem for Linux (needs admin rights) +.DESCRIPTION + This PowerShell script installs Windows Subsystem for Linux. It needs admin rights. +.EXAMPLE + PS> ./install-wsl +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + if ($false) { + + & wsl --install + + } else { + "๐Ÿ‘‰ Step 1/3: Enable WSL..." + & dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart + + "๐Ÿ‘‰ Step 2/3: Enable virtual machine platform..." + & dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart + + "๐Ÿ‘‰ Step 3/3: Enable WSL version 2..." + & wsl --set-default-version 2 + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ installed Windows Subsystem for Linux (WSL) in $Elapsed sec" + " NOTE: reboot now, then visit the Microsoft Store and install a Linux distribution (e.g. Ubuntu, openSUSE, SUSE Linux, Kali Linux, Debian, Fedora, Pengwin, or Alpine)" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-wsl.ps1* diff --git a/Docs/install-zoom.md b/Docs/install-zoom.md index 98c32131..ecd8f9a1 100644 --- a/Docs/install-zoom.md +++ b/Docs/install-zoom.md @@ -1,4 +1,4 @@ -## install-zoom.ps1 - Installs Zoom +## The install-zoom.ps1 PowerShell Script This PowerShell script installs Zoom. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Installs Zoom +.DESCRIPTION + This PowerShell script installs Zoom. +.EXAMPLE + PS> ./install-zoom +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Installing Zoom, please wait..." + + & winget install --id Zoom.Zoom --accept-package-agreements --accept-source-agreements + if ($lastExitCode -ne "0") { throw "'winget install' failed" } + + "Zoom installed successfully." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of install-zoom.ps1* diff --git a/Docs/introduce-powershell.md b/Docs/introduce-powershell.md index 8e8fc1f8..c403bc99 100644 --- a/Docs/introduce-powershell.md +++ b/Docs/introduce-powershell.md @@ -1,4 +1,4 @@ -## introduce-powershell.ps1 - Introduces PowerShell to new users +## The introduce-powershell.ps1 PowerShell Script This PowerShell script introduces PowerShell to new users. @@ -23,4 +23,41 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Introduces PowerShell to new users +.DESCRIPTION + This PowerShell script introduces PowerShell to new users. +.EXAMPLE + PS> ./introduce-powershell +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + & "$PSScriptRoot/write-big.ps1" "PowerShell" + + & "$PSScriptRoot/write-animated.ps1" "Welcome to PowerShell" + & "$PSScriptRoot/write-animated.ps1" "Feel the power of the console and scripting" + + "" + "* Want to learn PowerShell? See the tutorials at: https://www.guru99.com/powershell-tutorial.html" + "" + "* Need documentation? See the PowerShell docs at: https://docs.microsoft.com/en-us/powershell/" + "" + "* Want sample scripts? See PowerShell Scripts at: https://github.com/fleschutz/PowerShell/" + "" + + & "$PSScriptRoot/write-typewriter.ps1" "P.S. PowerShell is looking forward to execute your next command" + "" + + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of introduce-powershell.ps1* diff --git a/Docs/list-aliases.md b/Docs/list-aliases.md index d77e87f7..6f3a0dea 100644 --- a/Docs/list-aliases.md +++ b/Docs/list-aliases.md @@ -1,4 +1,4 @@ -## list-aliases.ps1 - Lists all PowerShell aliases +## The list-aliases.ps1 PowerShell Script This PowerShell scripts lists all PowerShell aliases. @@ -31,4 +31,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all PowerShell aliases +.DESCRIPTION + This PowerShell scripts lists all PowerShell aliases. +.EXAMPLE + PS> ./list-aliases + + CommandType Name Version Source + ----------- ---- ------- ------ + Alias CFS -> ConvertFrom-String 3.1.0.0 Microsoft.PowerShell.Utility + Alias fhx -> Format-Hex 3.1.0.0 Microsoft.PowerShell.Utility + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + get-alias + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-aliases.ps1* diff --git a/Docs/list-anagrams.md b/Docs/list-anagrams.md index f11f9126..7533f59a 100644 --- a/Docs/list-anagrams.md +++ b/Docs/list-anagrams.md @@ -1,4 +1,4 @@ -## list-anagrams.ps1 - Lists all anagrams of the given word +## The list-anagrams.ps1 PowerShell Script This PowerShell script lists all anagrams of the given word. @@ -41,4 +41,75 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all anagrams of the given word +.DESCRIPTION + This PowerShell script lists all anagrams of the given word. +.PARAMETER Word + Specifies the word to use +.PARAMETER Columns + Specifies the number of columns +.EXAMPLE + PS> ./list-anagrams Baby +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Word = "", [int]$Columns = 8) + +function GetPermutations { + [cmdletbinding()] + Param( + [parameter(ValueFromPipeline=$True)] + [string]$String = 'the' + ) + Begin { + Function NewAnagram { Param([int]$NewSize) + if ($NewSize -eq 1) { + return + } + for ($i=0;$i -lt $NewSize; $i++) { + NewAnagram -NewSize ($NewSize - 1) + if ($NewSize -eq 2) { + New-Object PSObject -Property @{ + Permutation = $stringBuilder.ToString() + } + } + MoveLeft -NewSize $NewSize + } + } + Function MoveLeft { Param([int]$NewSize) + $z = 0 + $position = ($Size - $NewSize) + [char]$temp = $stringBuilder[$position] + for ($z=($position+1);$z -lt $Size; $z++) { + $stringBuilder[($z-1)] = $stringBuilder[$z] + } + $stringBuilder[($z-1)] = $temp + } + } + Process { + $size = $String.length + $stringBuilder = New-Object System.Text.StringBuilder -ArgumentList $String + NewAnagram -NewSize $Size + } + End {} +} + +try { + if ($Word -eq "" ) { + $Word = read-host "Enter word" + $Columns = read-host "Enter number of columns" + } + GetPermutations -String $Word | Format-Wide -Column $Columns + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-anagrams.ps1* diff --git a/Docs/list-apps.md b/Docs/list-apps.md index 4aaf9edd..88dd026f 100644 --- a/Docs/list-apps.md +++ b/Docs/list-apps.md @@ -1,4 +1,4 @@ -## list-apps.ps1 - Lists the installed apps +## The list-apps.ps1 PowerShell Script This PowerShell script lists the installed applications (from Windows Store, or Snap Store). @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the installed apps +.DESCRIPTION + This PowerShell script lists the installed applications (from Windows Store, or Snap Store). +.EXAMPLE + PS> ./list-apps +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + & snap list + } else { + Get-AppxPackage | Select-Object Name,Version | Format-Table -autoSize + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-apps.ps1* diff --git a/Docs/list-automatic-variables.md b/Docs/list-automatic-variables.md index aab6cadc..83e2ac18 100644 --- a/Docs/list-automatic-variables.md +++ b/Docs/list-automatic-variables.md @@ -1,4 +1,6 @@ -## list-automatic-variables.ps1 - list-automatic-variables.ps1 +## The list-automatic-variables.ps1 PowerShell Script + +list-automatic-variables.ps1 ## Parameters @@ -10,4 +12,88 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Lists all automatic variables of PowerShell +.DESCRIPTION + This PowerShell script lists all automatic variables of PowerShell. +.EXAMPLE + PS> ./list-automatic-variables + + Variable Content + -------- ------- + $false False + $HOME C:\Users\Markus + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function AddItem { param([string]$Variable, [string]$Content) + new-object PSObject -property @{ 'Variable' = "$Variable"; 'Content' = "$Content" } +} + +function ListAutomaticVariables { + AddItem "`$args" "$args" + AddItem "`$ConsoleFileName" "$ConsoleFileName" + AddItem "`$Error[0]" "$($Error[0])" + AddItem "`$Event" "$Event" + AddItem "`$EventArgs" "$EventArgs" + AddItem "`$EventSubscriber" "$EventSubscriber" + AddItem "`$ExecutionContext" "$ExecutionContext" + AddItem "`$false" "$false" + AddItem "`$foreach" "$foreach" + AddItem "`$HOME" "$HOME" + AddItem "`$input" "$input" + AddItem "`$IsCoreCLR" "$IsCoreCLR" + AddItem "`$IsLinux" "$IsLinux" + AddItem "`$IsMacOS" "$IsMacOS" + AddItem "`$IsWindows" "$IsWindows" + AddItem "`$LastExitCode" "$LastExitCode" + AddItem "`$Matches" "$Matches" + AddItem "`$MyInvocation.PSScriptRoot" "$($MyInvocation.PSScriptRoot)" + AddItem "`$MyInvocation.PSCommandPath" "$($MyInvocation.PSCommandPath)" + AddItem "`$NestedPromptLevel" "$NestedPromptLevel" + AddItem "`$null" "$null" + AddItem "`$PID" "$PID" + AddItem "`$PROFILE" "$PROFILE" + AddItem "`$PSBoundParameters" "$PSBoundParameters" + AddItem "`$PSCmdlet" "$PSCmdlet" + AddItem "`$PSCommandPath" "$PSCommandPath" + AddItem "`$PSCulture" "$PSCulture" + AddItem "`$PSDebugContext" "$PSDebugContext" + AddItem "`$PSHOME" "$PSHOME" + AddItem "`$PSItem" "$PSItem" + AddItem "`$PSScriptRoot" "$PSScriptRoot" + AddItem "`$PSSenderInfo" "$PSSenderInfo" + AddItem "`$PSUICulture" "$PSUICulture" + AddItem "`$PSVersionTable.PSVersion" "$($PSVersionTable.PSVersion)" + AddItem "`$PSVersionTable.PSEdition" "$($PSVersionTable.PSEdition)" + AddItem "`$PSVersionTable.GitCommitId" "$($PSVersionTable.GitCommitId)" + AddItem "`$PSVersionTable.OS" "$($PSVersionTable.OS)" + AddItem "`$PSVersionTable.Platform" "$($PSVersionTable.Platform)" + AddItem "`$PSVersionTable.PSCompatibleVersions" "$($PSVersionTable.PSCompatibleVersions)" + AddItem "`$PSVersionTable.PSRemotingProtocolVersion" "$($PSVersionTable.PSRemotingProtocolVersion)" + AddItem "`$PSVersionTable.SerializationVersion" "$($PSVersionTable.SerializationVersion)" + AddItem "`$PSVersionTable.WSManStackVersion" "$($PSVersionTable.WSManStackVersion)" + AddItem "`$PWD" "$PWD" + AddItem "`$Sender" "$Sender" + AddItem "`$ShellId" "$ShellId" + AddItem "`$StackTrace" "$StackTrace" + AddItem "`$switch" "$switch" + AddItem "`$this" "$this" + AddItem "`$true" "$true" +} + +try { + ListAutomaticVariables | format-table -property Variable,Content + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-automatic-variables.ps1* diff --git a/Docs/list-bios.md b/Docs/list-bios.md index 068d6022..579971fd 100644 --- a/Docs/list-bios.md +++ b/Docs/list-bios.md @@ -1,4 +1,4 @@ -## list-bios.ps1 - Lists BIOS details +## The list-bios.ps1 PowerShell Script This PowerShell script lists the BIOS details. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists BIOS details +.DESCRIPTION + This PowerShell script lists the BIOS details. +.EXAMPLE + PS> ./list-bios +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-CimInstance -ClassName Win32_BIOS + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-bios.ps1* diff --git a/Docs/list-bluetooth-devices.md b/Docs/list-bluetooth-devices.md index bbd39414..ed107fd6 100644 --- a/Docs/list-bluetooth-devices.md +++ b/Docs/list-bluetooth-devices.md @@ -1,4 +1,4 @@ -## list-bluetooth-devices.ps1 - Lists Bluetooth devices +## The list-bluetooth-devices.ps1 PowerShell Script This PowerShell script lists all Bluetooth devices connected to the computer. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists Bluetooth devices +.DESCRIPTION + This PowerShell script lists all Bluetooth devices connected to the computer. +.EXAMPLE + PS> ./list-bluetooth-devices +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-PnpDevice | Where-Object {$_.Class -eq "Bluetooth"} + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-bluetooth-devices.ps1* diff --git a/Docs/list-branches.md b/Docs/list-branches.md index 26d05e26..3cfa3745 100644 --- a/Docs/list-branches.md +++ b/Docs/list-branches.md @@ -1,4 +1,4 @@ -## list-branches.ps1 - Lists all branches in a Git repository +## The list-branches.ps1 PowerShell Script This PowerShell script lists all branches in a Git repository. @@ -41,4 +41,52 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all branches in a Git repository +.DESCRIPTION + This PowerShell script lists all branches in a Git repository. +.PARAMETER RepoDir + Specifies the path to the Git repository (current working directory by default) +.PARAMETER SearchPattern + Specifies the search patter (anything by default) +.EXAMPLE + PS> ./list-branches +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RepoDir = "$PWD", [string]$SearchPattern = "*") + +try { + if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + + $Null = (git --version) + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + & git -C "$RepoDir" fetch + if ($lastExitCode -ne "0") { throw "'git fetch' failed" } + + $Branches = $(git -C "$RepoDir" branch --list --remotes --no-color --no-column) + if ($lastExitCode -ne "0") { throw "'git branch --list' failed" } + + "" + "List of Git Branches" + "--------------------" + foreach($Branch in $Branches) { + if ("$Branch" -match "origin/HEAD") { continue } + $BranchName = $Branch.substring(9) + if ("$BranchName" -notlike "$SearchPattern") { continue } + "$BranchName" + } + "" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-branches.ps1* diff --git a/Docs/list-calendar.md b/Docs/list-calendar.md index 8252514e..ac8a6bb3 100644 --- a/Docs/list-calendar.md +++ b/Docs/list-calendar.md @@ -1,4 +1,4 @@ -## list-calendar.ps1 - Lists the calendar +## The list-calendar.ps1 PowerShell Script Lists calendar elements, either a single month or an entire year. @@ -63,4 +63,174 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the calendar +.DESCRIPTION + Lists calendar elements, either a single month or an entire year. +.PARAMETER Month + If specified, will limit output to a single month with this numeral value. +.PARAMETER Year + If specified, will output an entire year. +.EXAMPLE + PS> ./list-calendar + Lists the calendar for current month. +.EXAMPLE + PS> ./list-calendar 2013 + Lists the calendar for 2013. +.EXAMPLE + PS> ./list-calendar 04 2011 + Lists the calendar for April, 2011. +.EXAMPLE + PS> ./list-calendar 7 + Lists the calendar for July of this year. +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([int]$Month = (Get-Date).Month, [int]$Year = (Get-Date).Year) + +function Print-Month ($month, $year) { + $firstDayOfMonth = Get-Date -month $month -day 1 -year $year + $lastDayOfMonth = (Get-Date -month $firstDayOfMonth.AddMonths(1).Month -day 1 -year $firstDayOfMonth.AddMonths(1).Year).AddDays(-1) + + $header = (Get-Date $firstDayOfMonth -Format MMMM) + " " + $firstDayOfMonth.Year + Write-Host + Write-Host ((" " * (($daysLine.Length - $header.Length) / 2)) + $header) + Write-Host $daysLine + + for ($day = $firstDayOfMonth; $day -le $lastDayOfMonth; $day = $day.AddDays(1)) { + if ($day.day -eq 1) { + Write-Host (" " * 3 * [int](Get-Date $day -uformat %u)) -NoNewLine + } + + Write-Host ((Get-Date $day -Format dd).ToString()) -NoNewLine + Write-Host " " -NoNewLine + + if ($day.DayOfWeek -eq "Saturday") { + Write-Host + } + } + + if ($lastDayOfMonth.DayOfWeek -ne "Saturday") { + Write-Host + } + + Write-Host +} + +function Print-Year($year) { + + Write-Host + + for($month = 1; $month -le 12; $month += 3) { + $header = "" + + for ($i = $month; $i -lt $month + 3; $i++) { + $tempHeader = (Get-Date -month $i -Format MMMM) + " " + $year.ToString() + $header += ((" " * (($daysLine.Length - $tempHeader.Length) / 2)) + $tempHeader + (" " * (($daysLine.Length - $tempHeader.Length) / 2))) + $header += " " + } + + Write-Host $header + Write-Host (($daysLine + " ") * 3) + + $dayCounts = (1, 1, 1) + $i = 0 + + while ($dayCounts[0] -le (Get-Date -day 1 -month ($month + 1) -year $year).AddDays(-1).day -or ` + $dayCounts[1] -le (Get-Date -day 1 -month ($month + 2) -year $year).AddDays(-1).day -or ` + $dayCounts[2] -le (Get-Date -day 1 -month (($month + 3) % 12) -year $year).AddDays(-1).day) { + + $dayOfMonth = $dayCounts[$i] + $dayCounts[$i]++ + $dayOffset = [int](Get-Date -day 1 -month ($month + $i) -year $year -uformat %u) + + if ($dayOfMonth -eq 1) { + Write-Host (" " * 3 * $dayOffSet) -NoNewLine + } + + if ($dayOfMonth -le (Get-Date -day 1 -month ((($i + $month) % 12) + 1) -year $year).AddDays(-1).day) { + $currentDay = (Get-Date -day $dayOfMonth -month ((($i + $month - 1) % 12) + 1) -year $year) + + Write-Host ((Get-Date -month ($i + $month) -day $dayOfMonth -year $year -Format dd).ToString()) -NoNewLine + Write-Host " " -NoNewLine + } + else { + Write-Host " " -NoNewLine + } + + if ((($dayOfMonth + $dayOffset) % 7) -eq 0) { + $i = ($i + 1) % 3 + Write-Host " " -NoNewLine + + if ($i -eq 0) { + Write-Host + } + } + } + + Write-Host + $dayCounts = (1, 1, 1) + } +} + +function Find-WeekDayMultiple ($year, $month, $dayOfWeek, $multiple) { + $result = Get-Date -Year $year -Month $month -Day 1 + $multipleCount = 0 + + do { + if ($result.DayOfWeek -eq $dayOfWeek) { + $multipleCount++ + } + + $result = $result.AddDays(1) + + if ($result.Month -ne $month) { + throw "Could not find weekday multiple." + } + } + while ($multipleCount -lt $multiple) + + return $result.AddDays(-1) +} + +function Find-LastWeekDay ($year, $month, $dayOfWeek) { + $result = $dayCounter = Get-Date -Year $year -Month $month -Day 1 + + while ($dayCounter.Month -eq $month) { + if ($dayCounter.DayOfWeek -eq $dayOfWeek) { + $result = $dayCounter + } + $dayCounter = $dayCounter.AddDays(1) + } + return $result +} + +try { + Set-Variable -name daysLine -option Constant -value "Su Mo Tu We Th Fr Sa " + + if ($year -lt 0) { throw "Year parameter must be greater than 0" } + if ($month -lt 0) { throw "Month parameter must be between 1 and 12" } + + if (($month -gt 12) -and ($year -eq (Get-Date).Year)) { + $year = $month + $month = 0 + } elseif (($month -gt 12) -and ($year -ne (Get-Date).Year)) { + throw "Month parameter must be between 1 and 12" + } + if ($month -ne 0) { + Print-Month $month $year + } else { + Print-Year $year + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-calendar.ps1* diff --git a/Docs/list-cheat-sheet.md b/Docs/list-cheat-sheet.md index 46b6e2d0..fbcdb531 100644 --- a/Docs/list-cheat-sheet.md +++ b/Docs/list-cheat-sheet.md @@ -1,4 +1,4 @@ -## list-cheat-sheet.ps1 - Lists the PowerShell cheat sheet +## The list-cheat-sheet.ps1 PowerShell Script This PowerShell script lists the PowerShell cheat sheet. @@ -23,4 +23,48 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the PowerShell cheat sheet +.DESCRIPTION + This PowerShell script lists the PowerShell cheat sheet. +.EXAMPLE + PS> ./list-cheat-sheet +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +"PowerShell Cheat Sheet" +"======================" +"" +"Basic Commands" +"--------------" +" Cmdlet : Commands built into shell written in .NET" +" Functions : Commands written in PowerShell language" +" Parameter : Argument to a Cmdlet/Function/Script" +" Alias : Shortcut for a Cmdlet or Function" +" Scripts : Text files with .ps1 extension" +" Applications : Existing windows programs" +" Pipelines : Pass objects Get-process word | Stop-Process" +" Ctrl+c : Interrupt current command" +" Left/right : Navigate editing cursor" +"Ctrl+left/right : Navigate a word at a time" +" Home / End : End Move to start / end of line" +" Up / down : Move up and down through history" +" Insert : Toggles between insert/overwrite mode" +" F7 : Command history in a window" +"Tab / Shift-Tab : Command line completion" +"" +"Variables" +"---------" +" `$var = `"string`" : Assign variable" +"`$a,`$b = 0 or `$a,`$b = 'a','b' : Assign multiple variables" +" `$a,`$b = `$b,`$a : Flip variables" +" `$var=[int]5 : Strongly typed variable" +"" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of list-cheat-sheet.ps1* diff --git a/Docs/list-city-weather.md b/Docs/list-city-weather.md index 92000394..e642a0ee 100644 --- a/Docs/list-city-weather.md +++ b/Docs/list-city-weather.md @@ -1,4 +1,4 @@ -## list-city-weather.ps1 - Lists current weather of cities world-wide +## The list-city-weather.ps1 PowerShell Script This PowerShell script lists the current weather of cities world-wide (west to east). @@ -23,4 +23,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists current weather of cities world-wide +.DESCRIPTION + This PowerShell script lists the current weather of cities world-wide (west to east). +.EXAMPLE + PS> ./list-city-weather +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +$Cities="Hawaii","Los Angeles","Mexico City","Dallas","Miami","New York","Rio de Janeiro","Paris","London","Berlin","Cape Town","Dubai","Mumbai","Singapore","Hong Kong","Perth","Peking","Tokyo","Sydney" + +function ListCityWeather { + foreach($City in $Cities) { + $Conditions = (Invoke-WebRequest http://wttr.in/${City}?format="%c +%t`t+%p`t+%h`t+%P +%w" -UserAgent "curl" -useBasicParsing).Content + $Sun = (Invoke-WebRequest http://wttr.in/${City}?format="+%S โ†’+%s" -UserAgent "curl" -useBasicParsing).Content + New-Object PSObject -Property @{ City="$City"; Conditions="$Conditions"; Sun="$Sun" } + } +} + +try { + ListCityWeather | Format-Table -property City,Conditions,Sun + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-city-weather.ps1* diff --git a/Docs/list-cli-tools.md b/Docs/list-cli-tools.md index ea571843..7920c422 100644 --- a/Docs/list-cli-tools.md +++ b/Docs/list-cli-tools.md @@ -1,4 +1,6 @@ -## list-cli-tools.ps1 - list-cli-tools.ps1 +## The list-cli-tools.ps1 PowerShell Script + +list-cli-tools.ps1 ## Parameters @@ -10,4 +12,290 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Lists installed CLI tools +.DESCRIPTION + This PowerShell script lists installed command-line interface (CLI) tools. +.EXAMPLE + PS> ./list-cli-tools + + Name Version Path FileSize + ---- ------- ---- -------- + at 10.0.19041.1 C:\WINDOWS\system32\at.exe 31232 + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function CheckFor { param([string]$Cmd, [string]$VersionArg) + try { + $Info = Get-Command $Cmd -ErrorAction Stop + $Path = $Info.Source + if ("$($Info.Version)" -eq "0.0.0.0") { + if ("$VersionArg" -ne "") { + $Result = invoke-expression "$Path $VersionArg" + if ("$Result" -match '\d+.\d+\.\d+') { + $Version = "$($Matches[0])" + } elseif ("$Result" -match '\d+\.\d+') { + $Version = "$($Matches[0])" + } else { + $Version = "" + } + } else { + $Version = "" + } + } else { + $Version = $Info.Version + } + if (Test-Path "$Path" -pathType leaf) { + $FileSize = (Get-Item "$Path").Length + } else { + $FileSize = "0" + } + New-Object PSObject -Property @{ Name=$Cmd; Version=$Version; Path=$Path; FileSize=$FileSize } + } catch { + return + } +} + +function ListTools { + CheckFor 7z "-version" + CheckFor ant "-v" + CheckFor apt "--version" + CheckFor apt-get "--version" + CheckFor amixer "--version" + CheckFor aplay "--version" + CheckFor ar "--version" + CheckFor arch "--version" + CheckFor arecord "--version" + CheckFor arp "" + CheckFor at "" + CheckFor attrib "" + CheckFor awk "--version" + CheckFor b2sum "--version" + CheckFor base32 "--version" + CheckFor base64 "--version" + CheckFor basename "--version" + CheckFor basenc "--version" + CheckFor bash "--version" + CheckFor bc "--version" + CheckFor bunzip2 "--version" + CheckFor bzcat "--version" + CheckFor bzip2 "--version" + CheckFor bzip2recover "--version" + CheckFor captoinfo "--version" + CheckFor cat "-version" + CheckFor cc "--version" + CheckFor chattr "--version" + CheckFor chcon "--version" + CheckFor chdsk "" + CheckFor chgrp "--version" + CheckFor chmod "--version" + CheckFor chkntfs "" + CheckFor chown "--version" + CheckFor chroot "--version" + CheckFor choco "--version" + CheckFor cipher "" + CheckFor cksum "--version" + CheckFor clang "--version" + CheckFor clear "--version" + CheckFor cmake "--version" + CheckFor cmd "" + CheckFor cmp "--version" + CheckFor column "--version" + CheckFor comp "" + CheckFor compact "" + CheckFor cp "--version" + CheckFor cpack "--version" + CheckFor csplit "--version" + CheckFor ctest "--version" + CheckFor curl "--version" + CheckFor cut "--version" + CheckFor cygcheck "--version" + CheckFor cygpath "--version" + CheckFor d2u "--version" + CheckFor dash "--version" + CheckFor date "" + CheckFor dd "--version" + CheckFor df "--version" + CheckFor diff "--version" + CheckFor diff3 "--version" + CheckFor dir "--version" + CheckFor dircolors "--version" + CheckFor dirname "--version" + CheckFor dism "" + CheckFor dos2unix "--version" + CheckFor driverquery "" + CheckFor du "--version" + CheckFor echo "--version" + CheckFor egrep "--version" + CheckFor env "--version" + CheckFor ex "--version" + CheckFor expand "--version" + CheckFor expr "--version" + CheckFor factor "--version" + CheckFor false "--version" + CheckFor fido2-assert "--version" + CheckFor fido2-cred "--version" + CheckFor fido2-token "--version" + CheckFor file "--version" + CheckFor find "--version" + CheckFor fgrep "--version" + CheckFor fmt "--version" + CheckFor fold "--version" + CheckFor ftp "--version" + CheckFor funzip "--version" + CheckFor gawk "--version" + CheckFor gencat "--version" + CheckFor getconf "--version" + CheckFor getopt "--version" + CheckFor gettext "--version" + CheckFor gcc "--version" + CheckFor gdb "--version" + CheckFor gh "--version" + CheckFor git "--version" + CheckFor gkill "--version" + CheckFor gmondump "--version" + CheckFor gpg "--version" + CheckFor gpg-agent "--version" + CheckFor gpgconf "--version" + CheckFor gpg-error "--version" + CheckFor gpgsplit "--version" + CheckFor gpgtar "--version" + CheckFor grep "--version" + CheckFor groups "--version" + CheckFor gzip "--version" + CheckFor head "--version" + CheckFor hcsdiag "" + CheckFor help "--version" + CheckFor hmac256 "--version" + CheckFor hostid "--version" + CheckFor hostname "" + CheckFor htop "--version" + CheckFor iconv "--version" + CheckFor id "--version" + CheckFor ipfs "--version" + CheckFor java "--version" + CheckFor join "--version" + CheckFor kill "--version" + CheckFor ldd "--version" + CheckFor less "--version" + CheckFor link "--version" + CheckFor ln "--version" + CheckFor locale "--version" + CheckFor locate "--version" + CheckFor logname "--version" + CheckFor ls "--version" + CheckFor lsattr "--version" + CheckFor lsb_release "" + CheckFor lzma "--version" + CheckFor mac2unix "--version" + CheckFor make "--version" + CheckFor md5sum "--version" + CheckFor minidumper "--version" + CheckFor mkdir "--version" + CheckFor mkfifo "--version" + CheckFor mkgroup "--version" + CheckFor mknod "--version" + CheckFor mkpasswd "--version" + CheckFor mktemp "--version" + CheckFor mount "--version" + CheckFor MpCmdRun "-h" + CheckFor netsh "" + CheckFor netstat "" + CheckFor nice "--version" + CheckFor nohup "--version" + CheckFor nroff "--version" + CheckFor nslookup "" + CheckFor openssl "" + CheckFor passwd "--version" + CheckFor paste "--version" + CheckFor perl "--version" + CheckFor ping "-V" + CheckFor ping6 "-V" + CheckFor pip "--version" + CheckFor pip3 "--version" + CheckFor pip3.8 "--version" + CheckFor powercfg "/?" + CheckFor powershell "--version" + CheckFor print "" + CheckFor printf "--version" + CheckFor python "--version" + CheckFor python3 "--version" + CheckFor python3.8 "--version" + CheckFor rasdial "--version" + CheckFor regedit "--version" + CheckFor replace "--version" + CheckFor robocopy "--version" + CheckFor route "" + CheckFor rsh "" + CheckFor rsync "--version" + CheckFor rundll32 "--version" + CheckFor scp "" + CheckFor sftp "" + CheckFor sh "--version" + CheckFor sha1sum "--version" + CheckFor sha256sum "--version" + CheckFor sha512sum "--version" + CheckFor ssh "" + CheckFor ssh-keygen "" + CheckFor sort "--version" + CheckFor split "--version" + CheckFor strace "--version" + CheckFor strings "--version" + CheckFor strip "--version" + CheckFor sudo "--version" + CheckFor systeminfo "" + CheckFor tail "--version" + CheckFor tar "--version" + CheckFor taskkill "" + CheckFor tasklist "" + CheckFor tee "--version" + CheckFor time "" + CheckFor timeout "" + CheckFor top "-v" + CheckFor tskill "" + CheckFor typeperf "" + CheckFor tzsync "--version" + CheckFor uniq "--version" + CheckFor vi "--version" + CheckFor vim "--version" + CheckFor vulkaninfo "--version" + CheckFor w32tm "/?" + CheckFor waitfor "--version" + CheckFor wakeonlan "" + CheckFor wget "--version" + CheckFor where "--version" + CheckFor whatis "--version" + CheckFor which "" + CheckFor winget "--version" + CheckFor winsat "" + CheckFor whoami "--version" + CheckFor wput "--version" + CheckFor write "" + CheckFor wsl "--version" + CheckFor xcopy "--version" + CheckFor yes "--version" + CheckFor zip "--version" + CheckFor zipcloak "--version" + CheckFor zipdetails "" + CheckFor zipgrep "" + CheckFor zipinfo "" + CheckFor zipnote "" + CheckFor zipsplit "" + CheckFor zsh "--version" +} + +try { + ListTools | Format-Table -property @{e='Name';width=12},@{e='Version';width=15},@{e='Path';width=70},@{e='FileSize';width=10} + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-cli-tools.ps1* diff --git a/Docs/list-clipboard.md b/Docs/list-clipboard.md index ee14c22e..43466e83 100644 --- a/Docs/list-clipboard.md +++ b/Docs/list-clipboard.md @@ -1,4 +1,4 @@ -## list-clipboard.ps1 - Lists the contents of the clipboard +## The list-clipboard.ps1 PowerShell Script This PowerShell script lists the contents of the clipboard. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the contents of the clipboard +.DESCRIPTION + This PowerShell script lists the contents of the clipboard. +.EXAMPLE + PS> ./list-clipboard +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "๐Ÿ“‹ $(get-clipboard)" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-clipboard.ps1* diff --git a/Docs/list-cmdlets.md b/Docs/list-cmdlets.md index 28b82170..c825a17c 100644 --- a/Docs/list-cmdlets.md +++ b/Docs/list-cmdlets.md @@ -1,4 +1,4 @@ -## list-cmdlets.ps1 - Lists all PowerShell cmdlets +## The list-cmdlets.ps1 PowerShell Script This PowerShell script lists all PowerShell cmdlets. @@ -31,4 +31,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all PowerShell cmdlets +.DESCRIPTION + This PowerShell script lists all PowerShell cmdlets. +.EXAMPLE + PS> ./list-cmdlets + + CommandType Name Version Source + ----------- ---- ------- ------ + Function Add-BCDataCacheExtension 1.0.0.0 BranchCache + Function Add-BitLockerKeyProtector 1.0.0.0 BitLocker + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-Command -Command-Type cmdlet + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-cmdlets.ps1* diff --git a/Docs/list-commit-statistics.md b/Docs/list-commit-statistics.md index eb19d88e..202b95c9 100644 --- a/Docs/list-commit-statistics.md +++ b/Docs/list-commit-statistics.md @@ -1,4 +1,4 @@ -## list-commit-statistics.ps1 - Lists the commit statistics of a Git repository +## The list-commit-statistics.ps1 PowerShell Script This PowerShell script lists the commit statistics of a Git repository. @@ -34,4 +34,49 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the commit statistics of a Git repository +.DESCRIPTION + This PowerShell script lists the commit statistics of a Git repository. +.PARAMETER RepoDir + Specifies the path to the Git repository. +.EXAMPLE + PS> ./list-commit-statistics + 1720 Markus Fleschutz + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RepoDir = "$PWD") + +try { + Write-Progress "โณ Step 1/4 - Searching for Git executable..." + $null = (git --version) + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + $RepoDirName = (Get-Item "$RepoDir").Name + Write-Progress "โณ Step 2/4 - Checking folder ๐Ÿ“‚$RepoDirName..." + if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + + Write-Progress "โณ Step 3/4 - Fetching updates..." + & git -C "$RepoDir" fetch --all --quiet + if ($lastExitCode -ne "0") { throw "'git fetch' failed with exit code $lastExitCode" } + + Write-Progress "โณ Step 4/4 - Querying commits..." + " " + "Commits Author" + "------- ------" + git -C "$RepoDir" shortlog --summary --numbered --email --no-merges + if ($lastExitCode -ne "0") { throw "'git shortlog' failed with exit code $lastExitCode" } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-commit-statistics.ps1* diff --git a/Docs/list-commits.md b/Docs/list-commits.md index 86c6804b..094be78b 100644 --- a/Docs/list-commits.md +++ b/Docs/list-commits.md @@ -1,4 +1,4 @@ -## list-commits.ps1 - Lists all commits in a Git repository +## The list-commits.ps1 PowerShell Script This PowerShell script lists all commits in a Git repository. Supported output formats are: list, compact, normal or JSON. @@ -49,4 +49,66 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all commits in a Git repository +.DESCRIPTION + This PowerShell script lists all commits in a Git repository. Supported output formats are: list, compact, normal or JSON. +.PARAMETER RepoDir + Specifies the path to the Git repository. +.PARAMETER Format + Specifies the output format: list|compact|normal|JSON +.EXAMPLE + PS> ./list-commits + + ID Date Committer Description + -- ---- --------- ----------- + ccd0d3e Wed Sep 29 08:28:20 2021 +0200 Markus Fleschutz Fix typo + 291d785 Wed Sep 29 08:18:28 2021 +0200 Markus Fleschutz Update README.md + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RepoDir = "$PWD", [string]$Format = "list") + +try { + if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + + $Null = (git --version) + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + write-progress "๐Ÿขƒ Fetching latest tags..." + & git -C "$RepoDir" fetch --all --quiet + if ($lastExitCode -ne "0") { throw "'git fetch' failed" } + + if ($Format -eq "list") { + "" + "ID Date Committer Description" + "-- ---- --------- -----------" + & git log --pretty=format:"%h%x09%ad%x09%an%x09%s" + } elseif ($Format -eq "compact") { + "" + "List of Git Commits" + "-------------------" + & git -C "$RepoDir" log --graph --pretty=format:'%Cred%h%Creset%C(yellow)%d%Creset %s %C(bold blue)by %an %cr%Creset' --abbrev-commit + if ($lastExitCode -ne "0") { throw "'git log' failed" } + } elseif ($Format -eq "JSON") { + & git -C "$RepoDir" log --pretty=format:'{%n "commit": "%H",%n "abbreviated_commit": "%h",%n "tree": "%T",%n "abbreviated_tree": "%t",%n "parent": "%P",%n "abbreviated_parent": "%p",%n "refs": "%D",%n "encoding": "%e",%n "subject": "%s",%n "sanitized_subject_line": "%f",%n "body": "%b",%n "commit_notes": "%N",%n "verification_flag": "%G?",%n "signer": "%GS",%n "signer_key": "%GK",%n "author": {%n "name": "%aN",%n "email": "%aE",%n "date": "%aD"%n },%n "commiter": {%n "name": "%cN",%n "email": "%cE",%n "date": "%cD"%n }%n},' + } else { + "" + "List of Git Commits" + "-------------------" + & git -C "$RepoDir" log + if ($lastExitCode -ne "0") { throw "'git log' failed" } + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-commits.ps1* diff --git a/Docs/list-console-colors.md b/Docs/list-console-colors.md index ca16f401..0cb40d88 100644 --- a/Docs/list-console-colors.md +++ b/Docs/list-console-colors.md @@ -1,4 +1,4 @@ -## list-console-colors.ps1 - Lists all console colors +## The list-console-colors.ps1 PowerShell Script This PowerShell script lists all available console colors. @@ -29,4 +29,41 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all console colors +.DESCRIPTION + This PowerShell script lists all available console colors. +.EXAMPLE + PS> ./list-console-colors + + Color As Foreground As Background + ----- ------------- ------------- + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Colors = [Enum]::GetValues([ConsoleColor]) + "" + "Color As Foreground As Background" + "----- ------------- -------------" + foreach($Color in $Colors) { + $Color = "$Color " + $Color = $Color.substring(0, 15) + write-host -noNewline "$Color" + write-host -noNewline -foregroundcolor $Color "$Color" + write-host -noNewline -backgroundcolor $Color "$Color" + write-host "" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-console-colors.ps1* diff --git a/Docs/list-countries.md b/Docs/list-countries.md index d82cd6b6..2b6e2900 100644 --- a/Docs/list-countries.md +++ b/Docs/list-countries.md @@ -1,4 +1,6 @@ -## list-countries.ps1 - list-countries.ps1 +## The list-countries.ps1 PowerShell Script + +list-countries.ps1 ## Parameters @@ -10,4 +12,39 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Lists details of all countries +.DESCRIPTION + This PowerShell script lists details of all countries. +.EXAMPLE + PS> ./list-countries +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function ListCountries { + $Countries = (Invoke-WebRequest -uri "https://restcountries.eu/rest/v2/all" -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json + foreach($Country in $Countries) { + New-Object PSObject -Property @{ + 'Country' = "$($Country.Name)" + 'Capital' = "$($Country.Capital)" + 'Population' = "$($Country.Population)" + 'TLD' = "$($Country.TopLevelDomain)" + 'Phone' = "+$($Country.CallingCodes)" + } + } +} + +try { + ListCountries | format-table -property Country,Capital,Population,TLD,Phone + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-countries.ps1* diff --git a/Docs/list-cpu.md b/Docs/list-cpu.md index dc4f290a..d846d80b 100644 --- a/Docs/list-cpu.md +++ b/Docs/list-cpu.md @@ -1,4 +1,4 @@ -## list-cpu.ps1 - Lists CPU details +## The list-cpu.ps1 PowerShell Script This PowerShell script lists the CPU details. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists CPU details +.DESCRIPTION + This PowerShell script lists the CPU details. +.EXAMPLE + PS> ./list-cpu +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-WmiObject -Class Win32_Processor + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-cpu.ps1* diff --git a/Docs/list-credits.md b/Docs/list-credits.md index cc19a18a..fc39a5b8 100644 --- a/Docs/list-credits.md +++ b/Docs/list-credits.md @@ -1,4 +1,4 @@ -## list-credits.ps1 - Shows the credits for the PowerShell Scripts +## The list-credits.ps1 PowerShell Script This PowerShell script shows the credits for the PowerShell Scripts. @@ -23,4 +23,53 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Shows the credits for the PowerShell Scripts +.DESCRIPTION + This PowerShell script shows the credits for the PowerShell Scripts. +.EXAMPLE + PS> ./list-credits +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + clear-host + "" + " ______ ______ ______ _____ __ ______ ______ " + " /\ ___\ /\ == \ /\ ___\ /\ __-. /\ \ /\__ _\ /\ ___\ " + " \ \ \____ \ \ __< \ \ __\ \ \ \/\ \ \ \ \ \/_/\ \/ \ \___ \ " + " \ \_____\ \ \_\ \_\ \ \_____\ \ \____- \ \_\ \ \_\ \/\_____\ " + " \/_____/ \/_/ /_/ \/_____/ \/____/ \/_/ \/_/ \/_____/ " + "" + + & "$PSScriptRoot/write-animated.ps1" "Typos: Markus Fleschutz" + & "$PSScriptRoot/write-animated.ps1" "Keyboard: Rapoo 12335 E9270P WL Ultra-Slim Touch" + & "$PSScriptRoot/write-animated.ps1" "Operating Systems: Windows 10 20H2 & Ubuntu Server 20.04 LTS" + & "$PSScriptRoot/write-animated.ps1" "Console: Windows Terminal 1.7.1033.0" + & "$PSScriptRoot/write-animated.ps1" "Background Image: Asteroid Field by starwars.com" + & "$PSScriptRoot/write-animated.ps1" "Shell: PowerShell 5.1 & PowerShell 7.1.3" + & "$PSScriptRoot/write-animated.ps1" "Scripts: PowerShell Scripts 0.2" + & "$PSScriptRoot/write-animated.ps1" "GitHub: github.com/fleschutz/PowerShell" + & "$PSScriptRoot/write-animated.ps1" "Git: version 2.30" + & "$PSScriptRoot/write-animated.ps1" "SSH: OpenSSH version 7.7p1" + & "$PSScriptRoot/write-animated.ps1" "Unicode: version 13.0" + & "$PSScriptRoot/write-animated.ps1" "Song #1: Epic Song by BoxCat Games from Free Music Archive" + & "$PSScriptRoot/write-animated.ps1" "Song #2: Siesta by Jahzzar from Free Music Archive" + & "$PSScriptRoot/write-animated.ps1" "Executive Producer: Markus Fleschutz" + & "$PSScriptRoot/write-animated.ps1" "Special Thanks: Andrea Fleschutz" + & "$PSScriptRoot/write-animated.ps1" "Copyright: (c) 2021. All Rights Reserved" + & "$PSScriptRoot/write-animated.ps1" "No Animals Were Harmed in the Making of This Film" + + & "$PSScriptRoot/write-big.ps1" " Thanx 4 watching" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-credits.ps1* diff --git a/Docs/list-crypto-rates.md b/Docs/list-crypto-rates.md index 2624b383..9bcf306b 100644 --- a/Docs/list-crypto-rates.md +++ b/Docs/list-crypto-rates.md @@ -1,4 +1,6 @@ -## list-crypto-rates.ps1 - list-crypto-rates.ps1 +## The list-crypto-rates.ps1 PowerShell Script + +list-crypto-rates.ps1 ## Parameters @@ -10,4 +12,57 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Lists crypto exchange rates +.DESCRIPTION + This PowerShell script queries and lists the current crypto exchange rates from cryptocompare.com. +.EXAMPLE + PS> ./list-crypto-rates +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function ListCryptoRate { param([string]$Symbol, [string]$Name) + $Rates = (Invoke-WebRequest -URI "https://min-api.cryptocompare.com/data/price?fsym=$Symbol&tsyms=USD,EUR,RUB,CNY" -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json + New-Object PSObject -property @{ 'Cryptocurrency' = "1 $Name ($Symbol) ="; 'USD' = "$($Rates.USD)"; 'EUR' = "$($Rates.EUR)"; 'RUB' = "$($Rates.RUB)"; 'CNY' = "$($Rates.CNY)" } +} + +function ListCryptoRates { + ListCryptoRate BTC "Bitcoin" + ListCryptoRate ETH "Ethereum" + ListCryptoRate ADA "Cardano" + ListCryptoRate BNB "Binance Coin" + ListCryptoRate USDT "Tether" + ListCryptoRate XRP "XRP" + ListCryptoRate DOGE "Dogecoin" + ListCryptoRate USDC "USD Coin" + ListCryptoRate DOT "Polkadot" + ListCryptoRate SOL "Solana" + ListCryptoRate UNI "Uniswap" + ListCryptoRate BUSD "Binance USD" + ListCryptoRate BCH "Bitcoin Cash" + ListCryptoRate LTC "Litecoin" + ListCryptoRate LINK "Chainlink" + ListCryptoRate LUNA "Terra" + ListCryptoRate ICP "Internet Computer" + ListCryptoRate WBTC "Wrapped Bitcoin" + ListCryptoRate MATIC "Polygon" + ListCryptoRate XLM "Stellar" +} + +try { + " " + "Current Crypto Exchange Rates by cryptocompare.com" + "==================================================" + ListCryptoRates | Format-Table -property @{e='Cryptocurrency';width=28},USD,EUR,RUB,CNY + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-crypto-rates.ps1* diff --git a/Docs/list-dir-tree.md b/Docs/list-dir-tree.md index 9720e892..51de1d00 100644 --- a/Docs/list-dir-tree.md +++ b/Docs/list-dir-tree.md @@ -1,4 +1,4 @@ -## list-dir-tree.ps1 - Lists the directory tree content +## The list-dir-tree.ps1 PowerShell Script This PowerShell script lists all files and folders in a directory tree. @@ -32,4 +32,53 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the directory tree content +.DESCRIPTION + This PowerShell script lists all files and folders in a directory tree. +.PARAMETER DirTree + Specifies the path to the directory tree +.EXAMPLE + PS> ./list-dir-tree C:\ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$DirTree = "$PWD") + +function ListDir { param([string]$Directory, [int]$Depth) + $Depth++ + $Items = Get-ChildItem -path $Directory + foreach($Item in $Items) { + $Filename = $Item.Name + for ($i = 1; $i -lt $Depth; $i++) { Write-Host "โ”‚ " -noNewline } + if ($Item.Mode -like "d*") { + Write-Host "โ”œโ”€" -noNewline + Write-Host -foregroundColor green "๐Ÿ“‚$Filename" + ListDir "$Directory\$Filename" $Depth + $global:Dirs++ + } else { + Write-Host "โ”œ $Filename ($($Item.Length) bytes)" + $global:Files++ + $global:Bytes += $Item.Length + } + } +} + +try { + [int]$global:Dirs = 1 + [int]$global:Files = 0 + [int]$global:Bytes = 0 + ListDir $DirTree 0 + "($($global:Dirs) folders, $($global:Files) files, $($global:Bytes) bytes total)" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-dir-tree.ps1* diff --git a/Docs/list-drives.md b/Docs/list-drives.md index 40b0502c..b4f0ee55 100644 --- a/Docs/list-drives.md +++ b/Docs/list-drives.md @@ -1,4 +1,4 @@ -## list-drives.ps1 - Lists all drives +## The list-drives.ps1 PowerShell Script This PowerShell script lists all local drives as a table. @@ -29,4 +29,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all drives +.DESCRIPTION + This PowerShell script lists all local drives as a table. +.EXAMPLE + PS> ./list-drives + + Name Root Used (GB) Free (GB) + ---- ---- --------- --------- + C C:\ 6648,1 744,2 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-PSDrive -PSProvider FileSystem | format-table -property Name,Root,@{n="Used (GB)";e={[math]::Round($_.Used/1GB,1)}},@{n="Free (GB)";e={[math]::Round($_.Free/1GB,1)}} + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-drives.ps1* diff --git a/Docs/list-earthquakes.md b/Docs/list-earthquakes.md index 7b976a20..78b7a066 100644 --- a/Docs/list-earthquakes.md +++ b/Docs/list-earthquakes.md @@ -1,4 +1,4 @@ -## list-earthquakes.ps1 - Lists major earthquakes +## The list-earthquakes.ps1 PowerShell Script This PowerShell script lists major earthquakes with magnitude >= 6.0 for the last 30 days. @@ -23,4 +23,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists major earthquakes +.DESCRIPTION + This PowerShell script lists major earthquakes with magnitude >= 6.0 for the last 30 days. +.EXAMPLE + PS> ./list-earthquakes +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +$Format="csv" # cap, csv, geojson, kml, kmlraw, quakeml, text, xml +$MinMagnitude=5.8 +$OrderBy="magnitude" # time, time-asc, magnitude, magnitude-asc + +function ListEarthquakes { + Write-Progress "Loading data from earthquake.usgs.gov..." + $Quakes = (Invoke-WebRequest -URI "https://earthquake.usgs.gov/fdsnws/event/1/query?format=$Format&minmagnitude=$MinMagnitude&orderby=$OrderBy" -userAgent "curl" -useBasicParsing).Content | ConvertFrom-CSV + foreach ($Quake in $Quakes) { + [int]$Depth = $Quake.depth + New-Object PSObject -Property @{ Mag=$Quake.mag; Depth="$Depth km"; Location=$Quake.place; Time=$Quake.time } + } +} + +try { + ListEarthquakes | Format-Table -property @{e='Mag';width=5},@{e='Location';width=42},@{e='Depth';width=12},Time + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-earthquakes.ps1* diff --git a/Docs/list-emojis.md b/Docs/list-emojis.md index cfc4b202..6ebac0c3 100644 --- a/Docs/list-emojis.md +++ b/Docs/list-emojis.md @@ -1,4 +1,4 @@ -## list-emojis.ps1 - Lists available Emojis +## The list-emojis.ps1 PowerShell Script This PowerShell script lists the emojis of Unicode 13.0 sorted by category. @@ -23,4 +23,45 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists available Emojis +.DESCRIPTION + This PowerShell script lists the emojis of Unicode 13.0 sorted by category. +.EXAMPLE + PS> ./list-emojis +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +"Emojis of Unicode 13.0 sorted by Category" +"=========================================" +"" +"Smileys: ๐Ÿ˜€ ๐Ÿ˜ ๐Ÿ˜‚ ๐Ÿคฃ ๐Ÿ˜ƒ ๐Ÿ˜„ ๐Ÿ˜… ๐Ÿ˜† ๐Ÿ˜‰ ๐Ÿ˜Š ๐Ÿ˜‹ ๐Ÿ˜Ž ๐Ÿ˜ ๐Ÿ˜˜ ๐Ÿฅฐ ๐Ÿ˜— ๐Ÿ˜™ ๐Ÿ˜š โ˜บ๏ธ ๐Ÿ™‚ ๐Ÿค— ๐Ÿคฉ ๐Ÿค” ๐Ÿคจ ๐Ÿ˜ ๐Ÿ˜‘ ๐Ÿ˜ถ ๐Ÿ™„ ๐Ÿ˜ ๐Ÿ˜ฃ ๐Ÿ˜ฅ ๐Ÿ˜ฎ ๐Ÿค ๐Ÿ˜ฏ ๐Ÿ˜ช ๐Ÿ˜ซ ๐Ÿ˜ด ๐Ÿ˜Œ ๐Ÿ˜› ๐Ÿ˜œ ๐Ÿ˜ ๐Ÿคค ๐Ÿ˜’ ๐Ÿ˜“ ๐Ÿ˜” ๐Ÿ˜• ๐Ÿ™ƒ ๐Ÿค‘ ๐Ÿ˜ฒ โ˜น๏ธ ๐Ÿ™ ๐Ÿ˜– ๐Ÿ˜ž ๐Ÿ˜Ÿ ๐Ÿ˜ค ๐Ÿ˜ข ๐Ÿ˜ญ ๐Ÿ˜ฆ ๐Ÿ˜ง ๐Ÿ˜จ ๐Ÿ˜ฉ ๐Ÿคฏ ๐Ÿ˜ฌ ๐Ÿ˜ฐ ๐Ÿ˜ฑ ๐Ÿฅต ๐Ÿฅถ ๐Ÿ˜ณ ๐Ÿคช ๐Ÿ˜ต ๐Ÿ˜ก ๐Ÿ˜  ๐Ÿคฌ ๐Ÿ˜ท ๐Ÿค’ ๐Ÿค• ๐Ÿคข ๐Ÿคฎ ๐Ÿคง ๐Ÿ˜‡ ๐Ÿค  ๐Ÿคก ๐Ÿฅณ ๐Ÿฅด ๐Ÿฅบ ๐Ÿคฅ ๐Ÿคซ ๐Ÿคญ ๐Ÿง ๐Ÿค“ ๐Ÿ˜ˆ ๐Ÿ‘ฟ ๐Ÿ‘น ๐Ÿ‘บ ๐Ÿ’€ ๐Ÿ‘ป ๐Ÿ‘ฝ ๐Ÿค– ๐Ÿ’ฉ ๐Ÿ˜บ ๐Ÿ˜ธ ๐Ÿ˜น ๐Ÿ˜ป ๐Ÿ˜ผ ๐Ÿ˜ฝ ๐Ÿ™€ ๐Ÿ˜ฟ ๐Ÿ˜พ" +"" +"People: ๐Ÿ‘ถ ๐Ÿ‘ง ๐Ÿง’ ๐Ÿ‘ฆ ๐Ÿ‘ฉ ๐Ÿง‘ ๐Ÿ‘จ ๐Ÿ‘ต ๐Ÿง“ ๐Ÿ‘ด ๐Ÿ‘ฒ ๐Ÿ‘ณโ€โ™€๏ธ ๐Ÿ‘ณโ€โ™‚๏ธ ๐Ÿง• ๐Ÿง” ๐Ÿ‘ฑโ€โ™‚๏ธ ๐Ÿ‘ฑโ€โ™€๏ธ ๐Ÿ‘จโ€๐Ÿฆฐ ๐Ÿ‘ฉโ€๐Ÿฆฐ ๐Ÿ‘จโ€๐Ÿฆฑ ๐Ÿ‘ฉโ€๐Ÿฆฑ ๐Ÿ‘จโ€๐Ÿฆฒ ๐Ÿ‘ฉโ€๐Ÿฆฒ ๐Ÿ‘จโ€๐Ÿฆณ ๐Ÿ‘ฉโ€๐Ÿฆณ ๐Ÿฆธโ€โ™€๏ธ ๐Ÿฆธโ€โ™‚๏ธ ๐Ÿฆนโ€โ™€๏ธ ๐Ÿฆนโ€โ™‚๏ธ ๐Ÿ‘ฎโ€โ™€๏ธ ๐Ÿ‘ฎโ€โ™‚๏ธ ๐Ÿ‘ทโ€โ™€๏ธ ๐Ÿ‘ทโ€โ™‚๏ธ ๐Ÿ’‚โ€โ™€๏ธ ๐Ÿ’‚โ€โ™‚๏ธ ๐Ÿ•ต๏ธโ€โ™€๏ธ ๐Ÿ•ต๏ธโ€โ™‚๏ธ ๐Ÿ‘ฉโ€โš•๏ธ ๐Ÿ‘จโ€โš•๏ธ ๐Ÿ‘ฉโ€๐ŸŒพ ๐Ÿ‘จโ€๐ŸŒพ ๐Ÿ‘ฉโ€๐Ÿณ ๐Ÿ‘จโ€๐Ÿณ ๐Ÿ‘ฉโ€๐ŸŽ“ ๐Ÿ‘จโ€๐ŸŽ“ ๐Ÿ‘ฉโ€๐ŸŽค ๐Ÿ‘จโ€๐ŸŽค ๐Ÿ‘ฉโ€๐Ÿซ ๐Ÿ‘จโ€๐Ÿซ ๐Ÿ‘ฉโ€๐Ÿญ ๐Ÿ‘จโ€๐Ÿญ ๐Ÿ‘ฉโ€๐Ÿ’ป ๐Ÿ‘จโ€๐Ÿ’ป ๐Ÿ‘ฉโ€๐Ÿ’ผ ๐Ÿ‘จโ€๐Ÿ’ผ ๐Ÿ‘ฉโ€๐Ÿ”ง ๐Ÿ‘จโ€๐Ÿ”ง ๐Ÿ‘ฉโ€๐Ÿ”ฌ ๐Ÿ‘จโ€๐Ÿ”ฌ ๐Ÿ‘ฉโ€๐ŸŽจ ๐Ÿ‘จโ€๐ŸŽจ ๐Ÿ‘ฉโ€๐Ÿš’ ๐Ÿ‘จโ€๐Ÿš’ ๐Ÿ‘ฉโ€โœˆ๏ธ ๐Ÿ‘จโ€โœˆ๏ธ ๐Ÿ‘ฉโ€๐Ÿš€ ๐Ÿ‘จโ€๐Ÿš€ ๐Ÿ‘ฉโ€โš–๏ธ ๐Ÿ‘จโ€โš–๏ธ ๐Ÿ‘ฐ ๐Ÿคต ๐Ÿ‘ธ ๐Ÿคด ๐Ÿคถ ๐ŸŽ… ๐Ÿง™โ€โ™€๏ธ ๐Ÿง™โ€โ™‚๏ธ ๐Ÿงโ€โ™€๏ธ ๐Ÿงโ€โ™‚๏ธ ๐Ÿง›โ€โ™€๏ธ ๐Ÿง›โ€โ™‚๏ธ ๐ŸงŸโ€โ™€๏ธ ๐ŸงŸโ€โ™‚๏ธ ๐Ÿงžโ€โ™€๏ธ ๐Ÿงžโ€โ™‚๏ธ ๐Ÿงœโ€โ™€๏ธ ๐Ÿงœโ€โ™‚๏ธ ๐Ÿงšโ€โ™€๏ธ ๐Ÿงšโ€โ™‚๏ธ ๐Ÿ‘ผ ๐Ÿคฐ ๐Ÿคฑ ๐Ÿ™‡โ€โ™€๏ธ ๐Ÿ™‡โ€โ™‚๏ธ ๐Ÿ’โ€โ™€๏ธ ๐Ÿ’โ€โ™‚๏ธ ๐Ÿ™…โ€โ™€๏ธ ๐Ÿ™…โ€โ™‚๏ธ ๐Ÿ™†โ€โ™€๏ธ ๐Ÿ™†โ€โ™‚๏ธ ๐Ÿ™‹โ€โ™€๏ธ ๐Ÿ™‹โ€โ™‚๏ธ ๐Ÿคฆโ€โ™€๏ธ ๐Ÿคฆโ€โ™‚๏ธ ๐Ÿคทโ€โ™€๏ธ ๐Ÿคทโ€โ™‚๏ธ ๐Ÿ™Žโ€โ™€๏ธ ๐Ÿ™Žโ€โ™‚๏ธ ๐Ÿ™โ€โ™€๏ธ ๐Ÿ™โ€โ™‚๏ธ ๐Ÿ’‡โ€โ™€๏ธ ๐Ÿ’‡โ€โ™‚๏ธ ๐Ÿ’†โ€โ™€๏ธ ๐Ÿ’†โ€โ™‚๏ธ ๐Ÿง–โ€โ™€๏ธ ๐Ÿง–โ€โ™‚๏ธ ๐Ÿ’… ๐Ÿคณ ๐Ÿ’ƒ ๐Ÿ•บ ๐Ÿ‘ฏโ€โ™€๏ธ ๐Ÿ‘ฏโ€โ™‚๏ธ ๐Ÿ•ด ๐Ÿšถโ€โ™€๏ธ ๐Ÿšถโ€โ™‚๏ธ ๐Ÿƒโ€โ™€๏ธ ๐Ÿƒโ€โ™‚๏ธ ๐Ÿ‘ซ ๐Ÿ‘ญ ๐Ÿ‘ฌ ๐Ÿ’‘ ๐Ÿ‘ฉโ€โค๏ธโ€๐Ÿ‘ฉ ๐Ÿ‘จโ€โค๏ธโ€๐Ÿ‘จ ๐Ÿ’ ๐Ÿ‘ฉโ€โค๏ธโ€๐Ÿ’‹โ€๐Ÿ‘ฉ ๐Ÿ‘จโ€โค๏ธโ€๐Ÿ’‹โ€๐Ÿ‘จ ๐Ÿ‘ช ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ง ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ฆโ€๐Ÿ‘ฆ ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ง ๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘ฆ ๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘ง ๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ ๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘ฆโ€๐Ÿ‘ฆ ๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ง ๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘ฆ ๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘ง ๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ ๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘ฆโ€๐Ÿ‘ฆ ๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ง ๐Ÿ‘ฉโ€๐Ÿ‘ฆ ๐Ÿ‘ฉโ€๐Ÿ‘ง ๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ ๐Ÿ‘ฉโ€๐Ÿ‘ฆโ€๐Ÿ‘ฆ ๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ง ๐Ÿ‘จโ€๐Ÿ‘ฆ ๐Ÿ‘จโ€๐Ÿ‘ง ๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ฆ ๐Ÿ‘จโ€๐Ÿ‘ฆโ€๐Ÿ‘ฆ ๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ง ๐Ÿคฒ ๐Ÿ‘ ๐Ÿ™Œ ๐Ÿ‘ ๐Ÿค ๐Ÿ‘ ๐Ÿ‘Ž ๐Ÿ‘Š โœŠ ๐Ÿค› ๐Ÿคœ ๐Ÿคž โœŒ๏ธ ๐ŸคŸ ๐Ÿค˜ ๐Ÿ‘Œ ๐Ÿ‘ˆ ๐Ÿ‘‰ ๐Ÿ‘† ๐Ÿ‘‡ โ˜๏ธ โœ‹ ๐Ÿคš ๐Ÿ– ๐Ÿ–– ๐Ÿ‘‹ ๐Ÿค™ ๐Ÿ’ช ๐Ÿฆต ๐Ÿฆถ ๐Ÿ–• โœ๏ธ ๐Ÿ™ ๐Ÿ’ ๐Ÿ’„ ๐Ÿ’‹ ๐Ÿ‘„ ๐Ÿ‘… ๐Ÿ‘‚ ๐Ÿ‘ƒ ๐Ÿ‘ฃ ๐Ÿ‘ ๐Ÿ‘€ ๐Ÿง  ๐Ÿฆด ๐Ÿฆท ๐Ÿ—ฃ ๐Ÿ‘ค ๐Ÿ‘ฅ" +"" +"Clothings & Accessoires: ๐Ÿงฅ ๐Ÿ‘š ๐Ÿ‘• ๐Ÿ‘– ๐Ÿ‘” ๐Ÿ‘— ๐Ÿ‘™ ๐Ÿ‘˜ ๐Ÿ‘  ๐Ÿ‘ก ๐Ÿ‘ข ๐Ÿ‘ž ๐Ÿ‘Ÿ ๐Ÿฅพ ๐Ÿฅฟ ๐Ÿงฆ ๐Ÿงค ๐Ÿงฃ ๐ŸŽฉ ๐Ÿงข ๐Ÿ‘’ ๐ŸŽ“ โ›‘ ๐Ÿ‘‘ ๐Ÿ‘ ๐Ÿ‘› ๐Ÿ‘œ ๐Ÿ’ผ ๐ŸŽ’ ๐Ÿ‘“ ๐Ÿ•ถ ๐Ÿฅฝ ๐Ÿฅผ ๐ŸŒ‚ ๐Ÿงต ๐Ÿงถ" +"" +"Animals & Nature: ๐Ÿถ ๐Ÿฑ ๐Ÿญ ๐Ÿน ๐Ÿฐ ๐ŸฆŠ ๐Ÿฆ ๐Ÿป ๐Ÿผ ๐Ÿฆ˜ ๐Ÿฆก ๐Ÿจ ๐Ÿฏ ๐Ÿฆ ๐Ÿฎ ๐Ÿท ๐Ÿฝ ๐Ÿธ ๐Ÿต ๐Ÿ™ˆ ๐Ÿ™‰ ๐Ÿ™Š ๐Ÿ’ ๐Ÿ” ๐Ÿง ๐Ÿฆ ๐Ÿค ๐Ÿฃ ๐Ÿฅ ๐Ÿฆ† ๐Ÿฆข ๐Ÿฆ… ๐Ÿฆ‰ ๐Ÿฆš ๐Ÿฆœ ๐Ÿฆ‡ ๐Ÿบ ๐Ÿ— ๐Ÿด ๐Ÿฆ„ ๐Ÿ ๐Ÿ› ๐Ÿฆ‹ ๐ŸŒ ๐Ÿš ๐Ÿž ๐Ÿœ ๐Ÿฆ— ๐Ÿ•ท ๐Ÿ•ธ ๐Ÿฆ‚ ๐ŸฆŸ ๐Ÿฆ  ๐Ÿข ๐Ÿ ๐ŸฆŽ ๐Ÿฆ– ๐Ÿฆ• ๐Ÿ™ ๐Ÿฆ‘ ๐Ÿฆ ๐Ÿฆ€ ๐Ÿก ๐Ÿ  ๐ŸŸ ๐Ÿฌ ๐Ÿณ ๐Ÿ‹ ๐Ÿฆˆ ๐ŸŠ ๐Ÿ… ๐Ÿ† ๐Ÿฆ“ ๐Ÿฆ ๐Ÿ˜ ๐Ÿฆ ๐Ÿฆ› ๐Ÿช ๐Ÿซ ๐Ÿฆ™ ๐Ÿฆ’ ๐Ÿƒ ๐Ÿ‚ ๐Ÿ„ ๐ŸŽ ๐Ÿ– ๐Ÿ ๐Ÿ‘ ๐Ÿ ๐ŸฆŒ ๐Ÿ• ๐Ÿฉ ๐Ÿˆ ๐Ÿ“ ๐Ÿฆƒ ๐Ÿ•Š ๐Ÿ‡ ๐Ÿ ๐Ÿ€ ๐Ÿฟ ๐Ÿฆ” ๐Ÿพ ๐Ÿ‰ ๐Ÿฒ ๐ŸŒต ๐ŸŽ„ ๐ŸŒฒ ๐ŸŒณ ๐ŸŒด ๐ŸŒฑ ๐ŸŒฟ โ˜˜๏ธ ๐Ÿ€ ๐ŸŽ ๐ŸŽ‹ ๐Ÿƒ ๐Ÿ‚ ๐Ÿ ๐Ÿ„ ๐ŸŒพ ๐Ÿ’ ๐ŸŒท ๐ŸŒน ๐Ÿฅ€ ๐ŸŒบ ๐ŸŒธ ๐ŸŒผ ๐ŸŒป ๐ŸŒž ๐ŸŒ ๐ŸŒ› ๐ŸŒœ ๐ŸŒš ๐ŸŒ• ๐ŸŒ– ๐ŸŒ— ๐ŸŒ˜ ๐ŸŒ‘ ๐ŸŒ’ ๐ŸŒ“ ๐ŸŒ” ๐ŸŒ™ ๐ŸŒŽ ๐ŸŒ ๐ŸŒ ๐Ÿ’ซ โญ๏ธ ๐ŸŒŸ โœจ โšก๏ธ โ˜„๏ธ ๐Ÿ’ฅ ๐Ÿ”ฅ ๐ŸŒช ๐ŸŒˆ โ˜€๏ธ ๐ŸŒค โ›…๏ธ ๐ŸŒฅ โ˜๏ธ ๐ŸŒฆ ๐ŸŒง โ›ˆ ๐ŸŒฉ ๐ŸŒจ โ„๏ธ โ˜ƒ๏ธ โ›„๏ธ ๐ŸŒฌ ๐Ÿ’จ ๐Ÿ’ง ๐Ÿ’ฆ โ˜”๏ธ โ˜‚๏ธ ๐ŸŒŠ ๐ŸŒซ" +"" +"Foods & Drinks: ๐Ÿ ๐ŸŽ ๐Ÿ ๐ŸŠ ๐Ÿ‹ ๐ŸŒ ๐Ÿ‰ ๐Ÿ‡ ๐Ÿ“ ๐Ÿˆ ๐Ÿ’ ๐Ÿ‘ ๐Ÿ ๐Ÿฅญ ๐Ÿฅฅ ๐Ÿฅ ๐Ÿ… ๐Ÿ† ๐Ÿฅ‘ ๐Ÿฅฆ ๐Ÿฅ’ ๐Ÿฅฌ ๐ŸŒถ ๐ŸŒฝ ๐Ÿฅ• ๐Ÿฅ” ๐Ÿ  ๐Ÿฅ ๐Ÿž ๐Ÿฅ– ๐Ÿฅจ ๐Ÿฅฏ ๐Ÿง€ ๐Ÿฅš ๐Ÿณ ๐Ÿฅž ๐Ÿฅ“ ๐Ÿฅฉ ๐Ÿ— ๐Ÿ– ๐ŸŒญ ๐Ÿ” ๐ŸŸ ๐Ÿ• ๐Ÿฅช ๐Ÿฅ™ ๐ŸŒฎ ๐ŸŒฏ ๐Ÿฅ— ๐Ÿฅ˜ ๐Ÿฅซ ๐Ÿ ๐Ÿœ ๐Ÿฒ ๐Ÿ› ๐Ÿฃ ๐Ÿฑ ๐ŸฅŸ ๐Ÿค ๐Ÿ™ ๐Ÿš ๐Ÿ˜ ๐Ÿฅ ๐Ÿฅฎ ๐Ÿฅ  ๐Ÿข ๐Ÿก ๐Ÿง ๐Ÿจ ๐Ÿฆ ๐Ÿฅง ๐Ÿฐ ๐ŸŽ‚ ๐Ÿฎ ๐Ÿญ ๐Ÿฌ ๐Ÿซ ๐Ÿฟ ๐Ÿง‚ ๐Ÿฉ ๐Ÿช ๐ŸŒฐ ๐Ÿฅœ ๐Ÿฏ ๐Ÿฅ› ๐Ÿผ โ˜•๏ธ ๐Ÿต ๐Ÿฅค ๐Ÿถ ๐Ÿบ ๐Ÿป ๐Ÿฅ‚ ๐Ÿท ๐Ÿฅƒ ๐Ÿธ ๐Ÿน ๐Ÿพ ๐Ÿฅ„ ๐Ÿด ๐Ÿฝ ๐Ÿฅฃ ๐Ÿฅก ๐Ÿฅข" +"" +"Sport & Hobbby: โšฝ๏ธ ๐Ÿ€ ๐Ÿˆ โšพ๏ธ ๐ŸฅŽ ๐Ÿ ๐Ÿ‰ ๐ŸŽพ ๐Ÿฅ ๐ŸŽฑ ๐Ÿ“ ๐Ÿธ ๐Ÿฅ… ๐Ÿ’ ๐Ÿ‘ ๐Ÿฅ ๐Ÿ โ›ณ๏ธ ๐Ÿน ๐ŸŽฃ ๐ŸฅŠ ๐Ÿฅ‹ ๐ŸŽฝ โ›ธ ๐ŸฅŒ ๐Ÿ›ท ๐Ÿ›น ๐ŸŽฟ โ›ท ๐Ÿ‚ ๐Ÿ‹๏ธโ€โ™€๏ธ ๐Ÿ‹๐Ÿปโ€โ™€๏ธ ๐Ÿ‹๐Ÿผโ€โ™€๏ธ ๐Ÿ‹๐Ÿฝโ€โ™€๏ธ ๐Ÿ‹๐Ÿพโ€โ™€๏ธ ๐Ÿ‹๐Ÿฟโ€โ™€๏ธ ๐Ÿ‹๏ธโ€โ™‚๏ธ ๐Ÿ‹๐Ÿปโ€โ™‚๏ธ ๐Ÿ‹๐Ÿผโ€โ™‚๏ธ ๐Ÿ‹๐Ÿฝโ€โ™‚๏ธ ๐Ÿ‹๐Ÿพโ€โ™‚๏ธ ๐Ÿ‹๐Ÿฟโ€โ™‚๏ธ ๐Ÿคผโ€โ™€๏ธ ๐Ÿคผโ€โ™‚๏ธ ๐Ÿคธโ€โ™€๏ธ ๐Ÿคธ๐Ÿปโ€โ™€๏ธ ๐Ÿคธ๐Ÿผโ€โ™€๏ธ ๐Ÿคธ๐Ÿฝโ€โ™€๏ธ ๐Ÿคธ๐Ÿพโ€โ™€๏ธ ๐Ÿคธ๐Ÿฟโ€โ™€๏ธ ๐Ÿคธโ€โ™‚๏ธ ๐Ÿคธ๐Ÿปโ€โ™‚๏ธ ๐Ÿคธ๐Ÿผโ€โ™‚๏ธ ๐Ÿคธ๐Ÿฝโ€โ™‚๏ธ ๐Ÿคธ๐Ÿพโ€โ™‚๏ธ ๐Ÿคธ๐Ÿฟโ€โ™‚๏ธ โ›น๏ธโ€โ™€๏ธ โ›น๐Ÿปโ€โ™€๏ธ โ›น๐Ÿผโ€โ™€๏ธ โ›น๐Ÿฝโ€โ™€๏ธ โ›น๐Ÿพโ€โ™€๏ธ โ›น๐Ÿฟโ€โ™€๏ธ โ›น๏ธโ€โ™‚๏ธ โ›น๐Ÿปโ€โ™‚๏ธ โ›น๐Ÿผโ€โ™‚๏ธ โ›น๐Ÿฝโ€โ™‚๏ธ โ›น๐Ÿพโ€โ™‚๏ธ โ›น๐Ÿฟโ€โ™‚๏ธ ๐Ÿคบ ๐Ÿคพโ€โ™€๏ธ ๐Ÿคพ๐Ÿปโ€โ™€๏ธ ๐Ÿคพ๐Ÿผโ€โ™€๏ธ ๐Ÿคพ๐Ÿพโ€โ™€๏ธ ๐Ÿคพ๐Ÿพโ€โ™€๏ธ ๐Ÿคพ๐Ÿฟโ€โ™€๏ธ ๐Ÿคพโ€โ™‚๏ธ ๐Ÿคพ๐Ÿปโ€โ™‚๏ธ ๐Ÿคพ๐Ÿผโ€โ™‚๏ธ ๐Ÿคพ๐Ÿฝโ€โ™‚๏ธ ๐Ÿคพ๐Ÿพโ€โ™‚๏ธ ๐Ÿคพ๐Ÿฟโ€โ™‚๏ธ ๐ŸŒ๏ธโ€โ™€๏ธ ๐ŸŒ๐Ÿปโ€โ™€๏ธ ๐ŸŒ๐Ÿผโ€โ™€๏ธ ๐ŸŒ๐Ÿฝโ€โ™€๏ธ ๐ŸŒ๐Ÿพโ€โ™€๏ธ ๐ŸŒ๐Ÿฟโ€โ™€๏ธ ๐ŸŒ๏ธโ€โ™‚๏ธ ๐ŸŒ๐Ÿปโ€โ™‚๏ธ ๐ŸŒ๐Ÿผโ€โ™‚๏ธ ๐ŸŒ๐Ÿฝโ€โ™‚๏ธ ๐ŸŒ๐Ÿพโ€โ™‚๏ธ ๐ŸŒ๐Ÿฟโ€โ™‚๏ธ ๐Ÿ‡ ๐Ÿ‡๐Ÿป ๐Ÿ‡๐Ÿผ ๐Ÿ‡๐Ÿฝ ๐Ÿ‡๐Ÿพ ๐Ÿ‡๐Ÿฟ ๐Ÿง˜โ€โ™€๏ธ ๐Ÿง˜๐Ÿปโ€โ™€๏ธ ๐Ÿง˜๐Ÿผโ€โ™€๏ธ ๐Ÿง˜๐Ÿฝโ€โ™€๏ธ ๐Ÿง˜๐Ÿพโ€โ™€๏ธ ๐Ÿง˜๐Ÿฟโ€โ™€๏ธ ๐Ÿง˜โ€โ™‚๏ธ ๐Ÿง˜๐Ÿปโ€โ™‚๏ธ ๐Ÿง˜๐Ÿผโ€โ™‚๏ธ ๐Ÿง˜๐Ÿฝโ€โ™‚๏ธ ๐Ÿง˜๐Ÿพโ€โ™‚๏ธ ๐Ÿง˜๐Ÿฟโ€โ™‚๏ธ ๐Ÿ„โ€โ™€๏ธ ๐Ÿ„๐Ÿปโ€โ™€๏ธ ๐Ÿ„๐Ÿผโ€โ™€๏ธ ๐Ÿ„๐Ÿฝโ€โ™€๏ธ ๐Ÿ„๐Ÿพโ€โ™€๏ธ ๐Ÿ„๐Ÿฟโ€โ™€๏ธ ๐Ÿ„โ€โ™‚๏ธ ๐Ÿ„๐Ÿปโ€โ™‚๏ธ ๐Ÿ„๐Ÿผโ€โ™‚๏ธ ๐Ÿ„๐Ÿฝโ€โ™‚๏ธ ๐Ÿ„๐Ÿพโ€โ™‚๏ธ ๐Ÿ„๐Ÿฟโ€โ™‚๏ธ ๐ŸŠโ€โ™€๏ธ ๐ŸŠ๐Ÿปโ€โ™€๏ธ ๐ŸŠ๐Ÿผโ€โ™€๏ธ ๐ŸŠ๐Ÿฝโ€โ™€๏ธ ๐ŸŠ๐Ÿพโ€โ™€๏ธ ๐ŸŠ๐Ÿฟโ€โ™€๏ธ ๐ŸŠโ€โ™‚๏ธ ๐ŸŠ๐Ÿปโ€โ™‚๏ธ ๐ŸŠ๐Ÿผโ€โ™‚๏ธ ๐ŸŠ๐Ÿฝโ€โ™‚๏ธ ๐ŸŠ๐Ÿพโ€โ™‚๏ธ ๐ŸŠ๐Ÿฟโ€โ™‚๏ธ ๐Ÿคฝโ€โ™€๏ธ ๐Ÿคฝ๐Ÿปโ€โ™€๏ธ ๐Ÿคฝ๐Ÿผโ€โ™€๏ธ ๐Ÿคฝ๐Ÿฝโ€โ™€๏ธ ๐Ÿคฝ๐Ÿพโ€โ™€๏ธ ๐Ÿคฝ๐Ÿฟโ€โ™€๏ธ ๐Ÿคฝโ€โ™‚๏ธ ๐Ÿคฝ๐Ÿปโ€โ™‚๏ธ ๐Ÿคฝ๐Ÿผโ€โ™‚๏ธ ๐Ÿคฝ๐Ÿฝโ€โ™‚๏ธ ๐Ÿคฝ๐Ÿพโ€โ™‚๏ธ ๐Ÿคฝ๐Ÿฟโ€โ™‚๏ธ ๐Ÿšฃโ€โ™€๏ธ ๐Ÿšฃ๐Ÿปโ€โ™€๏ธ ๐Ÿšฃ๐Ÿผโ€โ™€๏ธ ๐Ÿšฃ๐Ÿฝโ€โ™€๏ธ ๐Ÿšฃ๐Ÿพโ€โ™€๏ธ ๐Ÿšฃ๐Ÿฟโ€โ™€๏ธ ๐Ÿšฃโ€โ™‚๏ธ ๐Ÿšฃ๐Ÿปโ€โ™‚๏ธ ๐Ÿšฃ๐Ÿผโ€โ™‚๏ธ ๐Ÿšฃ๐Ÿฝโ€โ™‚๏ธ ๐Ÿšฃ๐Ÿพโ€โ™‚๏ธ ๐Ÿšฃ๐Ÿฟโ€โ™‚๏ธ ๐Ÿง—โ€โ™€๏ธ ๐Ÿง—๐Ÿปโ€โ™€๏ธ ๐Ÿง—๐Ÿผโ€โ™€๏ธ ๐Ÿง—๐Ÿฝโ€โ™€๏ธ ๐Ÿง—๐Ÿพโ€โ™€๏ธ ๐Ÿง—๐Ÿฟโ€โ™€๏ธ ๐Ÿง—โ€โ™‚๏ธ ๐Ÿง—๐Ÿปโ€โ™‚๏ธ ๐Ÿง—๐Ÿผโ€โ™‚๏ธ ๐Ÿง—๐Ÿฝโ€โ™‚๏ธ ๐Ÿง—๐Ÿพโ€โ™‚๏ธ ๐Ÿง—๐Ÿฟโ€โ™‚๏ธ ๐Ÿšตโ€โ™€๏ธ ๐Ÿšต๐Ÿปโ€โ™€๏ธ ๐Ÿšต๐Ÿผโ€โ™€๏ธ ๐Ÿšต๐Ÿฝโ€โ™€๏ธ ๐Ÿšต๐Ÿพโ€โ™€๏ธ ๐Ÿšต๐Ÿฟโ€โ™€๏ธ ๐Ÿšตโ€โ™‚๏ธ ๐Ÿšต๐Ÿปโ€โ™‚๏ธ ๐Ÿšต๐Ÿผโ€โ™‚๏ธ ๐Ÿšต๐Ÿฝโ€โ™‚๏ธ ๐Ÿšต๐Ÿพโ€โ™‚๏ธ ๐Ÿšต๐Ÿฟโ€โ™‚๏ธ ๐Ÿšดโ€โ™€๏ธ ๐Ÿšด๐Ÿปโ€โ™€๏ธ ๐Ÿšด๐Ÿผโ€โ™€๏ธ ๐Ÿšด๐Ÿฝโ€โ™€๏ธ ๐Ÿšด๐Ÿพโ€โ™€๏ธ ๐Ÿšด๐Ÿฟโ€โ™€๏ธ ๐Ÿšดโ€โ™‚๏ธ ๐Ÿšด๐Ÿปโ€โ™‚๏ธ ๐Ÿšด๐Ÿผโ€โ™‚๏ธ ๐Ÿšด๐Ÿฝโ€โ™‚๏ธ ๐Ÿšด๐Ÿพโ€โ™‚๏ธ ๐Ÿšด๐Ÿฟโ€โ™‚๏ธ ๐Ÿ† ๐Ÿฅ‡ ๐Ÿฅˆ ๐Ÿฅ‰ ๐Ÿ… ๐ŸŽ– ๐Ÿต ๐ŸŽ— ๐ŸŽซ ๐ŸŽŸ ๐ŸŽช ๐Ÿคนโ€โ™€๏ธ ๐Ÿคน๐Ÿปโ€โ™€๏ธ ๐Ÿคน๐Ÿผโ€โ™€๏ธ ๐Ÿคน๐Ÿฝโ€โ™€๏ธ ๐Ÿคน๐Ÿพโ€โ™€๏ธ ๐Ÿคน๐Ÿฟโ€โ™€๏ธ ๐Ÿคนโ€โ™‚๏ธ ๐Ÿคน๐Ÿปโ€โ™‚๏ธ ๐Ÿคน๐Ÿผโ€โ™‚๏ธ ๐Ÿคน๐Ÿฝโ€โ™‚๏ธ ๐Ÿคน๐Ÿพโ€โ™‚๏ธ ๐Ÿคน๐Ÿฟโ€โ™‚๏ธ ๐ŸŽญ ๐ŸŽจ ๐ŸŽฌ ๐ŸŽค ๐ŸŽง ๐ŸŽผ ๐ŸŽน ๐Ÿฅ ๐ŸŽท ๐ŸŽบ ๐ŸŽธ ๐ŸŽป ๐ŸŽฒ ๐Ÿงฉ โ™Ÿ ๐ŸŽฏ ๐ŸŽณ ๐ŸŽฎ ๐ŸŽฐ" +"" +"Travel & Locations: ๐Ÿš— ๐Ÿš• ๐Ÿš™ ๐ŸšŒ ๐ŸšŽ ๐ŸŽ ๐Ÿš“ ๐Ÿš‘ ๐Ÿš’ ๐Ÿš ๐Ÿšš ๐Ÿš› ๐Ÿšœ ๐Ÿ›ด ๐Ÿšฒ ๐Ÿ›ต ๐Ÿ ๐Ÿšจ ๐Ÿš” ๐Ÿš ๐Ÿš˜ ๐Ÿš– ๐Ÿšก ๐Ÿš  ๐ŸšŸ ๐Ÿšƒ ๐Ÿš‹ ๐Ÿšž ๐Ÿš ๐Ÿš„ ๐Ÿš… ๐Ÿšˆ ๐Ÿš‚ ๐Ÿš† ๐Ÿš‡ ๐ŸšŠ ๐Ÿš‰ โœˆ๏ธ ๐Ÿ›ซ ๐Ÿ›ฌ ๐Ÿ›ฉ ๐Ÿ’บ ๐Ÿ›ฐ ๐Ÿš€ ๐Ÿ›ธ ๐Ÿš ๐Ÿ›ถ โ›ต๏ธ ๐Ÿšค ๐Ÿ›ฅ ๐Ÿ›ณ โ›ด ๐Ÿšข โš“๏ธ โ›ฝ๏ธ ๐Ÿšง ๐Ÿšฆ ๐Ÿšฅ ๐Ÿš ๐Ÿ—บ ๐Ÿ—ฟ ๐Ÿ—ฝ ๐Ÿ—ผ ๐Ÿฐ ๐Ÿฏ ๐ŸŸ ๐ŸŽก ๐ŸŽข ๐ŸŽ  โ›ฒ๏ธ โ›ฑ ๐Ÿ– ๐Ÿ ๐Ÿœ ๐ŸŒ‹ โ›ฐ ๐Ÿ” ๐Ÿ—ป ๐Ÿ• โ›บ๏ธ ๐Ÿ  ๐Ÿก ๐Ÿ˜ ๐Ÿš ๐Ÿ— ๐Ÿญ ๐Ÿข ๐Ÿฌ ๐Ÿฃ ๐Ÿค ๐Ÿฅ ๐Ÿฆ ๐Ÿจ ๐Ÿช ๐Ÿซ ๐Ÿฉ ๐Ÿ’’ ๐Ÿ› โ›ช๏ธ ๐Ÿ•Œ ๐Ÿ• ๐Ÿ•‹ โ›ฉ ๐Ÿ›ค ๐Ÿ›ฃ ๐Ÿ—พ ๐ŸŽ‘ ๐Ÿž ๐ŸŒ… ๐ŸŒ„ ๐ŸŒ  ๐ŸŽ‡ ๐ŸŽ† ๐ŸŒ‡ ๐ŸŒ† ๐Ÿ™ ๐ŸŒƒ ๐ŸŒŒ ๐ŸŒ‰ ๐ŸŒ" +"" +"Objects: โŒš๏ธ ๐Ÿ“ฑ ๐Ÿ“ฒ ๐Ÿ’ป โŒจ๏ธ ๐Ÿ–ฅ ๐Ÿ–จ ๐Ÿ–ฑ ๐Ÿ–ฒ ๐Ÿ•น ๐Ÿ—œ ๐Ÿ’ฝ ๐Ÿ’พ ๐Ÿ’ฟ ๐Ÿ“€ ๐Ÿ“ผ ๐Ÿ“ท ๐Ÿ“ธ ๐Ÿ“น ๐ŸŽฅ ๐Ÿ“ฝ ๐ŸŽž ๐Ÿ“ž โ˜Ž๏ธ ๐Ÿ“Ÿ ๐Ÿ“  ๐Ÿ“บ ๐Ÿ“ป ๐ŸŽ™ ๐ŸŽš ๐ŸŽ› โฑ โฒ โฐ ๐Ÿ•ฐ โŒ›๏ธ โณ ๐Ÿ“ก ๐Ÿ”‹ ๐Ÿ”Œ ๐Ÿ’ก ๐Ÿ”ฆ ๐Ÿ•ฏ ๐Ÿ—‘ ๐Ÿ›ข ๐Ÿ’ธ ๐Ÿ’ต ๐Ÿ’ด ๐Ÿ’ถ ๐Ÿ’ท ๐Ÿ’ฐ ๐Ÿ’ณ ๐Ÿงพ ๐Ÿ’Ž โš–๏ธ ๐Ÿ”ง ๐Ÿ”จ โš’ ๐Ÿ›  โ› ๐Ÿ”ฉ โš™๏ธ โ›“ ๐Ÿ”ซ ๐Ÿ’ฃ ๐Ÿ”ช ๐Ÿ—ก โš”๏ธ ๐Ÿ›ก ๐Ÿšฌ โšฐ๏ธ โšฑ๏ธ ๐Ÿบ ๐Ÿงญ ๐Ÿงฑ ๐Ÿ”ฎ ๐Ÿงฟ ๐Ÿงธ ๐Ÿ“ฟ ๐Ÿ’ˆ โš—๏ธ ๐Ÿ”ญ ๐Ÿงฐ ๐Ÿงฒ ๐Ÿงช ๐Ÿงซ ๐Ÿงฌ ๐Ÿงฏ ๐Ÿ”ฌ ๐Ÿ•ณ ๐Ÿ’Š ๐Ÿ’‰ ๐ŸŒก ๐Ÿšฝ ๐Ÿšฐ ๐Ÿšฟ ๐Ÿ› ๐Ÿ›€ ๐Ÿ›€๐Ÿป ๐Ÿ›€๐Ÿผ ๐Ÿ›€๐Ÿฝ ๐Ÿ›€๐Ÿพ ๐Ÿ›€๐Ÿฟ ๐Ÿงด ๐Ÿงต ๐Ÿงถ ๐Ÿงท ๐Ÿงน ๐Ÿงบ ๐Ÿงป ๐Ÿงผ ๐Ÿงฝ ๐Ÿ›Ž ๐Ÿ”‘ ๐Ÿ— ๐Ÿšช ๐Ÿ›‹ ๐Ÿ› ๐Ÿ›Œ ๐Ÿ–ผ ๐Ÿ› ๐Ÿงณ ๐Ÿ›’ ๐ŸŽ ๐ŸŽˆ ๐ŸŽ ๐ŸŽ€ ๐ŸŽŠ ๐ŸŽ‰ ๐Ÿงจ ๐ŸŽŽ ๐Ÿฎ ๐ŸŽ ๐Ÿงง โœ‰๏ธ ๐Ÿ“ฉ ๐Ÿ“จ ๐Ÿ“ง ๐Ÿ’Œ ๐Ÿ“ฅ ๐Ÿ“ค ๐Ÿ“ฆ ๐Ÿท ๐Ÿ“ช ๐Ÿ“ซ ๐Ÿ“ฌ ๐Ÿ“ญ ๐Ÿ“ฎ ๐Ÿ“ฏ ๐Ÿ“œ ๐Ÿ“ƒ ๐Ÿ“„ ๐Ÿ“‘ ๐Ÿ“Š ๐Ÿ“ˆ ๐Ÿ“‰ ๐Ÿ—’ ๐Ÿ—“ ๐Ÿ“† ๐Ÿ“… ๐Ÿ“‡ ๐Ÿ—ƒ ๐Ÿ—ณ ๐Ÿ—„ ๐Ÿ“‹ ๐Ÿ“ ๐Ÿ“‚ ๐Ÿ—‚ ๐Ÿ—ž ๐Ÿ“ฐ ๐Ÿ““ ๐Ÿ“” ๐Ÿ“’ ๐Ÿ“• ๐Ÿ“— ๐Ÿ“˜ ๐Ÿ“™ ๐Ÿ“š ๐Ÿ“– ๐Ÿ”– ๐Ÿ”— ๐Ÿ“Ž ๐Ÿ–‡ ๐Ÿ“ ๐Ÿ“ ๐Ÿ“Œ ๐Ÿ“ โœ‚๏ธ ๐Ÿ–Š ๐Ÿ–‹ โœ’๏ธ ๐Ÿ–Œ ๐Ÿ– ๐Ÿ“ โœ๏ธ ๐Ÿ” ๐Ÿ”Ž ๐Ÿ” ๐Ÿ” ๐Ÿ”’ ๐Ÿ”“" +"" +"Symbols: โค๏ธ ๐Ÿงก ๐Ÿ’› ๐Ÿ’š ๐Ÿ’™ ๐Ÿ’œ ๐Ÿ–ค ๐Ÿ’” โฃ๏ธ ๐Ÿ’• ๐Ÿ’ž ๐Ÿ’“ ๐Ÿ’— ๐Ÿ’– ๐Ÿ’˜ ๐Ÿ’ ๐Ÿ’Ÿ โ˜ฎ๏ธ โœ๏ธ โ˜ช๏ธ ๐Ÿ•‰ โ˜ธ๏ธ โœก๏ธ ๐Ÿ”ฏ ๐Ÿ•Ž โ˜ฏ๏ธ โ˜ฆ๏ธ ๐Ÿ› โ›Ž โ™ˆ๏ธ โ™‰๏ธ โ™Š๏ธ โ™‹๏ธ โ™Œ๏ธ โ™๏ธ โ™Ž๏ธ โ™๏ธ โ™๏ธ โ™‘๏ธ โ™’๏ธ โ™“๏ธ ๐Ÿ†” โš›๏ธ ๐Ÿ‰‘ โ˜ข๏ธ โ˜ฃ๏ธ ๐Ÿ“ด ๐Ÿ“ณ ๐Ÿˆถ ๐Ÿˆš๏ธ ๐Ÿˆธ ๐Ÿˆบ ๐Ÿˆท๏ธ โœด๏ธ ๐Ÿ†š ๐Ÿ’ฎ ๐Ÿ‰ ใŠ™๏ธ ใŠ—๏ธ ๐Ÿˆด ๐Ÿˆต ๐Ÿˆน ๐Ÿˆฒ ๐Ÿ…ฐ๏ธ ๐Ÿ…ฑ๏ธ ๐Ÿ†Ž ๐Ÿ†‘ ๐Ÿ…พ๏ธ ๐Ÿ†˜ โŒ โญ•๏ธ ๐Ÿ›‘ โ›”๏ธ ๐Ÿ“› ๐Ÿšซ ๐Ÿ’ฏ ๐Ÿ’ข โ™จ๏ธ ๐Ÿšท ๐Ÿšฏ ๐Ÿšณ ๐Ÿšฑ ๐Ÿ”ž ๐Ÿ“ต ๐Ÿšญ โ—๏ธ โ• โ“ โ” โ€ผ๏ธ โ‰๏ธ ๐Ÿ”… ๐Ÿ”† ใ€ฝ๏ธ โš ๏ธ ๐Ÿšธ ๐Ÿ”ฑ โšœ๏ธ ๐Ÿ”ฐ โ™ป๏ธ โœ… ๐Ÿˆฏ๏ธ ๐Ÿ’น โ‡๏ธ โœณ๏ธ โŽ ๐ŸŒ ๐Ÿ’  โ“‚๏ธ ๐ŸŒ€ ๐Ÿ’ค ๐Ÿง ๐Ÿšพ โ™ฟ๏ธ ๐Ÿ…ฟ๏ธ ๐Ÿˆณ ๐Ÿˆ‚๏ธ ๐Ÿ›‚ ๐Ÿ›ƒ ๐Ÿ›„ ๐Ÿ›… ๐Ÿšน ๐Ÿšบ ๐Ÿšผ ๐Ÿšป ๐Ÿšฎ ๐ŸŽฆ ๐Ÿ“ถ ๐Ÿˆ ๐Ÿ”ฃ โ„น๏ธ ๐Ÿ”ค ๐Ÿ”ก ๐Ÿ”  ๐Ÿ†– ๐Ÿ†— ๐Ÿ†™ ๐Ÿ†’ ๐Ÿ†• ๐Ÿ†“ 0๏ธโƒฃ 1๏ธโƒฃ 2๏ธโƒฃ 3๏ธโƒฃ 4๏ธโƒฃ 5๏ธโƒฃ 6๏ธโƒฃ 7๏ธโƒฃ 8๏ธโƒฃ 9๏ธโƒฃ ๐Ÿ”Ÿ ๐Ÿ”ข #๏ธโƒฃ *๏ธโƒฃ โ๏ธ โ–ถ๏ธ โธ โฏ โน โบ โญ โฎ โฉ โช โซ โฌ โ—€๏ธ ๐Ÿ”ผ ๐Ÿ”ฝ โžก๏ธ โฌ…๏ธ โฌ†๏ธ โฌ‡๏ธ โ†—๏ธ โ†˜๏ธ โ†™๏ธ โ†–๏ธ โ†•๏ธ โ†”๏ธ โ†ช๏ธ โ†ฉ๏ธ โคด๏ธ โคต๏ธ ๐Ÿ”€ ๐Ÿ” ๐Ÿ”‚ ๐Ÿ”„ ๐Ÿ”ƒ ๐ŸŽต ๐ŸŽถ โž• โž– โž— โœ–๏ธ โ™พ ๐Ÿ’ฒ ๐Ÿ’ฑ โ„ข๏ธ ยฉ๏ธ ยฎ๏ธ ใ€ฐ๏ธ โžฐ โžฟ ๐Ÿ”š ๐Ÿ”™ ๐Ÿ”› ๐Ÿ” ๐Ÿ”œ โœ”๏ธ โ˜‘๏ธ ๐Ÿ”˜ โšช๏ธ โšซ๏ธ ๐Ÿ”ด ๐Ÿ”ต ๐Ÿ”บ ๐Ÿ”ป ๐Ÿ”ธ ๐Ÿ”น ๐Ÿ”ถ ๐Ÿ”ท ๐Ÿ”ณ ๐Ÿ”ฒ โ–ช๏ธ โ–ซ๏ธ โ—พ๏ธ โ—ฝ๏ธ โ—ผ๏ธ โ—ป๏ธ โฌ›๏ธ โฌœ๏ธ ๐Ÿ”ˆ ๐Ÿ”‡ ๐Ÿ”‰ ๐Ÿ”Š ๐Ÿ”” ๐Ÿ”• ๐Ÿ“ฃ ๐Ÿ“ข ๐Ÿ‘โ€๐Ÿ—จ ๐Ÿ’ฌ ๐Ÿ’ญ ๐Ÿ—ฏ โ™ ๏ธ โ™ฃ๏ธ โ™ฅ๏ธ โ™ฆ๏ธ ๐Ÿƒ ๐ŸŽด ๐Ÿ€„๏ธ ๐Ÿ• ๐Ÿ•‘ ๐Ÿ•’ ๐Ÿ•“ ๐Ÿ•” ๐Ÿ•• ๐Ÿ•– ๐Ÿ•— ๐Ÿ•˜ ๐Ÿ•™ ๐Ÿ•š ๐Ÿ•› ๐Ÿ•œ ๐Ÿ• ๐Ÿ•ž ๐Ÿ•Ÿ ๐Ÿ•  ๐Ÿ•ก ๐Ÿ•ข ๐Ÿ•ฃ ๐Ÿ•ค ๐Ÿ•ฅ ๐Ÿ•ฆ ๐Ÿ•ง" +"" +"Flags: ๐Ÿณ๏ธ ๐Ÿด ๐Ÿ ๐Ÿšฉ ๐Ÿณ๏ธโ€๐ŸŒˆ ๐Ÿดโ€โ˜ ๏ธ ๐Ÿ‡ฆ๐Ÿ‡ซ ๐Ÿ‡ฆ๐Ÿ‡ฝ ๐Ÿ‡ฆ๐Ÿ‡ฑ ๐Ÿ‡ฉ๐Ÿ‡ฟ ๐Ÿ‡ฆ๐Ÿ‡ธ ๐Ÿ‡ฆ๐Ÿ‡ฉ ๐Ÿ‡ฆ๐Ÿ‡ด ๐Ÿ‡ฆ๐Ÿ‡ฎ ๐Ÿ‡ฆ๐Ÿ‡ถ ๐Ÿ‡ฆ๐Ÿ‡ฌ ๐Ÿ‡ฆ๐Ÿ‡ท ๐Ÿ‡ฆ๐Ÿ‡ฒ ๐Ÿ‡ฆ๐Ÿ‡ผ ๐Ÿ‡ฆ๐Ÿ‡บ ๐Ÿ‡ฆ๐Ÿ‡น ๐Ÿ‡ฆ๐Ÿ‡ฟ ๐Ÿ‡ง๐Ÿ‡ธ ๐Ÿ‡ง๐Ÿ‡ญ ๐Ÿ‡ง๐Ÿ‡ฉ ๐Ÿ‡ง๐Ÿ‡ง ๐Ÿ‡ง๐Ÿ‡พ ๐Ÿ‡ง๐Ÿ‡ช ๐Ÿ‡ง๐Ÿ‡ฟ ๐Ÿ‡ง๐Ÿ‡ฏ ๐Ÿ‡ง๐Ÿ‡ฒ ๐Ÿ‡ง๐Ÿ‡น ๐Ÿ‡ง๐Ÿ‡ด ๐Ÿ‡ง๐Ÿ‡ฆ ๐Ÿ‡ง๐Ÿ‡ผ ๐Ÿ‡ง๐Ÿ‡ท ๐Ÿ‡ฎ๐Ÿ‡ด ๐Ÿ‡ป๐Ÿ‡ฌ ๐Ÿ‡ง๐Ÿ‡ณ ๐Ÿ‡ง๐Ÿ‡ฌ ๐Ÿ‡ง๐Ÿ‡ซ ๐Ÿ‡ง๐Ÿ‡ฎ ๐Ÿ‡ฐ๐Ÿ‡ญ ๐Ÿ‡จ๐Ÿ‡ฒ ๐Ÿ‡จ๐Ÿ‡ฆ ๐Ÿ‡ฎ๐Ÿ‡จ ๐Ÿ‡จ๐Ÿ‡ป ๐Ÿ‡ง๐Ÿ‡ถ ๐Ÿ‡ฐ๐Ÿ‡พ ๐Ÿ‡จ๐Ÿ‡ซ ๐Ÿ‡น๐Ÿ‡ฉ ๐Ÿ‡จ๐Ÿ‡ฑ ๐Ÿ‡จ๐Ÿ‡ณ ๐Ÿ‡จ๐Ÿ‡ฝ ๐Ÿ‡จ๐Ÿ‡จ ๐Ÿ‡จ๐Ÿ‡ด ๐Ÿ‡ฐ๐Ÿ‡ฒ ๐Ÿ‡จ๐Ÿ‡ฌ ๐Ÿ‡จ๐Ÿ‡ฉ ๐Ÿ‡จ๐Ÿ‡ฐ ๐Ÿ‡จ๐Ÿ‡ท ๐Ÿ‡จ๐Ÿ‡ฎ ๐Ÿ‡ญ๐Ÿ‡ท ๐Ÿ‡จ๐Ÿ‡บ ๐Ÿ‡จ๐Ÿ‡ผ ๐Ÿ‡จ๐Ÿ‡พ ๐Ÿ‡จ๐Ÿ‡ฟ ๐Ÿ‡ฉ๐Ÿ‡ฐ ๐Ÿ‡ฉ๐Ÿ‡ฏ ๐Ÿ‡ฉ๐Ÿ‡ฒ ๐Ÿ‡ฉ๐Ÿ‡ด ๐Ÿ‡ช๐Ÿ‡จ ๐Ÿ‡ช๐Ÿ‡ฌ ๐Ÿ‡ธ๐Ÿ‡ป ๐Ÿ‡ฌ๐Ÿ‡ถ ๐Ÿ‡ช๐Ÿ‡ท ๐Ÿ‡ช๐Ÿ‡ช ๐Ÿ‡ช๐Ÿ‡น ๐Ÿ‡ช๐Ÿ‡บ ๐Ÿ‡ซ๐Ÿ‡ฐ ๐Ÿ‡ซ๐Ÿ‡ด ๐Ÿ‡ซ๐Ÿ‡ฏ ๐Ÿ‡ซ๐Ÿ‡ฎ ๐Ÿ‡ซ๐Ÿ‡ท ๐Ÿ‡ฌ๐Ÿ‡ซ ๐Ÿ‡ต๐Ÿ‡ซ ๐Ÿ‡น๐Ÿ‡ซ ๐Ÿ‡ฌ๐Ÿ‡ฆ ๐Ÿ‡ฌ๐Ÿ‡ฒ ๐Ÿ‡ฌ๐Ÿ‡ช ๐Ÿ‡ฉ๐Ÿ‡ช ๐Ÿ‡ฌ๐Ÿ‡ญ ๐Ÿ‡ฌ๐Ÿ‡ฎ ๐Ÿ‡ฌ๐Ÿ‡ท ๐Ÿ‡ฌ๐Ÿ‡ฑ ๐Ÿ‡ฌ๐Ÿ‡ฉ ๐Ÿ‡ฌ๐Ÿ‡ต ๐Ÿ‡ฌ๐Ÿ‡บ ๐Ÿ‡ฌ๐Ÿ‡น ๐Ÿ‡ฌ๐Ÿ‡ฌ ๐Ÿ‡ฌ๐Ÿ‡ณ ๐Ÿ‡ฌ๐Ÿ‡ผ ๐Ÿ‡ฌ๐Ÿ‡พ ๐Ÿ‡ญ๐Ÿ‡น ๐Ÿ‡ญ๐Ÿ‡ณ ๐Ÿ‡ญ๐Ÿ‡ฐ ๐Ÿ‡ญ๐Ÿ‡บ ๐Ÿ‡ฎ๐Ÿ‡ธ ๐Ÿ‡ฎ๐Ÿ‡ณ ๐Ÿ‡ฎ๐Ÿ‡ฉ ๐Ÿ‡ฎ๐Ÿ‡ท ๐Ÿ‡ฎ๐Ÿ‡ถ ๐Ÿ‡ฎ๐Ÿ‡ช ๐Ÿ‡ฎ๐Ÿ‡ฒ ๐Ÿ‡ฎ๐Ÿ‡ฑ ๐Ÿ‡ฎ๐Ÿ‡น ๐Ÿ‡ฏ๐Ÿ‡ฒ ๐Ÿ‡ฏ๐Ÿ‡ต ๐ŸŽŒ ๐Ÿ‡ฏ๐Ÿ‡ช ๐Ÿ‡ฏ๐Ÿ‡ด ๐Ÿ‡ฐ๐Ÿ‡ฟ ๐Ÿ‡ฐ๐Ÿ‡ช ๐Ÿ‡ฐ๐Ÿ‡ฎ ๐Ÿ‡ฝ๐Ÿ‡ฐ ๐Ÿ‡ฐ๐Ÿ‡ผ ๐Ÿ‡ฐ๐Ÿ‡ฌ ๐Ÿ‡ฑ๐Ÿ‡ฆ ๐Ÿ‡ฑ๐Ÿ‡ป ๐Ÿ‡ฑ๐Ÿ‡ง ๐Ÿ‡ฑ๐Ÿ‡ธ ๐Ÿ‡ฑ๐Ÿ‡ท ๐Ÿ‡ฑ๐Ÿ‡พ ๐Ÿ‡ฑ๐Ÿ‡ฎ ๐Ÿ‡ฑ๐Ÿ‡น ๐Ÿ‡ฑ๐Ÿ‡บ ๐Ÿ‡ฒ๐Ÿ‡ด ๐Ÿ‡ฒ๐Ÿ‡ฐ ๐Ÿ‡ฒ๐Ÿ‡ฌ ๐Ÿ‡ฒ๐Ÿ‡ผ ๐Ÿ‡ฒ๐Ÿ‡พ ๐Ÿ‡ฒ๐Ÿ‡ป ๐Ÿ‡ฒ๐Ÿ‡ฑ ๐Ÿ‡ฒ๐Ÿ‡น ๐Ÿ‡ฒ๐Ÿ‡ญ ๐Ÿ‡ฒ๐Ÿ‡ถ ๐Ÿ‡ฒ๐Ÿ‡ท ๐Ÿ‡ฒ๐Ÿ‡บ ๐Ÿ‡พ๐Ÿ‡น ๐Ÿ‡ฒ๐Ÿ‡ฝ ๐Ÿ‡ซ๐Ÿ‡ฒ ๐Ÿ‡ฒ๐Ÿ‡ฉ ๐Ÿ‡ฒ๐Ÿ‡จ ๐Ÿ‡ฒ๐Ÿ‡ณ ๐Ÿ‡ฒ๐Ÿ‡ช ๐Ÿ‡ฒ๐Ÿ‡ธ ๐Ÿ‡ฒ๐Ÿ‡ฆ ๐Ÿ‡ฒ๐Ÿ‡ฟ ๐Ÿ‡ฒ๐Ÿ‡ฒ ๐Ÿ‡ณ๐Ÿ‡ฆ ๐Ÿ‡ณ๐Ÿ‡ท ๐Ÿ‡ณ๐Ÿ‡ต ๐Ÿ‡ณ๐Ÿ‡ฑ ๐Ÿ‡ณ๐Ÿ‡จ ๐Ÿ‡ณ๐Ÿ‡ฟ ๐Ÿ‡ณ๐Ÿ‡ฎ ๐Ÿ‡ณ๐Ÿ‡ช ๐Ÿ‡ณ๐Ÿ‡ฌ ๐Ÿ‡ณ๐Ÿ‡บ ๐Ÿ‡ณ๐Ÿ‡ซ ๐Ÿ‡ฐ๐Ÿ‡ต ๐Ÿ‡ฒ๐Ÿ‡ต ๐Ÿ‡ณ๐Ÿ‡ด ๐Ÿ‡ด๐Ÿ‡ฒ ๐Ÿ‡ต๐Ÿ‡ฐ ๐Ÿ‡ต๐Ÿ‡ผ ๐Ÿ‡ต๐Ÿ‡ธ ๐Ÿ‡ต๐Ÿ‡ฆ ๐Ÿ‡ต๐Ÿ‡ฌ ๐Ÿ‡ต๐Ÿ‡พ ๐Ÿ‡ต๐Ÿ‡ช ๐Ÿ‡ต๐Ÿ‡ญ ๐Ÿ‡ต๐Ÿ‡ณ ๐Ÿ‡ต๐Ÿ‡ฑ ๐Ÿ‡ต๐Ÿ‡น ๐Ÿ‡ต๐Ÿ‡ท ๐Ÿ‡ถ๐Ÿ‡ฆ ๐Ÿ‡ท๐Ÿ‡ช ๐Ÿ‡ท๐Ÿ‡ด ๐Ÿ‡ท๐Ÿ‡บ ๐Ÿ‡ท๐Ÿ‡ผ ๐Ÿ‡ผ๐Ÿ‡ธ ๐Ÿ‡ธ๐Ÿ‡ฒ ๐Ÿ‡ธ๐Ÿ‡ฆ ๐Ÿ‡ธ๐Ÿ‡ณ ๐Ÿ‡ท๐Ÿ‡ธ ๐Ÿ‡ธ๐Ÿ‡จ ๐Ÿ‡ธ๐Ÿ‡ฑ ๐Ÿ‡ธ๐Ÿ‡ฌ ๐Ÿ‡ธ๐Ÿ‡ฝ ๐Ÿ‡ธ๐Ÿ‡ฐ ๐Ÿ‡ธ๐Ÿ‡ฎ ๐Ÿ‡ฌ๐Ÿ‡ธ ๐Ÿ‡ธ๐Ÿ‡ง ๐Ÿ‡ธ๐Ÿ‡ด ๐Ÿ‡ฟ๐Ÿ‡ฆ ๐Ÿ‡ฐ๐Ÿ‡ท ๐Ÿ‡ธ๐Ÿ‡ธ ๐Ÿ‡ช๐Ÿ‡ธ ๐Ÿ‡ฑ๐Ÿ‡ฐ ๐Ÿ‡ง๐Ÿ‡ฑ ๐Ÿ‡ธ๐Ÿ‡ญ ๐Ÿ‡ฐ๐Ÿ‡ณ ๐Ÿ‡ฑ๐Ÿ‡จ ๐Ÿ‡ต๐Ÿ‡ฒ ๐Ÿ‡ป๐Ÿ‡จ ๐Ÿ‡ธ๐Ÿ‡ฉ ๐Ÿ‡ธ๐Ÿ‡ท ๐Ÿ‡ธ๐Ÿ‡ฟ ๐Ÿ‡ธ๐Ÿ‡ช ๐Ÿ‡จ๐Ÿ‡ญ ๐Ÿ‡ธ๐Ÿ‡พ ๐Ÿ‡น๐Ÿ‡ผ ๐Ÿ‡น๐Ÿ‡ฏ ๐Ÿ‡น๐Ÿ‡ฟ ๐Ÿ‡น๐Ÿ‡ญ ๐Ÿ‡น๐Ÿ‡ฑ ๐Ÿ‡น๐Ÿ‡ฌ ๐Ÿ‡น๐Ÿ‡ฐ ๐Ÿ‡น๐Ÿ‡ด ๐Ÿ‡น๐Ÿ‡น ๐Ÿ‡น๐Ÿ‡ณ ๐Ÿ‡น๐Ÿ‡ท ๐Ÿ‡น๐Ÿ‡ฒ ๐Ÿ‡น๐Ÿ‡จ ๐Ÿ‡น๐Ÿ‡ป ๐Ÿ‡ป๐Ÿ‡ฎ ๐Ÿ‡บ๐Ÿ‡ฌ ๐Ÿ‡บ๐Ÿ‡ฆ ๐Ÿ‡ฆ๐Ÿ‡ช ๐Ÿ‡ฌ๐Ÿ‡ง ๐Ÿด๓ ง๓ ข๓ ฅ๓ ฎ๓ ง๓ ฟ ๐Ÿด๓ ง๓ ข๓ ณ๓ ฃ๓ ด๓ ฟ ๐Ÿด๓ ง๓ ข๓ ท๓ ฌ๓ ณ๓ ฟ ๐Ÿ‡บ๐Ÿ‡ณ ๐Ÿ‡บ๐Ÿ‡ธ ๐Ÿ‡บ๐Ÿ‡พ ๐Ÿ‡บ๐Ÿ‡ฟ ๐Ÿ‡ป๐Ÿ‡บ ๐Ÿ‡ป๐Ÿ‡ฆ ๐Ÿ‡ป๐Ÿ‡ช ๐Ÿ‡ป๐Ÿ‡ณ ๐Ÿ‡ผ๐Ÿ‡ซ ๐Ÿ‡ช๐Ÿ‡ญ ๐Ÿ‡พ๐Ÿ‡ช ๐Ÿ‡ฟ๐Ÿ‡ฒ ๐Ÿ‡ฟ๐Ÿ‡ผ" +"" +"Arrows: โ† โ†’ โ†‘ โ†“ โ†” โ†• โ†– โ†— โ†˜ โ†™ โคก โคข โ†š โ†› โ†ฎ โŸต โŸถ โŸท โ‡ฆ โ‡จ โ‡ง โ‡ฉ โฌ„ โ‡ณ โฌ โฌ€ โฌ‚ โฌƒ โฌ… ( โฎ• โžก ) โฌ† โฌ‡ โฌ‰ โฌˆ โฌŠ โฌ‹ โฌŒ โฌ ๐Ÿก ๐Ÿก’ ๐Ÿก‘ ๐Ÿก“ ๐Ÿก” ๐Ÿก• ๐Ÿก– ๐Ÿก— ๐Ÿก˜ ๐Ÿก™ ๐Ÿ น ๐Ÿ ธ ๐Ÿ ป ๐Ÿ บ ๐Ÿก„ ๐Ÿก† ๐Ÿก… ๐Ÿก‡ ๐Ÿ ผ ๐Ÿ พ ๐Ÿ ฝ ๐Ÿ ฟ ๐Ÿก€ ๐Ÿก‚ ๐Ÿก ๐Ÿกƒ ๐Ÿ  ๐Ÿ ’ ๐Ÿ ‘ ๐Ÿ “ ๐Ÿ ” ๐Ÿ – ๐Ÿ • ๐Ÿ — ๐Ÿ ˜ ๐Ÿ š ๐Ÿ ™ ๐Ÿ › ๐Ÿ œ ๐Ÿ ž ๐Ÿ  ๐Ÿ Ÿ โญ  โญข โญก โญฃ โญค โญฅ โญฆ โญง โญจ โญฉ ๐Ÿ € ๐Ÿ ‚ ๐Ÿ  ๐Ÿ ƒ ๐Ÿ „ ๐Ÿ † ๐Ÿ … ๐Ÿ ‡ ๐Ÿ ˆ ๐Ÿ Š ๐Ÿ ‰ ๐Ÿ ‹ ๐Ÿ   ๐Ÿ ข ๐Ÿ ก ๐Ÿ ฃ ๐Ÿ ค ๐Ÿ ฆ ๐Ÿ ฅ ๐Ÿ ง ๐Ÿ จ ๐Ÿ ช ๐Ÿ ฉ ๐Ÿ ซ ๐Ÿ ฌ ๐Ÿ ฎ ๐Ÿ ญ ๐Ÿ ฏ ๐Ÿ ฐ ๐Ÿ ฒ ๐Ÿ ฑ ๐Ÿ ณ ๐Ÿก  ๐Ÿกข ๐Ÿกก ๐Ÿกฃ ๐Ÿกค ๐Ÿกฅ ๐Ÿกฆ ๐Ÿกง ๐Ÿกจ ๐Ÿกช ๐Ÿกฉ ๐Ÿกซ ๐Ÿกฌ ๐Ÿกญ ๐Ÿกฎ ๐Ÿกฏ ๐Ÿกฐ ๐Ÿกฒ ๐Ÿกฑ ๐Ÿกณ ๐Ÿกด ๐Ÿกต ๐Ÿกถ ๐Ÿกท ๐Ÿกธ ๐Ÿกบ ๐Ÿกน ๐Ÿกป ๐Ÿกผ ๐Ÿกฝ ๐Ÿกพ ๐Ÿกฟ ๐Ÿข€ ๐Ÿข‚ ๐Ÿข ๐Ÿขƒ ๐Ÿข„ ๐Ÿข… ๐Ÿข† ๐Ÿข‡ โฎˆ โฎŠ โฎ‰ โฎ‹ โžฒ โฎœ โฎž โฎ โฎŸ โฎ˜ โฎš โฎ™ โฎ› โžข โžฃ โžค" + +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of list-emojis.ps1* diff --git a/Docs/list-empty-dirs.md b/Docs/list-empty-dirs.md index e5a79eee..78adfb9e 100644 --- a/Docs/list-empty-dirs.md +++ b/Docs/list-empty-dirs.md @@ -1,4 +1,4 @@ -## list-empty-dirs.ps1 - Lists empty subfolders within a directory tree +## The list-empty-dirs.ps1 PowerShell Script This PowerShell script scans and lists all empty subfolders within the given directory tree. @@ -32,4 +32,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists empty subfolders within a directory tree +.DESCRIPTION + This PowerShell script scans and lists all empty subfolders within the given directory tree. +.PARAMETER DirTree + Specifies the path to the directory tree +.EXAMPLE + PS> ./list-empty-dirs C:\ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$DirTree = "$PWD") + +try { + $DirTree = resolve-path "$DirTree/" + write-progress "Listing empty directories in $DirTree..." + [int]$Count = 0 + Get-ChildItem "$DirTree" -attributes Directory -recurse | Where {$_.GetFileSystemInfos().Count -eq 0} | ForEach-Object { + "๐Ÿ“‚ $($_.FullName)" + $Count++ + } + "โœ”๏ธ directory tree $DirTree has $Count empty directories" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-empty-dirs.ps1* diff --git a/Docs/list-empty-files.md b/Docs/list-empty-files.md index f9803409..93aa758d 100644 --- a/Docs/list-empty-files.md +++ b/Docs/list-empty-files.md @@ -1,4 +1,4 @@ -## list-empty-files.ps1 - Lists empty files within a directory tree +## The list-empty-files.ps1 PowerShell Script This PowerShell script scans and lists all empty files within the given directory tree. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists empty files within a directory tree +.DESCRIPTION + This PowerShell script scans and lists all empty files within the given directory tree. +.PARAMETER DirTree + Specifies the path to the directory tree +.EXAMPLE + PS> ./list-empty-files C:\ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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 { + write-output $_.FullName + $Count++ + } + + "โœ”๏ธ found $Count empty file(s)" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-empty-files.ps1* diff --git a/Docs/list-environment-variables.md b/Docs/list-environment-variables.md index 5ea5baca..e044dec1 100644 --- a/Docs/list-environment-variables.md +++ b/Docs/list-environment-variables.md @@ -1,4 +1,4 @@ -## list-environment-variables.ps1 - Lists all environment variables +## The list-environment-variables.ps1 PowerShell Script This PowerShell script lists all environment variables. @@ -31,4 +31,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all environment variables +.DESCRIPTION + This PowerShell script lists all environment variables. +.EXAMPLE + PS> ./list-environment-variables + + Name Value + ---- ----- + ALLUSERSPROFILE C:\ProgramData + APPDATA C:\Users\Joe\AppData\Roaming + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-ChildItem env: + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-environment-variables.ps1* diff --git a/Docs/list-exchange-rates.md b/Docs/list-exchange-rates.md index 7cf200f2..be069ab7 100644 --- a/Docs/list-exchange-rates.md +++ b/Docs/list-exchange-rates.md @@ -1,4 +1,4 @@ -## list-exchange-rates.ps1 - Lists the exchange rates for a currency +## The list-exchange-rates.ps1 PowerShell Script This PowerShell script lists the current exchange rates for the given currency (USD per default). @@ -32,4 +32,41 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the exchange rates for a currency +.DESCRIPTION + This PowerShell script lists the current exchange rates for the given currency (USD per default). +.PARAMETER currency + Specifies the base currency +.EXAMPLE + PS> ./list-exchange-rates EUR +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$currency = "USD") + +function ListExchangeRates { param([string]$currency) + [xml]$ExchangeRates = (invoke-webRequest -uri "http://www.floatrates.com/daily/$($currency).xml" -userAgent "curl" -useBasicParsing).Content + foreach($Row in $ExchangeRates.channel.item) { + new-object PSObject -property @{ 'Rate' = "$($Row.exchangeRate)"; 'Currency' = "$($Row.targetCurrency) - $($Row.targetName)"; 'Inverse' = "$($Row.inverseRate)"; 'Date' = "$($Row.pubDate)" } + } +} + +try { + "" + "Current Exchange Rates for 1 $currency (source: http://www.floatrates.com)" + "================================" + + ListExchangeRates $currency | format-table -property Rate,Currency,Inverse,Date + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-exchange-rates.ps1* diff --git a/Docs/list-fibonacci.md b/Docs/list-fibonacci.md index 9c4683eb..fec6d02e 100644 --- a/Docs/list-fibonacci.md +++ b/Docs/list-fibonacci.md @@ -1,4 +1,6 @@ -## list-fibonacci.ps1 - list-fibonacci.ps1 +## The list-fibonacci.ps1 PowerShell Script + +list-fibonacci.ps1 ## Parameters @@ -10,4 +12,29 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Lists the Fibonacci numbers +.DESCRIPTION + This PowerShell script lists the Fibonacci numbers. +.EXAMPLE + PS> ./list-fibonacci +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function fibonacci($n) { + if ($n -lt 2) { return 1 } + return (fibonacci($n - 1)) + (fibonacci($n - 2)) +} + + +foreach ($i in 0..100) { + Write-Host "$(fibonacci $i), " -noNewline +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of list-fibonacci.ps1* diff --git a/Docs/list-files.md b/Docs/list-files.md index 203695d1..b7b0ef4f 100644 --- a/Docs/list-files.md +++ b/Docs/list-files.md @@ -1,4 +1,4 @@ -## list-files.ps1 - Lists all files in a directory tree +## The list-files.ps1 PowerShell Script This PowerShell script lists all files within the given directory tree. @@ -32,4 +32,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all files in a directory tree +.DESCRIPTION + This PowerShell script lists all files within the given directory tree. +.PARAMETER DirTree + Specifies the path to the directory tree +.EXAMPLE + PS> ./list-files C:\ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$DirTree = "") + +try { + if ($DirTree -eq "" ) { $DirTree = read-host "Enter path to directory tree" } + + Get-ChildItem -path $DirTree -recurse | select FullName + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-files.ps1* diff --git a/Docs/list-folder.md b/Docs/list-folder.md index 8aae5d3e..f47a7f0f 100644 --- a/Docs/list-folder.md +++ b/Docs/list-folder.md @@ -1,4 +1,4 @@ -## list-folder.ps1 - Lists the folder content +## The list-folder.ps1 PowerShell Script This PowerShell script lists the directory content formatted in columns. @@ -32,4 +32,44 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the folder content +.DESCRIPTION + This PowerShell script lists the directory content formatted in columns. +.PARAMETER SearchPattern + Specifies the search pattern, "*" by default (means anything) +.EXAMPLE + PS> ./list-folder C:\ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$SearchPattern = "*") + +function ListFolder { param([string]$SearchPattern) + $Items = get-childItem -path "$SearchPattern" + foreach ($Item in $Items) { + $Name = $Item.Name + if ($Name[0] -eq '.') { continue } # hidden file/dir + if ($Item.Mode -like "d*") { $Icon = "๐Ÿ“‚" + } elseif ($Name -like "*.iso") { $Icon = "๐Ÿ“€" + } elseif ($Name -like "*.mp3") { $Icon = "๐ŸŽต" + } elseif ($Name -like "*.epub") { $Icon = "๐Ÿ““" + } else { $Icon = "๐Ÿ“„" } + new-object PSObject -Property @{ Name = "$Icon$Name" } + } +} + +try { + ListFolder $SearchPattern | format-wide -autoSize + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-folder.ps1* diff --git a/Docs/list-fritzbox-calls.md b/Docs/list-fritzbox-calls.md index 886029a9..2b36145e 100644 --- a/Docs/list-fritzbox-calls.md +++ b/Docs/list-fritzbox-calls.md @@ -1,4 +1,4 @@ -## list-fritzbox-calls.ps1 - Lists the phone calls of the FRITZ!Box device +## The list-fritzbox-calls.ps1 PowerShell Script This PowerShell script lists the phone calls of the FRITZ!Box device. @@ -41,4 +41,108 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the phone calls of the FRITZ!Box device +.DESCRIPTION + This PowerShell script lists the phone calls of the FRITZ!Box device. +.PARAMETER Username + Specifies the user name for FRITZ!Box +.PARAMETER Password + Specifies the password to FRITZ!Box +.EXAMPLE + PS> ./list-fritzbox-calls +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -Version 3 + +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" } + +write-progress "Contacting FRITZ!Box ..." +$FQDN = "fritz.box" + +[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12' + +[xml]$serviceinfo = Invoke-RestMethod -Method GET -Uri "http://$($FQDN):49000/tr64desc.xml" +[System.Xml.XmlNamespaceManager]$ns = new-Object System.Xml.XmlNamespaceManager $serviceinfo.NameTable +$ns.AddNamespace("ns",$serviceinfo.DocumentElement.NamespaceURI) +[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true } + + +function Execute-SOAPRequest { param([Xml]$SOAPRequest, [string]$soapactionheader, [String]$URL) + try { + $wr = [System.Net.WebRequest]::Create($URL) + $wr.Headers.Add('SOAPAction',$soapactionheader) + $wr.ContentType = 'text/xml; charset="utf-8"' + $wr.Accept = 'text/xml' + $wr.Method = 'POST' + $wr.PreAuthenticate = $true + $wr.Credentials = [System.Net.NetworkCredential]::new($Username,$Password) + + $requestStream = $wr.GetRequestStream() + $SOAPRequest.Save($requestStream) + $requestStream.Close() + [System.Net.HttpWebResponse]$wresp = $wr.GetResponse() + $responseStream = $wresp.GetResponseStream() + $responseXML = [Xml]([System.IO.StreamReader]($responseStream)).ReadToEnd() + $responseStream.Close() + return $responseXML + } catch { + if ($_.Exception.InnerException.Response){ + throw ([System.IO.StreamReader]($_.Exception.InnerException.Response.GetResponseStream())).ReadToEnd() + } else { + throw $_.Exception.InnerException + } + } +} + +function New-Request { + param( + [parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string]$urn, + [parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string]$action, + [hashtable]$parameter = @{}, + $Protocol = 'https' + ) + # SOAP Request Body Template + [xml]$request = @" + + + + + +"@ + $service = $serviceinfo.SelectNodes('//ns:service',$ns) | ?{$_.ServiceType -eq $URN} + if(!$service){throw "URN does not exist."} + $actiontag = $request.CreateElement('u',$action,$service.serviceType) + $parameter.GetEnumerator() | %{ + $el = $request.CreateElement($_.Key) + $el.InnerText = $_.Value + $actiontag.AppendChild($el)| out-null + } + $request.GetElementsByTagName('s:Body')[0].AppendChild($actiontag) | out-null + $resp = Execute-SOAPRequest $request "$($service.serviceType)#$($action)" "$($Protocol)://$($FQDN):$(@{$true=$script:secport;$false=49000}[($Protocol -eq 'https')])$($service.controlURL)" + return $resp +} + +$script:secport = (New-Request -urn "urn:dslforum-org:service:DeviceInfo:1" -action 'GetSecurityPort' -proto 'http').Envelope.Body.GetSecurityPortResponse.NewSecurityPort + +function GetCallList { param([int]$MaxEntries = 999, [int]$MaxDays = 999 + ) + $resp = New-Request -urn 'urn:dslforum-org:service:X_AVM-DE_OnTel:1' -action 'GetCallList' + $list = [xml](new-object System.Net.WebClient).DownloadString("$($resp.Envelope.Body.GetCallListResponse.NewCallListURL)&max=$MaxEntries&MaxDays=$days") + return $list.root.call +} + +GetCallList | format-table -property Date,Duration,Caller,Called +echo $Result +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of list-fritzbox-calls.ps1* diff --git a/Docs/list-fritzbox-devices.md b/Docs/list-fritzbox-devices.md index bb1027a6..c91b026a 100644 --- a/Docs/list-fritzbox-devices.md +++ b/Docs/list-fritzbox-devices.md @@ -1,4 +1,4 @@ -## list-fritzbox-devices.ps1 - Lists FRITZ!Box's known devices +## The list-fritzbox-devices.ps1 PowerShell Script This PowerShell script lists FRITZ!Box's known devices. @@ -41,4 +41,60 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists FRITZ!Box's known devices +.DESCRIPTION + This PowerShell script lists FRITZ!Box's known devices. +.PARAMETER Username + Specifies the user name to FRITZ!Box +.PARAMETER Password + Specifies the password to FRITZ!Box +.EXAMPLE + PS> ./list-fritzbox-devices +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -Version 3 + +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" } + +write-progress "Contacting FRITZ!Box ..." +[string]$HostURL = "https://fritz.box:49443" +[string]$SOAPAction="urn:dslforum-org:service:Hosts:1#X_AVM-DE_GetHostListPath" +[string]$SOAPrequest = @" + + + + + + +"@ + +$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force +$Credentials = New-Object System.Management.Automation.PSCredential -ArgumentList $Username, $SecurePassword + +$XmlResult = invoke-restMethod ` + -Method POST ` + -Headers @{'SOAPAction'=($SOAPAction)} ` + -Uri ($HostURL+"/upnp/control/hosts") ` + -Credential $Credentials ` + -ContentType 'text/xml' ` + -Body $SOAPrequest + +$HostList = invoke-restMethod -Uri ($HostURL+($XmlResult.Envelope.Body.'X_AVM-DE_GetHostListPathResponse'.'NewX_AVM-DE_HostListPath')) + +$HostTable = $HostList.List.Item.GetEnumerator() + +$HostTable | format-table -property Active,IPAddress,MACAddress,HostName,InterfaceType,X_AVM-DE_Speed + +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of list-fritzbox-devices.ps1* diff --git a/Docs/list-headlines.md b/Docs/list-headlines.md index a07c9234..3ac17f1f 100644 --- a/Docs/list-headlines.md +++ b/Docs/list-headlines.md @@ -1,4 +1,4 @@ -## list-headlines.ps1 - Lists the latest headlines +## The list-headlines.ps1 PowerShell Script This PowerShell script lists the latest RSS feed news. @@ -41,4 +41,40 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the latest headlines +.DESCRIPTION + This PowerShell script lists the latest RSS feed news. +.PARAMETER RSS_URL + Specifies the URL to the RSS feed +.PARAMETER MaxCount + Specifies the number of news to list +.EXAMPLE + PS> ./list-headlines +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RSS_URL = "https://yahoo.com/news/rss/world", [int]$MaxCount = 20) + +try { + [xml]$Content = (invoke-webRequest -uri $RSS_URL -useBasicParsing).Content + "`n๐ŸŒ $($Content.rss.channel.title) ๐ŸŒ" + + [int]$Count = 0 + foreach ($item in $Content.rss.channel.item) { + "โ†’ $($item.title)" + $Count++ + if ($Count -eq $MaxCount) { break } + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-headlines.ps1* diff --git a/Docs/list-hidden-files.md b/Docs/list-hidden-files.md index cecc7163..e814f12c 100644 --- a/Docs/list-hidden-files.md +++ b/Docs/list-hidden-files.md @@ -1,4 +1,4 @@ -## list-hidden-files.ps1 - Lists hidden files in a directory tree +## The list-hidden-files.ps1 PowerShell Script This PowerShell script scans and lists all hidden files in a directory tree. @@ -32,4 +32,38 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists hidden files in a directory tree +.DESCRIPTION + This PowerShell script scans and lists all hidden files in a directory tree. +.PARAMETER DirTree + Specifies the path to the directory tree +.EXAMPLE + PS> ./list-hidden-files C:\ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$DirTree = "$PWD") + +try { + $DirTree = resolve-path "$DirTree" + write-progress "Listing hidden files in $DirTree ..." + + [int]$Count = 0 + get-childItem "$DirTree" -attributes Hidden -recurse | foreach-object { + "๐Ÿ“„ $($_.FullName)" + $Count++ + } + "โœ”๏ธ directory tree $DirTree has $Count hidden file(s)" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-hidden-files.ps1* diff --git a/Docs/list-installed-languages.md b/Docs/list-installed-languages.md index 0e7d81a6..6d921522 100644 --- a/Docs/list-installed-languages.md +++ b/Docs/list-installed-languages.md @@ -1,4 +1,6 @@ -## list-installed-languages.ps1 - list-installed-languages.ps1 +## The list-installed-languages.ps1 PowerShell Script + +list-installed-languages.ps1 ## Parameters @@ -10,4 +12,33 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Lists the installed languages +.DESCRIPTION + This PowerShell script lists the installed languages. +.EXAMPLE + PS> ./list-installed-languages +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function ListInstalledLanguages { + $List = Get-WinUserLanguageList + foreach ($Item in $List) { + New-Object PSObject -property @{ 'Tag' = "$($Item.LanguageTag)"; 'Autonym' = "$($Item.Autonym)"; 'English' = "$($Item.EnglishName)"; 'Spellchecking' = "$($Item.Spellchecking)"; 'Handwriting' = "$($Item.Handwriting)" } + } +} + +try { + ListInstalledLanguages | Format-Table -property Tag,Autonym,English,Spellchecking,Handwriting + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-installed-languages.ps1* diff --git a/Docs/list-installed-software.md b/Docs/list-installed-software.md index b230c8ae..53ab7011 100644 --- a/Docs/list-installed-software.md +++ b/Docs/list-installed-software.md @@ -1,4 +1,4 @@ -## list-installed-software.ps1 - Lists the installed software +## The list-installed-software.ps1 PowerShell Script This PowerShell script lists the installed software (except Windows Store apps). @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the installed software +.DESCRIPTION + This PowerShell script lists the installed software (except Windows Store apps). +.EXAMPLE + PS> ./list-installed-software +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*, HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | select-object DisplayName,DisplayVersion,InstallDate | Format-Table -autoSize + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-installed-software.ps1* diff --git a/Docs/list-latest-tag.md b/Docs/list-latest-tag.md index 8313bfc5..a7b0cd61 100644 --- a/Docs/list-latest-tag.md +++ b/Docs/list-latest-tag.md @@ -1,4 +1,4 @@ -## list-latest-tag.ps1 - Lists the latest tag on the current branch in a Git repository +## The list-latest-tag.ps1 PowerShell Script This PowerShell script lists the latest tag on the current branch in a Git repository. @@ -32,4 +32,43 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the latest tag on the current branch in a Git repository +.DESCRIPTION + This PowerShell script lists the latest tag on the current branch in a Git repository. +.PARAMETER RepoDir + Specifies the path to the repository +.EXAMPLE + PS> ./list-latest-tag C:\MyRepo +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RepoDir = "$PWD") + +try { + if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + + $Null = (git --version) + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + +# $RepoDirName = (get-item "$RepoDir").Name +# "๐Ÿขƒ Fetching updates for ๐Ÿ“‚$RepoDirName ..." +# & git -C "$RepoDir" fetch --tags +# if ($lastExitCode -ne "0") { throw "'git fetch --tags' failed" } + + $LatestTagCommitID = (git -C "$RepoDir" rev-list --tags --max-count=1) + $LatestTag = (git -C "$RepoDir" describe --tags $LatestTagCommitID) + "๐Ÿ”–$LatestTag ($LatestTagCommitID)" + + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-latest-tag.ps1* diff --git a/Docs/list-latest-tags.md b/Docs/list-latest-tags.md index fb57c4fe..ba62c835 100644 --- a/Docs/list-latest-tags.md +++ b/Docs/list-latest-tags.md @@ -1,4 +1,4 @@ -## list-latest-tags.ps1 - Lists the latests tags in all Git repositories in a folder +## The list-latest-tags.ps1 PowerShell Script This PowerShell script lists the latest tags in all Git repositories in the specified folder. @@ -32,4 +32,49 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the latests tags in all Git repositories in a folder +.DESCRIPTION + This PowerShell script lists the latest tags in all Git repositories in the specified folder. +.PARAMETER ParentDir + Specifies the path to the parent folder +.EXAMPLE + PS> ./list-latest-tags C:\MyRepos +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$ParentDir = "$PWD") + +try { + if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" } + + $Null = (git --version) + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + $Folders = (get-childItem "$ParentDir" -attributes Directory) + $FolderCount = $Folders.Count + $ParentDirName = (get-item "$ParentDir").Name + "Found $FolderCount subfolders in ๐Ÿ“‚$ParentDirName..." + + foreach ($Folder in $Folders) { + $FolderName = (get-item "$Folder").Name + +# & git -C "$Folder" fetch --tags +# if ($lastExitCode -ne "0") { throw "'git fetch --tags' failed" } + + $LatestTagCommitID = (git -C "$Folder" rev-list --tags --max-count=1) + $LatestTag = (git -C "$Folder" describe --tags $LatestTagCommitID) + "* $FolderName $LatestTag ($LatestTagCommitID)" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-latest-tags.ps1* diff --git a/Docs/list-memos.md b/Docs/list-memos.md index 7a961feb..8ac536e3 100644 --- a/Docs/list-memos.md +++ b/Docs/list-memos.md @@ -1,4 +1,4 @@ -## list-memos.ps1 - Lists all memos in $HOME/Memos.csv +## The list-memos.ps1 PowerShell Script This PowerShell script lists all memo entries in Memos.csv in the home folder. @@ -23,4 +23,45 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all memos in $HOME/Memos.csv +.DESCRIPTION + This PowerShell script lists all memo entries in Memos.csv in the home folder. +.EXAMPLE + PS> ./list-memos +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + + +try { + $Path = "$HOME/Memos.csv" + if (test-path "$Path" -pathType leaf) { + write-progress "Reading $Path ..." + $Table = import-csv "$Path" + write-progress -completed "Reading $Path" + + "" + "Time User Text" + "---- ---- ----" + foreach($Row in $Table) { + $Time = $Row.Time + $User = $Row.User + $Text = $Row.Text + "$Time $User $Text" + } + } else { + "Sorry, no memos saved yet" + exit 1 + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-memos.ps1* diff --git a/Docs/list-modules.md b/Docs/list-modules.md index de00af7e..2ca95e45 100644 --- a/Docs/list-modules.md +++ b/Docs/list-modules.md @@ -1,4 +1,4 @@ -## list-modules.ps1 - Lists all PowerShell modules +## The list-modules.ps1 PowerShell Script This PowerShell script lists all installed PowerShell modules. @@ -30,4 +30,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all PowerShell modules +.DESCRIPTION + This PowerShell script lists all installed PowerShell modules. +.EXAMPLE + PS> ./list-modules + + ModuleType Version Name ExportedCommands + ---------- ------- ---- ---------------- + Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer...} + Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable...} +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-Module | Format-Table + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-modules.ps1* diff --git a/Docs/list-motherboard.md b/Docs/list-motherboard.md index 78e70adb..a77ecf8b 100644 --- a/Docs/list-motherboard.md +++ b/Docs/list-motherboard.md @@ -1,4 +1,4 @@ -## list-motherboard.ps1 - Lists motherboard details +## The list-motherboard.ps1 PowerShell Script This PowerShell script lists the motherboard details. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists motherboard details +.DESCRIPTION + This PowerShell script lists the motherboard details. +.EXAMPLE + PS> ./list-motherboard +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-WmiObject -Class Win32_BaseBoard + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-motherboard.ps1* diff --git a/Docs/list-mysql-tables.md b/Docs/list-mysql-tables.md index 9f38c874..f6f16dcf 100644 --- a/Docs/list-mysql-tables.md +++ b/Docs/list-mysql-tables.md @@ -1,4 +1,4 @@ -## list-mysql-tables.ps1 - Lists all tables of a MySQL database +## The list-mysql-tables.ps1 PowerShell Script This PowerShell script lists all tables of the given MySQL database. @@ -55,4 +55,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all tables of a MySQL database +.DESCRIPTION + This PowerShell script lists all tables of the given MySQL database. +.EXAMPLE + PS> ./list-mysql-tables +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +# This script lists all of the tables in a MySQL database and exports the list as a CSV +# Install-Module InvokeQuery +# Run the above command if you do not have this module +param( +[Parameter(Mandatory=$true)]$server, +[Parameter(Mandatory=$true)]$database, +[Parameter(Mandatory=$true)]$dbuser, +[Parameter(Mandatory=$true)]$dbpass +) +$csvfilepath = "$PSScriptRoot\mysql_tables.csv" +$result = Invoke-MySqlQuery -ConnectionString "server=$server; database=$database; user=$dbuser; password=$dbpass; pooling = false; convert zero datetime=True" -Sql "SHOW TABLES" -CommandTimeout 10000 +$result | Export-Csv $csvfilepath -NoTypeInformation + *Generated by convert-ps2md.ps1 using the comment-based help of list-mysql-tables.ps1* diff --git a/Docs/list-network-routes.md b/Docs/list-network-routes.md index 42da5d1e..328e7cff 100644 --- a/Docs/list-network-routes.md +++ b/Docs/list-network-routes.md @@ -1,4 +1,4 @@ -## list-network-routes.ps1 - Lists network routes +## The list-network-routes.ps1 PowerShell Script This PowerShell script lists the network routes on the local computer. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists network routes +.DESCRIPTION + This PowerShell script lists the network routes on the local computer. +.EXAMPLE + PS> ./list-network-routes +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + & route print + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-network-routes.ps1* diff --git a/Docs/list-network-shares.md b/Docs/list-network-shares.md index 87c0eb18..422e9b72 100644 --- a/Docs/list-network-shares.md +++ b/Docs/list-network-shares.md @@ -1,4 +1,4 @@ -## list-network-shares.ps1 - Lists all network shares of the local computer +## The list-network-shares.ps1 PowerShell Script This PowerShell script lists all network shares of the local computer. @@ -29,4 +29,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all network shares of the local computer +.DESCRIPTION + This PowerShell script lists all network shares of the local computer. +.EXAMPLE + PS> ./list-network-shares + + Name Path Description + ---- ---- ----------- + Users C:\Users +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-WmiObject win32_share | where {$_.name -NotLike "*$"} + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-network-shares.ps1* diff --git a/Docs/list-news.md b/Docs/list-news.md index 39074f67..feb0885c 100644 --- a/Docs/list-news.md +++ b/Docs/list-news.md @@ -1,4 +1,4 @@ -## list-news.ps1 - Lists the news +## The list-news.ps1 PowerShell Script This PowerShell script lists the latest news by using RSS (Really Simple Syndication) feeds. @@ -41,4 +41,40 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the news +.DESCRIPTION + This PowerShell script lists the latest news by using RSS (Really Simple Syndication) feeds. +.PARAMETER RSS_URL + Specifies the URL to the RSS feed (Yahoo News by default) +.PARAMETER MaxCount + Specifies the number of lines to list (20 by default) +.EXAMPLE + PS> ./list-news +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RSS_URL = "https://yahoo.com/news/rss/world", [int]$MaxCount = 20) + +try { + [xml]$Content = (Invoke-WebRequest -URI $RSS_URL -useBasicParsing).Content + [int]$Count = 1 + foreach ($Item in $Content.rss.channel.item) { + & "$PSScriptRoot/write-typewriter.ps1" "โ†’ $($Item.title)" 20 # ms speed + if ($Count++ -eq $MaxCount) { break } + } + $Source = $Content.rss.channel.title + $Date = $Content.rss.channel.pubDate + " By *$($Source)* as of $Date" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-news.ps1* diff --git a/Docs/list-nic.md b/Docs/list-nic.md index b6fa5bac..84810630 100644 --- a/Docs/list-nic.md +++ b/Docs/list-nic.md @@ -1,4 +1,4 @@ -## list-nic.ps1 - Lists NIC details +## The list-nic.ps1 PowerShell Script This PowerShell script lists the details of the installed network interfaces. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists NIC details +.DESCRIPTION + This PowerShell script lists the details of the installed network interfaces. +.EXAMPLE + PS> ./list-nic +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-WmiObject -Class Win32_NetworkAdapterConfiguration | Format-Table -property ServiceName,Description,IPAddress,DHCPEnabled -AutoSize + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-nic.ps1* diff --git a/Docs/list-os-releases.md b/Docs/list-os-releases.md index c5c68808..05805d50 100644 --- a/Docs/list-os-releases.md +++ b/Docs/list-os-releases.md @@ -1,4 +1,4 @@ -## list-os-releases.ps1 - Lists OS releases and download URL +## The list-os-releases.ps1 PowerShell Script This PowerShell script lists OS releases and download URL. @@ -23,4 +23,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists OS releases and download URL +.DESCRIPTION + This PowerShell script lists OS releases and download URL. +.EXAMPLE + PS> ./list-os-releases +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + write-progress "Reading OS_IPFS_hashes.csv ..." + + $PathToRepo = "$PSScriptRoot/.." + $PathToCsvFile = "$PathToRepo/Data/os-release.csv" + invoke-webRequest -URI "https://fleschutz.droppages.com/downloads/OS_IPFS_hashes.csv" -outFile "$PathToCsvFile" + + $Table = import-csv "$PathToCsvFile" + remove-item -path "$PathToCsvFile" + + write-output "Operating System Releases" + write-output "=========================" + foreach ($Row in $Table) { + write-output "* $($Row.Path.substring(3)) -> ipfs://$($Row.IPFS)" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-os-releases.ps1* diff --git a/Docs/list-os-updates.md b/Docs/list-os-updates.md index ab2ba448..373bd11d 100644 --- a/Docs/list-os-updates.md +++ b/Docs/list-os-updates.md @@ -1,4 +1,4 @@ -## list-os-updates.ps1 - Lists the latest operating system updates +## The list-os-updates.ps1 PowerShell Script This PowerShell script lists the latest operating system update news. @@ -41,4 +41,41 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the latest operating system updates +.DESCRIPTION + This PowerShell script lists the latest operating system update news. +.PARAMETER RSS_URL + Specifies the URL to the RSS feed +.PARAMETER MaxCount + Specifies the number of news to list +.EXAMPLE + PS> ./list-os-updates +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RSS_URL = "https://distrowatch.com/news/dwd.xml", [int]$MaxCount = 20) + +try { + & "$PSScriptRoot/write-big.ps1" "OS Updates" + [xml]$Content = (invoke-webRequest -URI $RSS_URL).Content + "`t(by $($Content.rss.channel.title))" + + [int]$Count = 0 + foreach ($item in $Content.rss.channel.item) { + "`tโ†’ $($item.title)" + $Count++ + if ($Count -eq $MaxCount) { break } + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-os-updates.ps1* diff --git a/Docs/list-os.md b/Docs/list-os.md index 637ebbaa..3b6679a7 100644 --- a/Docs/list-os.md +++ b/Docs/list-os.md @@ -1,4 +1,4 @@ -## list-os.ps1 - Lists the operating system version +## The list-os.ps1 PowerShell Script This PowerShell script lists the exact operating system version. @@ -23,4 +23,34 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the operating system version +.DESCRIPTION + This PowerShell script lists the exact operating system version. +.EXAMPLE + PS> ./list-os +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + "๐Ÿง(uname -sr)" + } else { + $OS = Get-WmiObject -class Win32_OperatingSystem + $OSname = $OS.Caption + $OSarchitecture = $OS.OSArchitecture + $OSversion = $OS.Version + "๐ŸŒ$OSname for $OSarchitecture version $OSversion" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-os.ps1* diff --git a/Docs/list-outlook-inbox.md b/Docs/list-outlook-inbox.md index ea0797cd..b39f0e25 100644 --- a/Docs/list-outlook-inbox.md +++ b/Docs/list-outlook-inbox.md @@ -1,4 +1,4 @@ -## list-outlook-inbox.ps1 - Lists Outlook's Inbox +## The list-outlook-inbox.ps1 PowerShell Script This PowerShell script lists the emails in the inbox of Outlook. @@ -23,4 +23,29 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists Outlook's Inbox +.DESCRIPTION + This PowerShell script lists the emails in the inbox of Outlook. +.EXAMPLE + PS> ./list-outlook-inbox +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Outlook = New-Object -com Outlook.application + $MAPI = $Outlook.GetNameSpace("MAPI") + $Inbox = $MAPI.GetDefaultFolder(6) # 6 = olFolderInbox + $Inbox.items | Select Received,Subject | Format-Table -AutoSize + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-outlook-inbox.ps1* diff --git a/Docs/list-outlook-sent.md b/Docs/list-outlook-sent.md index 81193904..dd48d344 100644 --- a/Docs/list-outlook-sent.md +++ b/Docs/list-outlook-sent.md @@ -1,4 +1,4 @@ -## list-outlook-sent.ps1 - Lists Outlook's Sent Mails +## The list-outlook-sent.ps1 PowerShell Script This PowerShell script lists the mails in the Sent Mail folder of Outlook. @@ -23,4 +23,29 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists Outlook's Sent Mails +.DESCRIPTION + This PowerShell script lists the mails in the Sent Mail folder of Outlook. +.EXAMPLE + PS> ./list-outlook-sent +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Outlook = New-Object -com Outlook.application + $MAPI = $Outlook.GetNameSpace("MAPI") + $Inbox = $MAPI.GetDefaultFolder(5) # 5 = olFolderSentMail + $Inbox.items | Select SentOn,Subject | Format-Table -AutoSize + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-outlook-sent.ps1* diff --git a/Docs/list-passwords.md b/Docs/list-passwords.md index 86334202..dc0118fa 100644 --- a/Docs/list-passwords.md +++ b/Docs/list-passwords.md @@ -1,4 +1,4 @@ -## list-passwords.ps1 - Lists random passwords +## The list-passwords.ps1 PowerShell Script This PowerShell script lists random passwords. @@ -50,4 +50,49 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists random passwords +.DESCRIPTION + This PowerShell script lists random passwords. +.PARAMETER PasswordLength + Specifies the length of the password +.PARAMETER Columns + Specifies the number of columns +.PARAMETER Rows + Specifies the number of rows +.EXAMPLE + PS> ./list-passwords +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([int]$PasswordLength = 15, [int]$Columns = 6, [int]$Rows = 30) + +$MinCharCode = 33 +$MaxCharCode = 126 + +try { + write-output "" + $Generator = New-Object System.Random + for ($j = 0; $j -lt $Rows; $j++) { + $Line = "" + for ($k = 0; $k -lt $Columns; $k++) { + for ($i = 0; $i -lt $PasswordLength; $i++) { + $Line += [char]$Generator.next($MinCharCode,$MaxCharCode) + } + $Line += " " + } + write-output "$Line" + } + write-output "" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-passwords.ps1* diff --git a/Docs/list-pins.md b/Docs/list-pins.md index bcecc05c..ceb55593 100644 --- a/Docs/list-pins.md +++ b/Docs/list-pins.md @@ -1,4 +1,4 @@ -## list-pins.ps1 - Lists random PIN's +## The list-pins.ps1 PowerShell Script This PowerShell script lists random PIN's. @@ -50,4 +50,46 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists random PIN's +.DESCRIPTION + This PowerShell script lists random PIN's. +.PARAMETER PinLength + Specifies the PIN length +.PARAMETER Columns + Specifies the number of columns +.PARAMETER Rows + Specifies the number of rows +.EXAMPLE + PS> ./list-pins +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([int]$PinLength = 5, [int]$Columns = 12, [int]$Rows = 30) + +try { + write-output "" + $Generator = New-Object System.Random + for ($j = 0; $j -lt $Rows; $j++) { + $Line = "" + for ($k = 0; $k -lt $Columns; $k++) { + for ($i = 0; $i -lt $PinLength; $i++) { + $Line += [char]$Generator.next(48,57) + } + $Line += " " + } + write-output $Line + } + write-output "" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-pins.ps1* diff --git a/Docs/list-print-jobs.md b/Docs/list-print-jobs.md index e993ec4d..120c5585 100644 --- a/Docs/list-print-jobs.md +++ b/Docs/list-print-jobs.md @@ -1,4 +1,4 @@ -## list-print-jobs.ps1 - Lists all jobs of all printers +## The list-print-jobs.ps1 PowerShell Script This PowerShell script lists all print jobs of all printer devices. @@ -23,4 +23,41 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all jobs of all printers +.DESCRIPTION + This PowerShell script lists all print jobs of all printer devices. +.EXAMPLE + PS> ./list-print-jobs +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -Version 4 + +try { + $printers = Get-Printer + if ($printers.Count -eq 0) { throw "No printer found" } + + "" + "Printer Jobs" + "------- ----" + foreach ($printer in $printers) { + $printjobs = Get-PrintJob -PrinterObject $printer + if ($printjobs.Count -eq 0) { + "$($printer.Name) none" + } else { + "$($printer.Name) $printjobs" + } + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-print-jobs.ps1* diff --git a/Docs/list-printers.md b/Docs/list-printers.md index 69b2a10e..4888947c 100644 --- a/Docs/list-printers.md +++ b/Docs/list-printers.md @@ -1,4 +1,4 @@ -## list-printers.ps1 - Lists all printers known to the local computer +## The list-printers.ps1 PowerShell Script This PowerShell script lists all printers known to the local computer. @@ -23,4 +23,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all printers known to the local computer +.DESCRIPTION + This PowerShell script lists all printers known to the local computer. +.EXAMPLE + PS> ./list-printers +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $ComputerName = $(hostname) + get-WMIObject -Class Win32_Printer -ComputerName $ComputerName | format-table + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-printers.ps1* diff --git a/Docs/list-processes.md b/Docs/list-processes.md index 3a646470..058b2d68 100644 --- a/Docs/list-processes.md +++ b/Docs/list-processes.md @@ -1,4 +1,4 @@ -## list-processes.ps1 - Lists all local computer processes +## The list-processes.ps1 PowerShell Script This PowerShell script lists all local computer processes. @@ -31,4 +31,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all local computer processes +.DESCRIPTION + This PowerShell script lists all local computer processes. +.EXAMPLE + PS> ./list-processes + + Id CPU(s) ProcessName + -- ------ ----------- + 9712 0,39% 64DriverLoad + 2484 AppleMobileDeviceService + ... +.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 + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-processes.ps1* diff --git a/Docs/list-profiles.md b/Docs/list-profiles.md index 0a030549..df5a714e 100644 --- a/Docs/list-profiles.md +++ b/Docs/list-profiles.md @@ -1,4 +1,6 @@ -## list-profiles.ps1 - list-profiles.ps1 +## The list-profiles.ps1 PowerShell Script + +list-profiles.ps1 ## Parameters @@ -10,4 +12,45 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Lists the user's PowerShell profiles +.DESCRIPTION + This PowerShell script lists the user's PowerShell profiles. +.EXAMPLE + PS> ./list-profiles + + Level Profile Location Existent + ----- ------- -------- -------- + 1 AllUsersAllHosts /opt/PowerShell/profile.ps1 no + 2 AllUsersCurrentHost /opt/PowerShell/Microsoft.PowerShell_profile.ps1 no + 3 CurrentUserAllHosts /home/markus/.config/powershell/profile.ps1 no + 4 CurrentUserCurrentHost /home/markus/.config/powershell/Microsoft.PowerShell_profile.ps1 yes +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function ListProfile { param([int]$Level, [string]$Profile, [string]$Location) + if (test-path "$Location") { $Existent = "yes" } else { $Existent = "no" } + New-Object PSObject -Property @{ 'Level'="$Level"; 'Profile'="$Profile"; 'Location'="$Location"; 'Existent'="$Existent" } +} + +function ListProfiles { + ListProfile 1 "AllUsersAllHosts" $PROFILE.AllUsersAllHosts + ListProfile 2 "AllUsersCurrentHost" $PROFILE.AllUsersCurrentHost + ListProfile 3 "CurrentUserAllHosts" $PROFILE.CurrentUserAllHosts + ListProfile 4 "CurrentUserCurrentHost" $PROFILE.CurrentUserCurrentHost +} + +try { + ListProfiles | format-table -property Level,Profile,Location,Existent + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-profiles.ps1* diff --git a/Docs/list-ram.md b/Docs/list-ram.md index 2cab0046..5a96ec0a 100644 --- a/Docs/list-ram.md +++ b/Docs/list-ram.md @@ -1,4 +1,4 @@ -## list-ram.ps1 - Lists RAM details +## The list-ram.ps1 PowerShell Script This PowerShell script lists the details of the installed RAM. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists RAM details +.DESCRIPTION + This PowerShell script lists the details of the installed RAM. +.EXAMPLE + PS> ./list-ram +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-WmiObject -Class Win32_PhysicalMemory + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-ram.ps1* diff --git a/Docs/list-recycle-bin.md b/Docs/list-recycle-bin.md index 2e7be3d3..3e6d45be 100644 --- a/Docs/list-recycle-bin.md +++ b/Docs/list-recycle-bin.md @@ -1,4 +1,4 @@ -## list-recycle-bin.ps1 - Lists the content of the recycle bin folder +## The list-recycle-bin.ps1 PowerShell Script This PowerShell script lists the content of the recycle bin folder. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the content of the recycle bin folder +.DESCRIPTION + This PowerShell script lists the content of the recycle bin folder. +.EXAMPLE + PS> ./list-recycle-bin +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + (New-Object -ComObject Shell.Application).NameSpace(0x0a).Items() | Select-Object Name,Size,Path + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-recycle-bin.ps1* diff --git a/Docs/list-repos.md b/Docs/list-repos.md index 9e869a54..c969bd0d 100644 --- a/Docs/list-repos.md +++ b/Docs/list-repos.md @@ -1,4 +1,4 @@ -## list-repos.ps1 - Lists Git repositories +## The list-repos.ps1 PowerShell Script This PowerShell script lists the details of all Git repositories in a folder. @@ -40,4 +40,58 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists Git repositories +.DESCRIPTION + This PowerShell script lists the details of all Git repositories in a folder. +.PARAMETER ParentDir + Specifies the path to the parent folder. +.EXAMPLE + PS> ./list-repos C:\MyRepos + + No Repository Branch LatestTag Status + -- ---------- ------ --------- ------ + 1 cmake main v3.23.0 clean + 2 opencv main 4.5.5 modified + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$ParentDir = "$PWD") + +function ListRepos { + [int]$No = 0 + $Folders = (Get-ChildItem "$ParentDir" -attributes Directory) + foreach ($Folder in $Folders) { + $No++ + $Repository = (get-item "$Folder").Name + $Branch = (git -C "$Folder" branch --show-current) + $LatestTagCommitID = (git -C "$Folder" rev-list --tags --max-count=1) + $LatestTag = (git -C "$Folder" describe --tags $LatestTagCommitID) + $Status = (git -C "$Folder" status --short) + if ("$Status" -eq "") { $Status = "clean" } + if ("$Status" -like " M *") { $Status = "modified" } + + New-Object PSObject -property @{ 'No'="$No"; 'Repository'="$Repository"; 'Branch'="$Branch"; 'LatestTag'="$LatestTag"; 'Status'="$Status"; } + } +} + +try { + if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" } + + $Null = (git --version) + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + ListRepos | Format-Table -property @{e='No';width=3},@{e='Repository';width=25},@{e='Branch';width=20},LatestTag,Status + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-repos.ps1* diff --git a/Docs/list-scripts.md b/Docs/list-scripts.md index f59d4caf..48bf15a1 100644 --- a/Docs/list-scripts.md +++ b/Docs/list-scripts.md @@ -1,4 +1,6 @@ -## list-scripts.ps1 - list-scripts.ps1 +## The list-scripts.ps1 PowerShell Script + +list-scripts.ps1 ## Parameters @@ -10,4 +12,42 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Lists all PowerShell scripts in this repository +.DESCRIPTION + This PowerShell script lists all PowerShell scripts in the repository (sorted alphabetically). +.EXAMPLE + PS> ./list-scripts +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function ListScripts { param([string]$FilePath) + write-progress "Reading $FilePath..." + $Table = import-csv "$FilePath" + foreach($Row in $Table) { + New-Object PSObject -Property @{ + 'PowerShell Script' = "$($Row.Script)" + 'Description' = "$($Row.Description)" + } + } + $global:NumScripts = $Table.Count + write-progress -completed "Reading $FilePath..." +} + +try { + $PathToRepo = "$PSScriptRoot/.." + ListScripts "$PathToRepo/Data/scripts.csv" | format-table -property "PowerShell Script",Description + + "โœ”๏ธ $($global:NumScripts) PowerShell scripts total" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-scripts.ps1* diff --git a/Docs/list-services.md b/Docs/list-services.md index 5a0a610a..d57d1cf2 100644 --- a/Docs/list-services.md +++ b/Docs/list-services.md @@ -1,4 +1,4 @@ -## list-services.ps1 - Lists the local computer services +## The list-services.ps1 PowerShell Script This PowerShell script lists all local computer services. @@ -31,4 +31,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the local computer services +.DESCRIPTION + This PowerShell script lists all local computer services. +.EXAMPLE + PS> ./list-services + + Status Name DisplayName + ------ ---- ----------- + Running AarSvc_886c2 Agent Activation Runtime_886c2 + Running Apple Mobile De... Apple Mobile Device Service + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-Service + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-services.ps1* diff --git a/Docs/list-special-folders.md b/Docs/list-special-folders.md index 5f6a8493..54a02e6c 100644 --- a/Docs/list-special-folders.md +++ b/Docs/list-special-folders.md @@ -1,4 +1,6 @@ -## list-special-folders.ps1 - list-special-folders.ps1 +## The list-special-folders.ps1 PowerShell Script + +list-special-folders.ps1 ## Parameters @@ -10,4 +12,68 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Lists special folders +.DESCRIPTION + This PowerShell script lists the special folders (sorted alphabetically). +.EXAMPLE + PS> ./list-special-folders + + Folder Name Folder Path + ----------- ----------- + AdminTools ๐Ÿ“‚C:\Users\Markus\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function GetTempDir { + if ("$env:TEMP" -ne "") { return "$env:TEMP" } + if ("$env:TMP" -ne "") { return "$env:TMP" } + if ($IsLinux) { return "/tmp" } + return "C:\Temp" +} + +function AddLine { param([string]$FolderName, [string]$FolderPath) + New-Object PSObject -property @{ 'Folder Name' = "$FolderName"; 'Folder Path' = "๐Ÿ“‚$FolderPath" } +} + +function ListSpecialFolders { + if ($IsLinux) { + AddLine "Desktop" "$HOME/Desktop" + AddLine "Downloads" "$HOME/Downloads" + AddLine "Home Folder" "$HOME" + AddLine "MyDocuments" "$HOME/Documents" + AddLine "MyMusic" "$HOME/Music" + AddLine "MyPictures" "$HOME/Pictures" + AddLine "MyScreenshots" "$HOME/Pictures/Screenshots" + AddLine "MyVideos" "$HOME/Videos" + AddLine "Temporary Folder" "$(GetTempDir)" + $Path = Resolve-Path "$HOME/.." + AddLine "Users" "$Path" + } else { + $FolderNames = [System.Enum]::GetNames('System.Environment+SpecialFolder') + $FolderNames | Sort-Object | ForEach-Object { + if ($Path = [System.Environment]::GetFolderPath($_)) { + AddLine "$_" "$Path" + } + } + AddLine "TemporaryFolder" "$(GetTempDir)" + $Path = Resolve-Path "$HOME/.." + AddLine "Users" "$Path" + } +} + +try { + ListSpecialFolders | Format-Table -property @{e='Folder Name';width=22},'Folder Path' + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-special-folders.ps1* diff --git a/Docs/list-sql-tables.md b/Docs/list-sql-tables.md index ead744a4..cd1ae51a 100644 --- a/Docs/list-sql-tables.md +++ b/Docs/list-sql-tables.md @@ -1,4 +1,4 @@ -## list-sql-tables.ps1 - Lists all tables of a SQL server database +## The list-sql-tables.ps1 PowerShell Script This PowerShell script lists all tables in a SQL server database and exports the list as CSV. Install-Module InvokeQuery @@ -57,4 +57,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all tables of a SQL server database +.DESCRIPTION + This PowerShell script lists all tables in a SQL server database and exports the list as CSV. + Install-Module InvokeQuery + Run the above command if you do not have this module. +.EXAMPLE + PS> ./list-sql-tables +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param( +[Parameter(Mandatory=$true)]$server, +[Parameter(Mandatory=$true)]$database, +[Parameter(Mandatory=$true)]$username, +[Parameter(Mandatory=$true)]$password +) +$secpasswd = ConvertTo-SecureString $password -AsPlainText -Force +$creds = New-Object System.Management.Automation.PSCredential ($username, $secpasswd) +$csvfilepath = "$PSScriptRoot\sqlserver_tables.csv" +$result = Invoke-SqlServerQuery -Credential $creds -ConnectionTimeout 10000 -Database $database -Server $server -Sql "SELECT TABLE_NAME FROM $database.INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'" -CommandTimeout 10000 +$result | Export-Csv $csvfilepath -NoTypeInformation + *Generated by convert-ps2md.ps1 using the comment-based help of list-sql-tables.ps1* diff --git a/Docs/list-submodules.md b/Docs/list-submodules.md index 37413e02..8a643160 100644 --- a/Docs/list-submodules.md +++ b/Docs/list-submodules.md @@ -1,4 +1,4 @@ -## list-submodules.ps1 - Lists the submodules in a Git repository +## The list-submodules.ps1 PowerShell Script This PowerShell script lists the submodules in the given Git repository. @@ -32,4 +32,43 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the submodules in a Git repository +.DESCRIPTION + This PowerShell script lists the submodules in the given Git repository. +.PARAMETER RepoDir + Specifies the path to the repository (current working directory by default) +.EXAMPLE + PS> ./list-submodules C:\MyRepo +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RepoDir = "$PWD") + +try { + "โณ Step 1/3: Checking requirements... " + if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + + & git --version + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + "โณ Step 2/3: Fetching latest updates... " + & git -C "$RepoDir" fetch + if ($lastExitCode -ne "0") { throw "'git fetch' failed" } + + "โณ Step 3/3: Listing submodules... " + & git -C "$RepoDir" submodule + if ($lastExitCode -ne "0") { throw "'git submodule' failed" } + + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-submodules.ps1* diff --git a/Docs/list-suggestions.md b/Docs/list-suggestions.md index f720fbe5..8833b5ef 100644 --- a/Docs/list-suggestions.md +++ b/Docs/list-suggestions.md @@ -1,4 +1,4 @@ -## list-suggestions.ps1 - Lists suggestions +## The list-suggestions.ps1 PowerShell Script This PowerShell script lists "Did you mean?" suggestions from Google. @@ -35,4 +35,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists suggestions +.DESCRIPTION + This PowerShell script lists "Did you mean?" suggestions from Google. +.EXAMPLE + PS> ./list-suggestions Joe + joe biden + joe cocker + ... +.PARAMETER text + Specifies the word or sentence to get suggestions for. +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ("$text" -eq "") { $text = read-host "Enter a word or sentence to get suggestions for" } + $URI = [uri]::escapeuristring("suggestqueries.google.com/complete/search?client=firefox&q=$text") + $Content = (Invoke-WebRequest -URI $URI -useBasicParsing).Content + ($Content | ConvertFrom-Json).SyncRoot | Select-Object -Skip 1 + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-suggestions.ps1* diff --git a/Docs/list-system-info.md b/Docs/list-system-info.md index bb4e2698..30ddcc98 100644 --- a/Docs/list-system-info.md +++ b/Docs/list-system-info.md @@ -1,4 +1,4 @@ -## list-system-info.ps1 - Lists system information of the local computer +## The list-system-info.ps1 PowerShell Script This PowerShell script lists system information of the local computer. @@ -23,4 +23,114 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists system information of the local computer +.DESCRIPTION + This PowerShell script lists system information of the local computer. +.EXAMPLE + PS> ./list-system-info +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +# RAM +$RAM = Get-WmiObject -Query "SELECT TotalVisibleMemorySize, FreePhysicalMemory FROM Win32_OperatingSystem" + +$totalRAM = [math]::Round($RAM.TotalVisibleMemorySize/1MB, 2) +$freeRAM = [math]::Round($RAM.FreePhysicalMemory/1MB, 2) +$usedRAM = [math]::Round(($RAM.TotalVisibleMemorySize - $RAM.FreePhysicalMemory)/1MB, 2) + +# Operating System +$OS = Get-WmiObject -class Win32_OperatingSystem + +$OS_Name = $OS.Caption +$OS_InstallDate = $OS.ConvertToDateTime($OS.InstallDate) +$OS_LastBootUpTime = $OS.ConvertToDateTime($OS.LastBootUpTime) +$OS_Architecture = $OS.OSArchitecture +$OS_SystemDrive = $OS.SystemDrive +$OS_WindowsDirectory = $OS.WindowsDirectory +$OS_BuildNumber = $OS.BuildNumber +$OS_SerialNumber = $OS.SerialNumber +$OS_Version = $OS.Version +$OS_Manufacturer = $OS.Manufacturer + +# Computer System +$CS = Get-WmiObject -class Win32_ComputerSystem + +$CS_Name = $CS.Name +$CS_Owner = $CS.PrimaryOwnerName + +# CPU +$CPU = Get-WmiObject -class Win32_Processor + +$CPU_Name = $CPU.Name +$CPU_Manufacturer = $CPU.Manufacturer +$CPU_MaxClockSpeed = $CPU.MaxClockSpeed / 1000 +$CPU_Used = (Get-WmiObject win32_processor).LoadPercentage +$CPU_Free = 100 - $CPU_Used + +# Disk +$Disk = Get-WmiObject -class Win32_LogicalDisk -Filter "DeviceID='C:'" +$Disk_ID = $Disk.DeviceID +$Disk_TotalSpace = [math]::Round($Disk.Size/1GB, 2) +$Disk_FreeSpace = [math]::Round($Disk.FreeSpace/1GB, 2) +$Disk_UsedSpace = [math]::Round(($Disk.Size - $Disk.FreeSpace)/1GB, 2) + +# System Info +$systeminfo = systeminfo + +# IP Config +$ipconfig = ipconfig + +# Driver Query +$driverquery = driverquery + +# Running Services +$netstart = net start + +# Create info object +$infoprop = @{ + 'RAM_total'= $totalRAM; + 'RAM_free'= $freeRAM; + 'RAM_used'= $usedRAM; + 'OS_Name'= $OS_Name; + 'OS_InstallDate'= $OS_InstallDate; + 'OS_LastBootUpTime'= $OS_LastBootUpTime; + 'OS_Architecture'= $OS_Architecture; + 'OS_SystemDrive'= $OS_SystemDrive; + 'OS_WindowsDirectory'= $OS_WindowsDirectory; + 'OS_BuildNumber'= $OS_BuildNumber; + 'OS_SerialNumber'= $OS_SerialNumber; + 'OS_Version'= $OS_Version; + 'OS_Manufacturer'= $OS_Manufacturer; + 'CS_Name'= $CS_Name; + 'CS_Owner'= $CS_Owner; + 'CPU_Name'= $CPU_Name; + 'CPU_Manufacturer'= $CPU_Manufacturer; + 'CPU_MaxClockSpeed'= $CPU_MaxClockSpeed; + 'CPU_Used'= $CPU_Used; + 'CPU_Free'= $CPU_Free; + 'Disk_ID'= $Disk_ID; + 'Disk_TotalSpace'= $Disk_TotalSpace; + 'Disk_FreeSpace'= $Disk_FreeSpace; + 'Disk_UsedSpace'= $Disk_UsedSpace; + 'systeminfo'= $systeminfo; + 'ipconfig'= $ipconfig; + 'driverquery'= $driverquery; + 'netstart'= $netstart; +} + +$info = New-Object -TypeName PSObject -Prop $infoprop + +# Convert info to JSON +$info = $info | ConvertTo-JSON + +# Output +$info +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of list-system-info.ps1* diff --git a/Docs/list-tags.md b/Docs/list-tags.md index f137b6e0..81de2d61 100644 --- a/Docs/list-tags.md +++ b/Docs/list-tags.md @@ -1,4 +1,4 @@ -## list-tags.ps1 - Lists all tags in a Git repository +## The list-tags.ps1 PowerShell Script This PowerShell script lists all tags in a Git repository. @@ -48,4 +48,54 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all tags in a Git repository +.DESCRIPTION + This PowerShell script lists all tags in a Git repository. +.PARAMETER RepoDir + Specifies the path to the Git repository (current working directory by default) +.PARAMETER SearchPattern + Specifies the search pattern (anything by default) +.EXAMPLE + PS> ./list-tags C:\MyRepo + + Tag Description + --- ----------- + v0.1 Update README.md + v0.2 Fix typo +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RepoDir = "$PWD", [string]$SearchPattern="*") + +try { + Write-Progress "โณ (1/3) Searching for Git executable... " + $Null = (git --version) + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + Write-Progress "โณ (2/3) Checking folder... " + if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + + Write-Progress "โณ (3/3) Fetching latest tags..." + & git -C "$RepoDir" fetch --all --tags --quiet + if ($lastExitCode -ne "0") { throw "'git fetch --all --tags' failed" } + + Write-Progress -completed "Fetched" + "" + "Tag Description" + "--- -----------" + & git -C "$RepoDir" tag --list "$SearchPattern" -n + if ($lastExitCode -ne "0") { throw "'git tag --list' failed" } + + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-tags.ps1* diff --git a/Docs/list-tasks.md b/Docs/list-tasks.md index 16fcb7cc..7cdfc8ca 100644 --- a/Docs/list-tasks.md +++ b/Docs/list-tasks.md @@ -1,4 +1,6 @@ -## list-tasks.ps1 - list-tasks.ps1 +## The list-tasks.ps1 PowerShell Script + +list-tasks.ps1 ## Parameters @@ -10,4 +12,32 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Lists all scheduled tasks +.DESCRIPTION + This PowerShell script lists all scheduled tasks. +.EXAMPLE + PS> ./list-tasks + + TaskName State TaskPath + -------- ----- -------- + .NET Framework NGEN v4.0.30319 Ready \Microsoft\Windows\.NET Framework\ + .NET Framework NGEN v4.0.30319 64 Ready \Microsoft\Windows\.NET Framework\ + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-ScheduledTask | Format-Table -property TaskName,State,TaskPath + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-tasks.ps1* diff --git a/Docs/list-timezone.md b/Docs/list-timezone.md index e39198d0..c2bdb193 100644 --- a/Docs/list-timezone.md +++ b/Docs/list-timezone.md @@ -1,4 +1,4 @@ -## list-timezone.ps1 - Lists time zone details +## The list-timezone.ps1 PowerShell Script This PowerShell script lists the details of the current time zone. @@ -32,4 +32,34 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists time zone details +.DESCRIPTION + This PowerShell script lists the details of the current time zone. +.EXAMPLE + PS> ./list-timezone + + Id : Europe/Berlin + DisplayName : (UTC+01:00) Central European Standard Time + StandardName : Central European Standard Time + DaylightName : Central European Summer Time + BaseUtcOffset : 01:00:00 + SupportsDaylightSavingTime : True +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + [system.threading.thread]::currentThread.currentCulture = [system.globalization.cultureInfo]"en-US" + Get-Timezone + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-timezone.ps1* diff --git a/Docs/list-timezones.md b/Docs/list-timezones.md index ff7ebc06..ad028949 100644 --- a/Docs/list-timezones.md +++ b/Docs/list-timezones.md @@ -1,4 +1,4 @@ -## list-timezones.ps1 - Lists all available time zones +## The list-timezones.ps1 PowerShell Script This PowerShell script lists all available time zones. @@ -32,4 +32,33 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all available time zones +.DESCRIPTION + This PowerShell script lists all available time zones. +.EXAMPLE + PS> ./list-timezones + + Id DisplayName SupportsDaylight + SavingTime + -- ----------- ---------------- + Hawaiian Standard Time (UTC-10:00) Hawaii False + Alaskan Standard Time (UTC-09:00) Alaska True + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-Timezone -listavailable | Format-Table -property Id,DisplayName,SupportsDaylightSavingTime + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-timezones.ps1* diff --git a/Docs/list-tiobe-index.md b/Docs/list-tiobe-index.md index d448d6e7..07f9c4bb 100644 --- a/Docs/list-tiobe-index.md +++ b/Docs/list-tiobe-index.md @@ -1,4 +1,6 @@ -## list-tiobe-index.ps1 - list-tiobe-index.ps1 +## The list-tiobe-index.ps1 PowerShell Script + +list-tiobe-index.ps1 ## Parameters @@ -10,4 +12,65 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Lists the TIOBE index of top programming languages +.DESCRIPTION + This PowerShell script lists the TIOBE index of top programming languages. +.EXAMPLE + PS> ./list-tiobe-index +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function WriteBar { param([string]$Text, [float]$Value, [float]$Max, [float]$Change) + $Num = ($Value * 100.0) / $Max + while ($Num -ge 1.0) { + write-host -noNewLine "โ–ˆ" + $Num -= 1.0 + } + if ($Num -ge 0.875) { + write-host -noNewLine "โ–‰" + } elseif ($Num -ge 0.75) { + write-host -noNewLine "โ–Š" + } elseif ($Num -ge 0.625) { + write-host -noNewLine "โ–‹" + } elseif ($Num -ge 0.5) { + write-host -noNewLine "โ–Œ" + } elseif ($Num -ge 0.375) { + write-host -noNewLine "โ–" + } elseif ($Num -ge 0.25) { + write-host -noNewLine "โ–Ž" + } elseif ($Num -ge 0.125) { + write-host -noNewLine "โ–" + } + write-host -noNewLine " $Text $($Value)%" + if ($Change -ge 0.0) { + write-host -foregroundColor green " +$($Change)%" + } else { + write-host -foregroundColor red " $($Change)%" + } +} + +try { + & write-big.ps1 "TIOBE INDEX 2021-06" + " Source: https://www.tiobe.com" + "" + + $Table = import-csv "$PSScriptRoot/../Data/TIOBE-index.csv" + foreach($Row in $Table) { + [string]$Name = $Row.Language + [float]$Value = $Row.Popularity + [float]$Change = $Row.Change + WriteBar $Name $Value 14.0 $Change + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-tiobe-index.ps1* diff --git a/Docs/list-unused-files.md b/Docs/list-unused-files.md index 0ef39180..cd078559 100644 --- a/Docs/list-unused-files.md +++ b/Docs/list-unused-files.md @@ -1,4 +1,4 @@ -## list-unused-files.ps1 - Lists unused files in a directory tree +## The list-unused-files.ps1 PowerShell Script This PowerShell script scans and lists files in a folder with last access time older than number of days. @@ -41,4 +41,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists unused files in a directory tree +.DESCRIPTION + This PowerShell script scans and lists files in a folder with last access time older than number of days. +.PARAMETER DirTree + Specifies the path to the directory tree +.PARAMETER Days + Specifies the number of days +.EXAMPLE + PS> ./list-unused-files C:\ 100 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$DirTree = "", [int]$Days = 100) + +write-host "Listing files in $DirTree with last access time older than $Days days" + +try { + $cutOffDate = (Get-Date).AddDays(-$Days) + + Get-ChildItem -path $DirTree -recurse | Where-Object {$_.LastAccessTime -le $cutOffDate} | select fullname + + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-unused-files.ps1* diff --git a/Docs/list-user-accounts.md b/Docs/list-user-accounts.md index bb81ee9b..25981fc6 100644 --- a/Docs/list-user-accounts.md +++ b/Docs/list-user-accounts.md @@ -1,4 +1,4 @@ -## list-user-accounts.ps1 - Lists user accounts +## The list-user-accounts.ps1 PowerShell Script This PowerShell script lists the user accounts on the local computer. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists user accounts +.DESCRIPTION + This PowerShell script lists the user accounts on the local computer. +.EXAMPLE + PS> ./list-user-accounts +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + & net user + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-user-accounts.ps1* diff --git a/Docs/list-user-groups.md b/Docs/list-user-groups.md index 38b138d6..0873441e 100644 --- a/Docs/list-user-groups.md +++ b/Docs/list-user-groups.md @@ -1,4 +1,4 @@ -## list-user-groups.ps1 - Lists the user groups on the local computer +## The list-user-groups.ps1 PowerShell Script This PowerShell script lists the user groups on the local computer. @@ -31,4 +31,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the user groups on the local computer +.DESCRIPTION + This PowerShell script lists the user groups on the local computer. +.EXAMPLE + PS> ./list-user-groups + + Name Description + ---- ----------- + HomeUsers HomeUsers Security Group + Ssh Users Members of this group can remotely access this computer over SSH protocol. + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Get-LocalGroup + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-user-groups.ps1* diff --git a/Docs/list-voices.md b/Docs/list-voices.md index 7e79d1ec..43fe2204 100644 --- a/Docs/list-voices.md +++ b/Docs/list-voices.md @@ -1,4 +1,4 @@ -## list-voices.ps1 - Lists the installed text-to-speech voices +## The list-voices.ps1 PowerShell Script This PowerShell script lists the installed text-to-speech (TTS) voices. @@ -30,4 +30,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the installed text-to-speech voices +.DESCRIPTION + This PowerShell script lists the installed text-to-speech (TTS) voices. +.EXAMPLE + PS> ./list-voices + + Name Culture Gender Age + ---- ------- ------ --- + Microsoft David Desktop en-US Male Adult + ... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -Version 2.0 + +try { + Add-Type -AssemblyName System.Speech + $Synth = New-Object System.Speech.Synthesis.SpeechSynthesizer + $Synth.GetInstalledVoices() | + Select-Object -ExpandProperty VoiceInfo | + Select-Object -Property Name, Culture, Gender, Age + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-voices.ps1* diff --git a/Docs/list-weather.md b/Docs/list-weather.md index 3b2de5f5..ddc1a43b 100644 --- a/Docs/list-weather.md +++ b/Docs/list-weather.md @@ -1,4 +1,4 @@ -## list-weather.ps1 - Lists the weather report +## The list-weather.ps1 PowerShell Script This PowerShell script lists the hourly weather report. @@ -32,4 +32,75 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the weather report +.DESCRIPTION + This PowerShell script lists the hourly weather report. +.PARAMETER Location + Specifies the location to use (determined automatically per default) +.EXAMPLE + PS> ./list-weather +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Location = "") # empty means determine automatically + +function Describe { param([string]$Desc) + switch($Desc) { + "Clear" { return "๐ŸŒ™ clear " } + "Cloudy" { return "โ˜๏ธ cloudy " } + "Light drizzle" { return "๐Ÿ’ง light drizzle" } + "Light rain shower" { return "๐Ÿ’ง light rain " } + "Mist" { return "๐ŸŒซ misty " } + "Overcast" { return "โ˜๏ธ overcast " } + "Partly cloudy" { return "โ›…๏ธpartly cloudy" } + "Patchy light rain" { return "๐Ÿ’ง patchy light rain" } + "Patchy rain possible" { return "๐Ÿ’ง patchy rain possible" } + "Sunny" { return "โ˜€๏ธ sunny " } + "Thundery outbreaks possible" { return "โšก๏ธthundery outbreaks possible" } + default { return "$Desc" } + } +} + +try { + $Weather = (Invoke-WebRequest -URI http://wttr.in/${Location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json + $Area = $Weather.nearest_area.areaName.value + $Region = $Weather.nearest_area.region.value + $Country = $Weather.nearest_area.country.value + [int]$Day = 0 + foreach($Hourly in $Weather.weather.hourly) { + $Hour = $Hourly.time / 100 + $Temp = $Hourly.tempC + $Precip = $Hourly.precipMM + $Humidity = $Hourly.humidity + $Pressure = $Hourly.pressure + $WindSpeed = $Hourly.windspeedKmph + $WindDir = $Hourly.winddir16Point + $UV = $Hourly.uvIndex + $Clouds = $Hourly.cloudcover + $Desc = $Hourly.weatherDesc.value + if ($Hour -eq 0) { + if ($Day -eq 0) { + Write-Host -foregroundColor green "Today ๐ŸŒกยฐC โ˜‚๏ธmm ๐Ÿ’ง ๐Ÿ’จkm/h from โ˜€๏ธUV โ˜๏ธ at $Area ($Region, $Country)" + } elseif ($Day -eq 1) { + Write-Host -foregroundColor green "Tomorrow" + } else { + Write-Host -foregroundColor green "Day after tomorrow" + } + $Day++ + } + "$(($Hour.toString()).PadLeft(2))ยฐยฐ $(($Temp.toString()).PadLeft(2))ยฐ $($Precip) $(($Humidity.toString()).PadLeft(3))% $(($WindSpeed.toString()).PadLeft(2)) $WindDir`t$($UV) $(($Clouds.toString()).PadLeft(3))% $(Describe $Desc)" + $Hour++ + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-weather.ps1* diff --git a/Docs/list-wifi.md b/Docs/list-wifi.md index 8f8de75c..7da42e1c 100644 --- a/Docs/list-wifi.md +++ b/Docs/list-wifi.md @@ -1,4 +1,4 @@ -## list-wifi.ps1 - Lists WIFI +## The list-wifi.ps1 PowerShell Script This PowerShell script lists the WIFI networks. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists WIFI +.DESCRIPTION + This PowerShell script lists the WIFI networks. +.EXAMPLE + PS> ./list-wifi +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + & netsh wlan show profile + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-wifi.ps1* diff --git a/Docs/list-workdir.md b/Docs/list-workdir.md index 87aa1c06..a9606570 100644 --- a/Docs/list-workdir.md +++ b/Docs/list-workdir.md @@ -1,4 +1,4 @@ -## list-workdir.ps1 - Lists the current working directory +## The list-workdir.ps1 PowerShell Script This PowerShell script lists the current working directory (but not the content itself!) @@ -23,4 +23,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the current working directory +.DESCRIPTION + This PowerShell script lists the current working directory (but not the content itself!) +.EXAMPLE + PS> ./list-workdir +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $CWD = Resolve-Path "$PWD" + "๐Ÿ“‚$CWD" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of list-workdir.ps1* diff --git a/Docs/locate-city.md b/Docs/locate-city.md index 1ed28ff1..c21e1600 100644 --- a/Docs/locate-city.md +++ b/Docs/locate-city.md @@ -1,4 +1,4 @@ -## locate-city.ps1 - Prints the geographic location of a city +## The locate-city.ps1 PowerShell Script This PowerShell script prints the geographic location of the given city. @@ -32,4 +32,51 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Prints the geographic location of a city +.DESCRIPTION + This PowerShell script prints the geographic location of the given city. +.PARAMETER City + Specifies the city to look for +.EXAMPLE + PS> ./locate-city Paris +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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" + + $FoundOne = 0 + foreach($Row in $Table) { + if ($Row.city -eq $City) { + $FoundOne = 1 + $Country = $Row.country + $Region = $Row.admin_name + $Lat = $Row.lat + $Long = $Row.lng + $Population = $Row.population + write-host "* $City ($Country, $Region, population $Population) is at $LatยฐN, $LongยฐW" + } + } + + if ($FoundOne) { + exit 0 # success + } + write-error "City $City not found" + exit 1 +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of locate-city.ps1* diff --git a/Docs/locate-ipaddress.md b/Docs/locate-ipaddress.md index 982377f6..764e0d9b 100644 --- a/Docs/locate-ipaddress.md +++ b/Docs/locate-ipaddress.md @@ -1,4 +1,6 @@ -## locate-ipaddress.ps1 - locate-ipaddress.ps1 [[-IPaddress] ] +## The locate-ipaddress.ps1 PowerShell Script + +locate-ipaddress.ps1 [[-IPaddress] ] ## Parameters @@ -10,4 +12,33 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Prints the geo location of the given IP address +.DESCRIPTION + This PowerShell script prints the geographic location of the given IP address. +.PARAMTER IPaddress + Specifies the IP address +.EXAMPLE + PS> ./locate-ipaddress 177.144.67.98 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$IPaddress= "") + +try { + if ($IPaddress -eq "" ) { $IPaddress = read-host "Enter IP address to locate" } + + $result = Invoke-RestMethod -Method Get -Uri "http://ip-api.com/json/$IPaddress" + write-output $result + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of locate-ipaddress.ps1* diff --git a/Docs/locate-my-phone.md b/Docs/locate-my-phone.md index 3946fb59..f6146e51 100644 --- a/Docs/locate-my-phone.md +++ b/Docs/locate-my-phone.md @@ -1,4 +1,4 @@ -## locate-my-phone.ps1 - Opens Google Find My Device +## The locate-my-phone.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Find My Device website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Find My Device +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Find My Device website. +.EXAMPLE + PS> ./locate-my-phone +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://www.google.com/android/find" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of locate-my-phone.ps1* diff --git a/Docs/locate-zip-code.md b/Docs/locate-zip-code.md index 3f351049..0e9a13cf 100644 --- a/Docs/locate-zip-code.md +++ b/Docs/locate-zip-code.md @@ -1,4 +1,4 @@ -## locate-zip-code.ps1 - Prints the geo location of a zip-code +## The locate-zip-code.ps1 PowerShell Script This PowerShell script prints the geographic location of the given zip-code. @@ -41,4 +41,54 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Prints the geo location of a zip-code +.DESCRIPTION + This PowerShell script prints the geographic location of the given zip-code. +.PARAMETER CountryCode + Specifies the country code +.PARAMETER ZipCode + Specifies the zip code +.EXAMPLE + PS> ./locate-zip-code +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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" + + $FoundOne = 0 + foreach($Row in $Table) { + if ($Row.country -eq $CountryCode) { + if ($Row.postal_code -eq $ZipCode) { + $Country=$Row.country + $City = $Row.city + $Lat = $Row.latitude + $Lon = $Row.longitude + write-output "* $Country $ZipCode $City is at $LatยฐN, $LonยฐW" + $FoundOne = 1 + } + } + } + + if ($FoundOne) { + exit 0 # success + } + throw "Zip-code $ZipCode in country $CountryCode not found" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of locate-zip-code.ps1* diff --git a/Docs/lock-desktop.md b/Docs/lock-desktop.md index 954e25bc..5710a508 100644 --- a/Docs/lock-desktop.md +++ b/Docs/lock-desktop.md @@ -1,4 +1,4 @@ -## lock-desktop.ps1 - Locks the desktop +## The lock-desktop.ps1 PowerShell Script This PowerShell script locks the local computer desktop immediately. @@ -23,4 +23,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Locks the desktop +.DESCRIPTION + This PowerShell script locks the local computer desktop immediately. +.EXAMPLE + PS> ./lock-desktop +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Bye bye." + rundll32.exe user32.dll,LockWorkStation + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of lock-desktop.ps1* diff --git a/Docs/log-off.md b/Docs/log-off.md index 7826da30..e87e6d27 100644 --- a/Docs/log-off.md +++ b/Docs/log-off.md @@ -1,4 +1,4 @@ -## log-off.ps1 - Log off the current user +## The log-off.ps1 PowerShell Script This PowerShell script logs off the current Windows user. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Log off the current user +.DESCRIPTION + This PowerShell script logs off the current Windows user. +.EXAMPLE + PS> ./log-off +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Invoke-CimMethod -ClassName Win32_Operatingsystem -MethodName Win32Shutdown -Arguments @{ Flags = 0 } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of log-off.ps1* diff --git a/Docs/make-install.md b/Docs/make-install.md index 20e3d8c6..d2b4befa 100644 --- a/Docs/make-install.md +++ b/Docs/make-install.md @@ -1,4 +1,4 @@ -## make-install.ps1 - Copies newer EXE's + DLL's from the build directory to the installation directory +## The make-install.ps1 PowerShell Script This PowerShell script copies newer EXE's + DLL's from the build directory to the installation directory. @@ -23,4 +23,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Copies newer EXE's + DLL's from the build directory to the installation directory +.DESCRIPTION + This PowerShell script copies newer EXE's + DLL's from the build directory to the installation directory. +.EXAMPLE + PS> ./make-install +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +set SRC_DIR=%1 +set "DST_DIR=C:\Program Files\MyApp\bin" +set FILTER=*.exe *.dll +set OPTIONS=/E /njh /np + +try { + title Syncing to %DST_DIR% ... + robocopy %SRC_DIR% %DST_DIR% %FILTER% %OPTIONS% + + echo ------------------------------------------------------------------------------ + echo. + + "โœ”๏ธ synced to %DST_DIR%" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of make-install.ps1* diff --git a/Docs/merry-christmas.md b/Docs/merry-christmas.md index 352e08da..d5481ada 100644 --- a/Docs/merry-christmas.md +++ b/Docs/merry-christmas.md @@ -1,4 +1,4 @@ -## merry-christmas.ps1 - Replies to "Merry Christmas" +## The merry-christmas.ps1 PowerShell Script This PowerShell script replies to 'Merry Christmas' by text-to-speech (TTS). @@ -23,4 +23,23 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Replies to "Merry Christmas" +.DESCRIPTION + This PowerShell script replies to 'Merry Christmas' by text-to-speech (TTS). +.EXAMPLE + PS> ./merry-christmas +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +$Reply = "Merry Christmas to you too!", "Happy Christmas to you too!" | Get-Random + +& "$PSScriptRoot/give-reply.ps1" "$Reply" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of merry-christmas.ps1* diff --git a/Docs/minimize-all-windows.md b/Docs/minimize-all-windows.md index d6daafe9..f2cf8a16 100644 --- a/Docs/minimize-all-windows.md +++ b/Docs/minimize-all-windows.md @@ -1,4 +1,4 @@ -## minimize-all-windows.ps1 - Minimizes all windows +## The minimize-all-windows.ps1 PowerShell Script This PowerShell script minimizes all open windows. @@ -23,4 +23,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Minimizes all windows +.DESCRIPTION + This PowerShell script minimizes all open windows. +.EXAMPLE + PS> ./minimize-all-windows +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $shell = New-Object -ComObject "Shell.Application" + $shell.minimizeall() + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of minimize-all-windows.ps1* diff --git a/Docs/moon.md b/Docs/moon.md index cbef3dde..972a31fc 100644 --- a/Docs/moon.md +++ b/Docs/moon.md @@ -1,4 +1,4 @@ -## moon.ps1 - Prints the current moon phase +## The moon.ps1 PowerShell Script This PowerShell script prints the current moon phase. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Prints the current moon phase +.DESCRIPTION + This PowerShell script prints the current moon phase. +.EXAMPLE + PS> ./moon +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + (Invoke-WebRequest http://wttr.in/Moon -userAgent "curl" -useBasicParsing).Content + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of moon.ps1* diff --git a/Docs/my-profile.md b/Docs/my-profile.md index c173e0b7..078229c2 100644 --- a/Docs/my-profile.md +++ b/Docs/my-profile.md @@ -1,4 +1,6 @@ -## my-profile.ps1 - my-profile.ps1 +## The my-profile.ps1 PowerShell Script + +my-profile.ps1 ## Parameters @@ -10,4 +12,21 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +# MY POWERSHELL PROFILE (this profile file defines the look & feel of PowerShell) + +# WINDOW TITLE +if ($IsLinux) { $Username = $(whoami) } else { $Username = $env:USERNAME } +$host.ui.RawUI.WindowTitle = "$Username @ $(hostname)" + +# COMMAND PROMPT +function prompt { write-host -noNewline -foregroundColor yellow "`nโžค"; return " " } + +# ALIAS NAMES +del alias:pwd -force -errorAction SilentlyContinue +set-alias -name pwd -value list-workdir.ps1 # pwd = print working directory +set-alias -name ll -value get-childitem # ll = list folder (long format) +del alias:ls -force -errorAction SilentlyContinue +set-alias -name ls -value list-folder.ps1 # ls = list folder (short format) + *Generated by convert-ps2md.ps1 using the comment-based help of my-profile.ps1* diff --git a/Docs/new-branch.md b/Docs/new-branch.md index 9fc82569..b9edc673 100644 --- a/Docs/new-branch.md +++ b/Docs/new-branch.md @@ -1,4 +1,4 @@ -## new-branch.ps1 - Creates a new Git branch +## The new-branch.ps1 PowerShell Script This PowerShell script creates a new branch in a Git repository and switches to it. @@ -41,4 +41,64 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Creates a new Git branch +.DESCRIPTION + This PowerShell script creates a new branch in a Git repository and switches to it. +.PARAMETER NewBranchName + Specifies the new branch name +.PARAMETER RepoDir + Specifies the path to the Git repository (current working directory per default) +.EXAMPLE + PS> ./new-branch test123 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$NewBranchName = "", [string]$RepoDir = "$PWD") + +try { + if ($NewBranchName -eq "") { $NewBranchName = read-host "Enter new branch name" } + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + Write-Host "โณ (1/6) Searching for Git executable... " -noNewline + & git --version + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + $RepoDirName = (Get-Item "$RepoDir").Name + "โณ (2/6) Checking folder ๐Ÿ“‚$RepoDirName... " + if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + + "โณ (3/6) Fetching updates..." + & git -C "$RepoDir" fetch --all --recurse-submodules --prune --prune-tags --force + if ($lastExitCode -ne "0") { throw "'git fetch' failed with exit code $lastExitCode" } + + $CurrentBranchName = (git -C "$RepoDir" rev-parse --abbrev-ref HEAD) + if ($lastExitCode -ne "0") { throw "'git rev-parse' failed with exit code $lastExitCode" } + + "โณ (4/6) Creating branch '$NewBranchName'..." + & git -C "$RepoDir" checkout -b "$NewBranchName" + if ($lastExitCode -ne "0") { throw "'git checkout -b $NewBranchName' failed with exit code $lastExitCode" } + + "โณ (5/6) Pushing updates..." + & git -C "$RepoDir" push origin "$NewBranchName" + if ($lastExitCode -ne "0") { throw "'git push origin $NewBranchName' failed with exit code $lastExitCode" } + + "โณ (6/6) Updating submodules..." + & git -C "$RepoDir" submodule update --init --recursive + if ($lastExitCode -ne "0") { throw "'git submodule update' failed with exit code $lastExitCode" } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ created new '$NewBranchName' branch in ๐Ÿ“‚$RepoDirName repo in $Elapsed sec (based on '$CurrentBranchName' branch)" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of new-branch.ps1* diff --git a/Docs/new-email.md b/Docs/new-email.md index 80e595f4..bf6ac9d1 100644 --- a/Docs/new-email.md +++ b/Docs/new-email.md @@ -1,4 +1,4 @@ -## new-email.ps1 - Opens the default email client to write a new email +## The new-email.ps1 PowerShell Script This PowerShell script opens the default email client to write a new email. @@ -32,4 +32,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the default email client to write a new email +.DESCRIPTION + This PowerShell script opens the default email client to write a new email. +.PARAMETER EmailAddress + Specifies the email address fill in +.EXAMPLE + PS> ./new-email +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$EmailAddress = "markus@fleschutz.de") + +try { + $URL="mailto:$EmailAddress" + Start-Process $URL + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of new-email.ps1* diff --git a/Docs/new-qrcode.md b/Docs/new-qrcode.md index 8b3e3bdf..229503db 100644 --- a/Docs/new-qrcode.md +++ b/Docs/new-qrcode.md @@ -1,4 +1,4 @@ -## new-qrcode.ps1 - Generates a QR code +## The new-qrcode.ps1 PowerShell Script This PowerShell script generates a new QR code image file. @@ -41,4 +41,56 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Generates a QR code +.DESCRIPTION + This PowerShell script generates a new QR code image file. +.PARAMETER Text + Specifies the text to use +.PARAMETER ImageSize + Specifies the image size (width x height) +.EXAMPLE + PS> ./new-qrcode "Fasten seatbelt" 500x500 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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" + $BackgroundColor = "ffffff" + $FileFormat = "jpg" + if ($IsLinux) { + $PathToPics = Resolve-Path "$HOME/Pictures" + } else { + $PathToPics = [Environment]::GetFolderPath('MyPictures') + } + if (-not(Test-Path "$PathToPics" -pathType container)) { + throw "Pictures folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + $NewFile = "$PathToPics/QR_code.jpg" + + $WebClient = new-object System.Net.WebClient + $WebClient.DownloadFile(("http://api.qrserver.com/v1/create-qr-code/?data=" + $Text + "&ecc=" + $ECC +` + "&size=" + $ImageSize + "&qzone=" + $QuietZone + ` + "&color=" + $ForegroundColor + "&bgcolor=" + $BackgroundColor.Text + ` + "&format=" + $FileFormat), $NewFile) + + "โœ”๏ธ saved new QR code image file to: $NewFile" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of new-qrcode.ps1* diff --git a/Docs/new-script.md b/Docs/new-script.md index e13545dc..e3e8e7c2 100644 --- a/Docs/new-script.md +++ b/Docs/new-script.md @@ -1,4 +1,4 @@ -## new-script.ps1 - Creates a new PowerShell script file +## The new-script.ps1 PowerShell Script This PowerShell script creates a new PowerShell script file (by using template file ../Data/template.ps1). @@ -33,4 +33,35 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Creates a new PowerShell script file +.DESCRIPTION + This PowerShell script creates a new PowerShell script file (by using template file ../Data/template.ps1). +.PARAMETER filename + Specifies the path to the resulting file +.EXAMPLE + PS> ./new-script myscript.ps1 + โœ”๏ธ created new PowerShell script: myscript.ps1 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$filename = "") + +try { + if ($filename -eq "" ) { $shortcut = read-host "Enter the new filename" } + + copy-item "$PSScriptRoot/../Data/template.ps1" "$filename" + + "โœ”๏ธ created new PowerShell script: $filename" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of new-script.ps1* diff --git a/Docs/new-shortcut.md b/Docs/new-shortcut.md index c0620095..04a5d4d4 100644 --- a/Docs/new-shortcut.md +++ b/Docs/new-shortcut.md @@ -1,4 +1,4 @@ -## new-shortcut.ps1 - Creates a new shortcut file +## The new-shortcut.ps1 PowerShell Script This PowerShell script creates a new shortcut file. @@ -50,4 +50,46 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Creates a new shortcut file +.DESCRIPTION + This PowerShell script creates a new shortcut file. +.PARAMETER shortcut + Specifies the shortcut filename +.PARAMETER target + Specifies the path to the target +.PARAMETER description + Specifies a description +.EXAMPLE + PS> ./new-shortcut C:\Temp\HDD C:\ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$shortcut = "", [string]$target = "", [string]$description) + +try { + if ($shortcut -eq "" ) { $shortcut = read-host "Enter new shortcut filename" } + if ($target -eq "" ) { $target = read-host "Enter path to target" } + if ($description -eq "" ) { $description = read-host "Enter description" } + + $sh = new-object -ComObject WScript.Shell + $sc = $sh.CreateShortcut("$shortcut.lnk") + $sc.TargetPath = "$target" + $sc.WindowStyle = "1" + $sc.IconLocation = "C:\Windows\System32\SHELL32.dll, 3" + $sc.Description = "$description" + $sc.save() + + "โœ”๏ธ created new shortcut $shortcut โญข $target" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of new-shortcut.ps1* diff --git a/Docs/new-symlink.md b/Docs/new-symlink.md index 793c42ac..0fec55bd 100644 --- a/Docs/new-symlink.md +++ b/Docs/new-symlink.md @@ -1,4 +1,6 @@ -## new-symlink.ps1 - +## The new-symlink.ps1 PowerShell Script + + ## Parameters ```powershell @@ -9,4 +11,37 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Creates a new symbolic link file +.DESCRIPTION + This PowerShell script creates a new symbolic link file. +.PARAMETER symlink + Specifies the new symlink filename +.PARAMETER target + Specifies the path to target +.EXAMPLE + PS> ./new-symlink C:\Temp\HDD C:\ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$symlink = "", $[string]target = "") + +try { + if ($symlink -eq "" ) { $symlink = read-host "Enter new symlink filename" } + if ($target -eq "" ) { $target = read-host "Enter path to target" } + + new-item -path "$symlink" -itemType SymbolicLink -Value "$target" + + "โœ”๏ธ created new symlink $symlink โญข $target" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of new-symlink.ps1* diff --git a/Docs/new-tag.md b/Docs/new-tag.md index 30521420..50b336a5 100644 --- a/Docs/new-tag.md +++ b/Docs/new-tag.md @@ -1,4 +1,4 @@ -## new-tag.ps1 - Creates a new tag in a Git repository +## The new-tag.ps1 PowerShell Script This PowerShell script creates a new tag in a Git repository. @@ -41,4 +41,56 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Creates a new tag in a Git repository +.DESCRIPTION + This PowerShell script creates a new tag in a Git repository. +.PARAMETER TagName + Specifies the new tag name +.PARAMETER RepoDir + Specifies the path to the Git repository +.EXAMPLE + PS> ./create-tag v1.7 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$TagName = "", [string]$RepoDir = "$PWD") + +try { + if ($TagName -eq "") { $TagName = read-host "Enter new tag name" } + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + set-location "$RepoDir" + + $Null = (git --version) + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + $Result = (git status) + if ($lastExitCode -ne "0") { throw "'git status' failed in $RepoDir" } + if ("$Result" -notmatch "nothing to commit, working tree clean") { throw "Repository is NOT clean: $Result" } + + & "$PSScriptRoot/fetch-repo.ps1" + if ($lastExitCode -ne "0") { throw "Script 'fetch-repo.ps1' failed" } + + & git tag "$TagName" + if ($lastExitCode -ne "0") { throw "Error: 'git tag $TagName' failed!" } + + & git push origin "$TagName" + if ($lastExitCode -ne "0") { throw "Error: 'git push origin $TagName' failed!" } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ created new tag '$TagName' in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of new-tag.ps1* diff --git a/Docs/new-user.md b/Docs/new-user.md index 8c6522de..a5b751b7 100644 --- a/Docs/new-user.md +++ b/Docs/new-user.md @@ -1,4 +1,4 @@ -## new-user.ps1 - Creates a new user account +## The new-user.ps1 PowerShell Script This PowerShell script creates a new user account. @@ -31,4 +31,38 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Creates a new user account +.DESCRIPTION + This PowerShell script creates a new user account. +.EXAMPLE + PS> ./new-user +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Username = "") + +try { + if ($Username -eq "") { $Username = read-host "Enter new user name" } + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + if ($IsLinux) { + & sudo adduser --encrypt-home $Username + } else { + throw "Not supported yet" + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ created new user '$Username' with encrypted home directory in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of new-user.ps1* diff --git a/Docs/new-zipfile.md b/Docs/new-zipfile.md index a2323f94..f133ed28 100644 --- a/Docs/new-zipfile.md +++ b/Docs/new-zipfile.md @@ -1,4 +1,4 @@ -## new-zipfile.ps1 - Creates a new .ZIP file from a folder (including subfolders) +## The new-zipfile.ps1 PowerShell Script This PowerShell script creates a new .ZIP file from a folder (including subfolders). @@ -32,4 +32,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Creates a new .ZIP file from a folder (including subfolders) +.DESCRIPTION + This PowerShell script creates a new .ZIP file from a folder (including subfolders). +.PARAMETER folder + Specifies the path to the folder +.EXAMPLE + PS> ./new-zipfile C:\Windows +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$folder = "") + +try { + if ($folder -eq "" ) { $folder = read-host "Enter the path to the folder to zip" } + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + $folder = resolve-path $folder + compress-archive -path $folder -destinationPath $folder.zip + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ created zip file $($folder).zip in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of new-zipfile.ps1* diff --git a/Docs/open-accu-weather.md b/Docs/open-accu-weather.md index 0d0705e9..9b15cbf9 100644 --- a/Docs/open-accu-weather.md +++ b/Docs/open-accu-weather.md @@ -1,4 +1,4 @@ -## open-accu-weather.ps1 - Opens the AccuWeather website +## The open-accu-weather.ps1 PowerShell Script This PowerShell script launches the Web browser with the AccuWeather website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the AccuWeather website +.DESCRIPTION + This PowerShell script launches the Web browser with the AccuWeather website. +.EXAMPLE + PS> ./open-accu-weather +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://www.accuweather.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-accu-weather.ps1* diff --git a/Docs/open-air-b-n-b.md b/Docs/open-air-b-n-b.md index a4510490..d70a125d 100644 --- a/Docs/open-air-b-n-b.md +++ b/Docs/open-air-b-n-b.md @@ -1,4 +1,4 @@ -## open-air-b-n-b.ps1 - Opens the AirBNB website +## The open-air-b-n-b.ps1 PowerShell Script This PowerShell script launches the Web browser with the AirBNB website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the AirBNB website +.DESCRIPTION + This PowerShell script launches the Web browser with the AirBNB website. +.EXAMPLE + PS> ./open-air-b-n-b +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://www.airbnb.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-air-b-n-b.ps1* diff --git a/Docs/open-apps-folder.md b/Docs/open-apps-folder.md index edafaeee..9f140117 100644 --- a/Docs/open-apps-folder.md +++ b/Docs/open-apps-folder.md @@ -1,4 +1,4 @@ -## open-apps-folder.ps1 - Opens the Apps folder +## The open-apps-folder.ps1 PowerShell Script This PowerShell script launches the File Explorer showing the UWP apps folder. @@ -23,4 +23,22 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the Apps folder +.DESCRIPTION + This PowerShell script launches the File Explorer showing the UWP apps folder. +.EXAMPLE + PS> ./open-apps-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-file-explorer.ps1" "shell:AppsFolder" +exit 0 # success + + *Generated by convert-ps2md.ps1 using the comment-based help of open-apps-folder.ps1* diff --git a/Docs/open-auto-start-folder.md b/Docs/open-auto-start-folder.md index 0c5cdcea..64f90424 100644 --- a/Docs/open-auto-start-folder.md +++ b/Docs/open-auto-start-folder.md @@ -1,4 +1,4 @@ -## open-auto-start-folder.ps1 - Opens the autostart folder +## The open-auto-start-folder.ps1 PowerShell Script This PowerShell script launches the File Explorer with the user's autostart folder. @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the autostart folder +.DESCRIPTION + This PowerShell script launches the File Explorer with the user's autostart folder. +.EXAMPLE + PS> ./open-auto-start-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $TargetDir = resolve-path "$HOME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup" + if (-not(test-path "$TargetDir" -pathType container)) { + throw "Autostart folder at ๐Ÿ“‚$TargetDir doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-auto-start-folder.ps1* diff --git a/Docs/open-bing-maps.md b/Docs/open-bing-maps.md index fb41cdcb..1b88e4e8 100644 --- a/Docs/open-bing-maps.md +++ b/Docs/open-bing-maps.md @@ -1,4 +1,4 @@ -## open-bing-maps.ps1 - Launches the Bing Maps app +## The open-bing-maps.ps1 PowerShell Script This PowerShell script launches the Bing Maps application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Bing Maps app +.DESCRIPTION + This PowerShell script launches the Bing Maps application. +.EXAMPLE + PS> ./open-bing-maps +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + start-process bingmaps: + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-bing-maps.ps1* diff --git a/Docs/open-booking-com.md b/Docs/open-booking-com.md index 257c2078..363d2adb 100644 --- a/Docs/open-booking-com.md +++ b/Docs/open-booking-com.md @@ -1,4 +1,4 @@ -## open-booking-com.ps1 - Opens the Booking.com website +## The open-booking-com.ps1 PowerShell Script This PowerShell script launches the Web browser with the Booking.com website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the Booking.com website +.DESCRIPTION + This PowerShell script launches the Web browser with the Booking.com website. +.EXAMPLE + PS> ./open-booking-com +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://www.booking.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-booking-com.ps1* diff --git a/Docs/open-c-drive.md b/Docs/open-c-drive.md index acef153a..7b446ff3 100644 --- a/Docs/open-c-drive.md +++ b/Docs/open-c-drive.md @@ -1,4 +1,4 @@ -## open-c-drive.ps1 - Opens the C: drive folder +## The open-c-drive.ps1 PowerShell Script This PowerShell script launches the File Explorer with the C: drive folder. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the C: drive folder +.DESCRIPTION + This PowerShell script launches the File Explorer with the C: drive folder. +.EXAMPLE + PS> ./open-c-drive +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-file-explorer.ps1" "C:" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-c-drive.ps1* diff --git a/Docs/open-calculator.md b/Docs/open-calculator.md index 30aa1a92..5b8cc12a 100644 --- a/Docs/open-calculator.md +++ b/Docs/open-calculator.md @@ -1,4 +1,4 @@ -## open-calculator.ps1 - Launches the calculator application +## The open-calculator.ps1 PowerShell Script This PowerShell script launches the calculator application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the calculator application +.DESCRIPTION + This PowerShell script launches the calculator application. +.EXAMPLE + PS> ./open-calculator +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Start-Process ms-calculator: + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-calculator.ps1* diff --git a/Docs/open-chrome.md b/Docs/open-chrome.md index a890c687..0829105f 100644 --- a/Docs/open-chrome.md +++ b/Docs/open-chrome.md @@ -1,4 +1,4 @@ -## open-chrome.ps1 - Launches the Chrome browser +## The open-chrome.ps1 PowerShell Script This PowerShell script launches the Google Chrome Web browser. @@ -32,4 +32,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Chrome browser +.DESCRIPTION + This PowerShell script launches the Google Chrome Web browser. +.EXAMPLE + PS> ./open-chrome +.PARAMETER URL + Specifies an optional URL +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$URL = "http://www.fleschutz.de") + +try { + Start-Process chrome.exe "$URL" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-chrome.ps1* diff --git a/Docs/open-clock.md b/Docs/open-clock.md index 32bbe452..0852b59d 100644 --- a/Docs/open-clock.md +++ b/Docs/open-clock.md @@ -1,4 +1,4 @@ -## open-clock.ps1 - Launches the Clock app +## The open-clock.ps1 PowerShell Script This PowerShell script launches the Clock application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Clock app +.DESCRIPTION + This PowerShell script launches the Clock application. +.EXAMPLE + PS> ./open-clock +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Start-Process ms-clock: + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-clock.ps1* diff --git a/Docs/open-cortana.md b/Docs/open-cortana.md index 00c97d35..748e0fc4 100644 --- a/Docs/open-cortana.md +++ b/Docs/open-cortana.md @@ -1,4 +1,4 @@ -## open-cortana.ps1 - Launches the Cortana app +## The open-cortana.ps1 PowerShell Script This PowerShell script launches the Cortana application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Cortana app +.DESCRIPTION + This PowerShell script launches the Cortana application. +.EXAMPLE + PS> ./open-cortana +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Start-Process ms-cortana2: + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-cortana.ps1* diff --git a/Docs/open-d-drive.md b/Docs/open-d-drive.md index a28e1c62..b20a7beb 100644 --- a/Docs/open-d-drive.md +++ b/Docs/open-d-drive.md @@ -1,4 +1,4 @@ -## open-d-drive.ps1 - Opens the D: drive folder +## The open-d-drive.ps1 PowerShell Script This PowerShell script launches the File Explorer with the D: drive folder. @@ -23,4 +23,20 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the D: drive folder +.DESCRIPTION + This PowerShell script launches the File Explorer with the D: drive folder. +.EXAMPLE + PS> ./open-d-drive +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-file-explorer.ps1" "D:" + *Generated by convert-ps2md.ps1 using the comment-based help of open-d-drive.ps1* diff --git a/Docs/open-deep-l-translator.md b/Docs/open-deep-l-translator.md index cbe5eb62..25cc1f2a 100644 --- a/Docs/open-deep-l-translator.md +++ b/Docs/open-deep-l-translator.md @@ -1,4 +1,4 @@ -## open-deep-l-translator.ps1 - Opens the DeepL Translator website +## The open-deep-l-translator.ps1 PowerShell Script This PowerShell script launches the Web browser with the DeepL Translator website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the DeepL Translator website +.DESCRIPTION + This PowerShell script launches the Web browser with the DeepL Translator website. +.EXAMPLE + PS> ./open-deep-l-translator +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://www.deepl.com/translator" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-deep-l-translator.ps1* diff --git a/Docs/open-default-browser.md b/Docs/open-default-browser.md index 2797e538..ae331418 100644 --- a/Docs/open-default-browser.md +++ b/Docs/open-default-browser.md @@ -1,4 +1,4 @@ -## open-default-browser.ps1 - Opens the default browser +## The open-default-browser.ps1 PowerShell Script This PowerShell script launches the default Web browser, optional with a given URL. @@ -32,4 +32,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the default browser +.DESCRIPTION + This PowerShell script launches the default Web browser, optional with a given URL. +.PARAMETER URL + Specifies the URL +.EXAMPLE + PS> ./open-default-browser +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$URL = "http://www.fleschutz.de") + +try { + Start-Process $URL + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-default-browser.ps1* diff --git a/Docs/open-desktop-folder.md b/Docs/open-desktop-folder.md index 5630caa0..d3510e47 100644 --- a/Docs/open-desktop-folder.md +++ b/Docs/open-desktop-folder.md @@ -1,4 +1,4 @@ -## open-desktop-folder.ps1 - Opens the desktop folder +## The open-desktop-folder.ps1 PowerShell Script This PowerShell script launches the File Explorer with the user's desktop folder. @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the desktop folder +.DESCRIPTION + This PowerShell script launches the File Explorer with the user's desktop folder. +.EXAMPLE + PS> ./open-desktop-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $TargetDir = resolve-path "$HOME/Desktop" + if (-not(test-path "$TargetDir" -pathType container)) { + throw "Desktop folder at ๐Ÿ“‚$TargetDir doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-desktop-folder.ps1* diff --git a/Docs/open-documents-folder.md b/Docs/open-documents-folder.md index a9a5e932..17187650 100644 --- a/Docs/open-documents-folder.md +++ b/Docs/open-documents-folder.md @@ -1,4 +1,4 @@ -## open-documents-folder.ps1 - Opens the documents folder +## The open-documents-folder.ps1 PowerShell Script This PowerShell script launches the File Explorer with the user's documents folder. @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the documents folder +.DESCRIPTION + This PowerShell script launches the File Explorer with the user's documents folder. +.EXAMPLE + PS> ./open-documents-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $TargetDir = resolve-path "$HOME/Documents" + if (-not(test-path "$TargetDir" -pathType container)) { + throw "Documents folder at ๐Ÿ“‚$TargetDir doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-documents-folder.ps1* diff --git a/Docs/open-downloads-folder.md b/Docs/open-downloads-folder.md index c22b0d1c..84dc53a3 100644 --- a/Docs/open-downloads-folder.md +++ b/Docs/open-downloads-folder.md @@ -1,4 +1,4 @@ -## open-downloads-folder.ps1 - Opens the user's downloads folder +## The open-downloads-folder.ps1 PowerShell Script This PowerShell script launches the File Explorer showing the user's downloads folder. @@ -23,4 +23,34 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the user's downloads folder +.DESCRIPTION + This PowerShell script launches the File Explorer showing the user's downloads folder. +.EXAMPLE + PS> ./open-downloads-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + if ($IsLinux) { + $Path = Resolve-Path "$HOME/Downloads" + } else { + $Path = (New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path + } + if (-not(Test-Path "$Path" -pathType container)) { + throw "Downloads folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" $Path + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-downloads-folder.ps1* diff --git a/Docs/open-dropbox-folder.md b/Docs/open-dropbox-folder.md index 473f1c26..974c837b 100644 --- a/Docs/open-dropbox-folder.md +++ b/Docs/open-dropbox-folder.md @@ -1,4 +1,4 @@ -## open-dropbox-folder.ps1 - Opens the Dropbox folder +## The open-dropbox-folder.ps1 PowerShell Script This PowerShell script launches the File Explorer with the user's Dropbox folder. @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the Dropbox folder +.DESCRIPTION + This PowerShell script launches the File Explorer with the user's Dropbox folder. +.EXAMPLE + PS> ./open-dropbox-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $TargetDirs = resolve-path "$HOME/Dropbox*" + foreach($TargetDir in $TargetDirs) { + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success + } + throw "No Dropbox folder at ๐Ÿ“‚$HOME/Dropbox" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-dropbox-folder.ps1* diff --git a/Docs/open-duck-duck-go.md b/Docs/open-duck-duck-go.md index fd9697a9..63e2976f 100644 --- a/Docs/open-duck-duck-go.md +++ b/Docs/open-duck-duck-go.md @@ -1,4 +1,4 @@ -## open-duck-duck-go.ps1 - Opens the DuckDuckGo website +## The open-duck-duck-go.ps1 PowerShell Script This PowerShell script launches the Web browser with the DuckDuckGo website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the DuckDuckGo website +.DESCRIPTION + This PowerShell script launches the Web browser with the DuckDuckGo website. +.EXAMPLE + PS> ./open-duck-duck-go +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://duckduckgo.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-duck-duck-go.ps1* diff --git a/Docs/open-e-drive.md b/Docs/open-e-drive.md index 885ec887..52f07fed 100644 --- a/Docs/open-e-drive.md +++ b/Docs/open-e-drive.md @@ -1,4 +1,4 @@ -## open-e-drive.ps1 - Opens the E: drive folder +## The open-e-drive.ps1 PowerShell Script This PowerShell script launches the File Explorer with the E: drive folder. @@ -23,4 +23,20 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the E: drive folder +.DESCRIPTION + This PowerShell script launches the File Explorer with the E: drive folder. +.EXAMPLE + PS> ./open-e-drive +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-file-explorer.ps1" "E:" + *Generated by convert-ps2md.ps1 using the comment-based help of open-e-drive.ps1* diff --git a/Docs/open-edge.md b/Docs/open-edge.md index 02cd3cfe..352cc61f 100644 --- a/Docs/open-edge.md +++ b/Docs/open-edge.md @@ -1,4 +1,4 @@ -## open-edge.ps1 - Launches the Edge browser +## The open-edge.ps1 PowerShell Script This PowerShell script launches the Microsoft Edge Web browser. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Edge browser +.DESCRIPTION + This PowerShell script launches the Microsoft Edge Web browser. +.EXAMPLE + PS> ./open-edge +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +Start-Process microsoft-edge:// +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-edge.ps1* diff --git a/Docs/open-egg-timer.md b/Docs/open-egg-timer.md index 3d5f03d9..bf45a7f5 100644 --- a/Docs/open-egg-timer.md +++ b/Docs/open-egg-timer.md @@ -1,4 +1,4 @@ -## open-egg-timer.ps1 - Opens an egg timer +## The open-egg-timer.ps1 PowerShell Script This PowerShell script launches the Web browser with the eggtimer website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens an egg timer +.DESCRIPTION + This PowerShell script launches the Web browser with the eggtimer website. +.EXAMPLE + PS> ./open-egg-timer +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://e.ggtimer.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-egg-timer.ps1* diff --git a/Docs/open-email-client.md b/Docs/open-email-client.md index 7aeb3902..518fa36d 100644 --- a/Docs/open-email-client.md +++ b/Docs/open-email-client.md @@ -1,4 +1,4 @@ -## open-email-client.ps1 - Starts the default email client +## The open-email-client.ps1 PowerShell Script This PowerShell script launches the default email client. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Starts the default email client +.DESCRIPTION + This PowerShell script launches the default email client. +.EXAMPLE + PS> ./open-email-client +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + start-process "mailto:markus@fleschutz.de" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-email-client.ps1* diff --git a/Docs/open-f-drive.md b/Docs/open-f-drive.md index 241e1a2b..fd9ea0bd 100644 --- a/Docs/open-f-drive.md +++ b/Docs/open-f-drive.md @@ -1,4 +1,4 @@ -## open-f-drive.ps1 - Opens the F: drive folder +## The open-f-drive.ps1 PowerShell Script This PowerShell script launches the File Explorer with the F: drive folder. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the F: drive folder +.DESCRIPTION + This PowerShell script launches the File Explorer with the F: drive folder. +.EXAMPLE + PS> ./open-f-drive +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-file-explorer.ps1" "F:" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-f-drive.ps1* diff --git a/Docs/open-file-explorer.md b/Docs/open-file-explorer.md index 88539da0..e1c1fa91 100644 --- a/Docs/open-file-explorer.md +++ b/Docs/open-file-explorer.md @@ -1,4 +1,4 @@ -## open-file-explorer.ps1 - Launches the File Explorer +## The open-file-explorer.ps1 PowerShell Script This PowerShell script launches the File Explorer. @@ -32,4 +32,34 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the File Explorer +.DESCRIPTION + This PowerShell script launches the File Explorer. +.EXAMPLE + PS> ./open-file-explorer +.PARAMETER Path + Specifies the path to the folder to display +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Path = "") + +try { + if ("$Path" -ne "") { + start-process explorer.exe "$Path" + } else { + start-process explorer.exe + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-file-explorer.ps1* diff --git a/Docs/open-fire-place.md b/Docs/open-fire-place.md index 72a01b1c..374a5825 100644 --- a/Docs/open-fire-place.md +++ b/Docs/open-fire-place.md @@ -1,4 +1,4 @@ -## open-fire-place.ps1 - Opens a fire place website +## The open-fire-place.ps1 PowerShell Script This PowerShell script launches the Web browser with a fire place website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens a fire place website +.DESCRIPTION + This PowerShell script launches the Web browser with a fire place website. +.EXAMPLE + PS> ./open-fire-place +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://freefireplaces.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-fire-place.ps1* diff --git a/Docs/open-firefox.md b/Docs/open-firefox.md index c8e3cca8..a79721be 100644 --- a/Docs/open-firefox.md +++ b/Docs/open-firefox.md @@ -1,4 +1,4 @@ -## open-firefox.ps1 - Launches the Firefox browser +## The open-firefox.ps1 PowerShell Script This PowerShell script launches the Mozilla Firefox Web browser. @@ -32,4 +32,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Firefox browser +.DESCRIPTION + This PowerShell script launches the Mozilla Firefox Web browser. +.EXAMPLE + PS> ./open-firefox +.PARAMETER URL + Specifies an URL +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$URL = "http://www.fleschutz.de") + +try { + $App = Get-AppxPackage -Name Mozilla.FireFox + if ($App.Status -eq "Ok") { + # starting Firefox UWP app: + explorer.exe shell:appsFolder\$($App.PackageFamilyName)!FIREFOX + } else { + # starting Firefox program: + start-process firefox.exe "$URL" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-firefox.ps1* diff --git a/Docs/open-flight-radar.md b/Docs/open-flight-radar.md index c9c30a84..f5a81f27 100644 --- a/Docs/open-flight-radar.md +++ b/Docs/open-flight-radar.md @@ -1,4 +1,4 @@ -## open-flight-radar.ps1 - Opens FlightRadar24 +## The open-flight-radar.ps1 PowerShell Script This PowerShell script launches the Web browser with the FlightRadar24 website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens FlightRadar24 +.DESCRIPTION + This PowerShell script launches the Web browser with the FlightRadar24 website. +.EXAMPLE + PS> ./open-flight-radar +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://www.flightradar24.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-flight-radar.ps1* diff --git a/Docs/open-g-drive.md b/Docs/open-g-drive.md index 78499cb3..e9cd4cb9 100644 --- a/Docs/open-g-drive.md +++ b/Docs/open-g-drive.md @@ -1,4 +1,4 @@ -## open-g-drive.ps1 - Opens the G: drive folder +## The open-g-drive.ps1 PowerShell Script This PowerShell script launches the File Explorer with the G: drive folder. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the G: drive folder +.DESCRIPTION + This PowerShell script launches the File Explorer with the G: drive folder. +.EXAMPLE + PS> ./open-g-drive +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-file-explorer.ps1" "G:" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-g-drive.ps1* diff --git a/Docs/open-git-extensions.md b/Docs/open-git-extensions.md index 31e24311..86e29e4b 100644 --- a/Docs/open-git-extensions.md +++ b/Docs/open-git-extensions.md @@ -1,4 +1,6 @@ -## open-git-extensions.ps1 - open-git-extensions.ps1 +## The open-git-extensions.ps1 PowerShell Script + +open-git-extensions.ps1 ## Parameters @@ -10,4 +12,35 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Launches Git Extensions +.DESCRIPTION + This PowerShell script launches the Git Extensions application. +.EXAMPLE + PS> ./open-git-extensions +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function TryToExec { param($Folder, $Binary) + if (test-path "$Folder/$Binary" -pathType leaf) { + start-process "$Folder/$Binary" -WorkingDirectory "$Folder" + exit 0 # success + } +} + +try { + TryToExec "C:\Program Files (x86)\GitExtensions" "GitExtensions.exe" + TryToExec "C:\Program Files\GitExtensions" "GitExtensions.exe" + & "$PSScriptRoot/give-reply.ps1" "Sorry, can't find Git Extensions." + exit 1 +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-git-extensions.ps1* diff --git a/Docs/open-google-books.md b/Docs/open-google-books.md index 976ace19..c58f0f74 100644 --- a/Docs/open-google-books.md +++ b/Docs/open-google-books.md @@ -1,4 +1,4 @@ -## open-google-books.ps1 - Opens Google Books +## The open-google-books.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Books website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Books +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Books website. +.EXAMPLE + PS> ./open-google-books +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://books.google.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-books.ps1* diff --git a/Docs/open-google-calendar.md b/Docs/open-google-calendar.md index ca3b6cd0..27d4f4de 100644 --- a/Docs/open-google-calendar.md +++ b/Docs/open-google-calendar.md @@ -1,4 +1,4 @@ -## open-google-calendar.ps1 - Opens Google Calendar +## The open-google-calendar.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Calendar website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Calendar +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Calendar website. +.EXAMPLE + PS> ./open-google-calendar +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://calendar.google.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-calendar.ps1* diff --git a/Docs/open-google-contacts.md b/Docs/open-google-contacts.md index bace9b4e..28e0eefa 100644 --- a/Docs/open-google-contacts.md +++ b/Docs/open-google-contacts.md @@ -1,4 +1,4 @@ -## open-google-contacts.ps1 - Opens Google Contacts +## The open-google-contacts.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Contacts website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Contacts +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Contacts website. +.EXAMPLE + PS> ./open-google-contacts +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://contacts.google.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-contacts.ps1* diff --git a/Docs/open-google-docs.md b/Docs/open-google-docs.md index 7932a900..41e759e7 100644 --- a/Docs/open-google-docs.md +++ b/Docs/open-google-docs.md @@ -1,4 +1,4 @@ -## open-google-docs.ps1 - Opens Google Docs +## The open-google-docs.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Docs website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Docs +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Docs website. +.EXAMPLE + PS> ./open-google-docs +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://docs.google.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-docs.ps1* diff --git a/Docs/open-google-earth.md b/Docs/open-google-earth.md index e1952b6e..e0cfb03a 100644 --- a/Docs/open-google-earth.md +++ b/Docs/open-google-earth.md @@ -1,4 +1,4 @@ -## open-google-earth.ps1 - Opens Google Earth +## The open-google-earth.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Earth website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Earth +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Earth website. +.EXAMPLE + PS> ./open-google-earth +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://earth.google.com/web/" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-earth.ps1* diff --git a/Docs/open-google-mail.md b/Docs/open-google-mail.md index ff31e2f1..21582ba1 100644 --- a/Docs/open-google-mail.md +++ b/Docs/open-google-mail.md @@ -1,4 +1,4 @@ -## open-google-mail.ps1 - Opens Google Mail +## The open-google-mail.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Mail website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Mail +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Mail website. +.EXAMPLE + PS> ./open-google-mail +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://mail.google.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-mail.ps1* diff --git a/Docs/open-google-maps.md b/Docs/open-google-maps.md index b1886496..34ef558f 100644 --- a/Docs/open-google-maps.md +++ b/Docs/open-google-maps.md @@ -1,4 +1,4 @@ -## open-google-maps.ps1 - Opens Google Maps +## The open-google-maps.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Maps website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Maps +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Maps website. +.EXAMPLE + PS> ./open-google-maps +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://www.google.com/maps" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-maps.ps1* diff --git a/Docs/open-google-news.md b/Docs/open-google-news.md index 69eba14f..64874dfc 100644 --- a/Docs/open-google-news.md +++ b/Docs/open-google-news.md @@ -1,4 +1,4 @@ -## open-google-news.ps1 - Opens Google News +## The open-google-news.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google News website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google News +.DESCRIPTION + This PowerShell script launches the Web browser with the Google News website. +.EXAMPLE + PS> ./open-google-news +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://news.google.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-news.ps1* diff --git a/Docs/open-google-photos.md b/Docs/open-google-photos.md index b6447132..d9c7c07a 100644 --- a/Docs/open-google-photos.md +++ b/Docs/open-google-photos.md @@ -1,4 +1,4 @@ -## open-google-photos.ps1 - Opens Google Photos +## The open-google-photos.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Photos website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Photos +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Photos website. +.EXAMPLE + PS> ./open-google-photos +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://photos.google.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-photos.ps1* diff --git a/Docs/open-google-play.md b/Docs/open-google-play.md index 08bfe9be..f427a04d 100644 --- a/Docs/open-google-play.md +++ b/Docs/open-google-play.md @@ -1,4 +1,4 @@ -## open-google-play.ps1 - Opens Google Play +## The open-google-play.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Play website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Play +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Play website. +.EXAMPLE + PS> ./open-google-play +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://play.google.com/store" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-play.ps1* diff --git a/Docs/open-google-search.md b/Docs/open-google-search.md index 8949b623..59558e7d 100644 --- a/Docs/open-google-search.md +++ b/Docs/open-google-search.md @@ -1,4 +1,4 @@ -## open-google-search.ps1 - Opens Google Search +## The open-google-search.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Search website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Search +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Search website. +.EXAMPLE + PS> ./open-google-search +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://google.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-search.ps1* diff --git a/Docs/open-google-stadia.md b/Docs/open-google-stadia.md index 4174bbb0..2f382219 100644 --- a/Docs/open-google-stadia.md +++ b/Docs/open-google-stadia.md @@ -1,4 +1,4 @@ -## open-google-stadia.ps1 - Opens Google Stadia +## The open-google-stadia.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Stadia website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Stadia +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Stadia website. +.EXAMPLE + PS> ./open-google-stadia +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://stadia.google.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-stadia.ps1* diff --git a/Docs/open-google-translate.md b/Docs/open-google-translate.md index c2de5f69..c075e0d6 100644 --- a/Docs/open-google-translate.md +++ b/Docs/open-google-translate.md @@ -1,4 +1,4 @@ -## open-google-translate.ps1 - Opens Google Translate +## The open-google-translate.ps1 PowerShell Script This PowerShell script launches the Web browser with the Google Translate website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Google Translate +.DESCRIPTION + This PowerShell script launches the Web browser with the Google Translate website. +.EXAMPLE + PS> ./open-google-translate +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://translate.google.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-google-translate.ps1* diff --git a/Docs/open-home-folder.md b/Docs/open-home-folder.md index 07dcf210..732dcce3 100644 --- a/Docs/open-home-folder.md +++ b/Docs/open-home-folder.md @@ -1,4 +1,4 @@ -## open-home-folder.ps1 - Opens the home folder +## The open-home-folder.ps1 PowerShell Script This script launches the File Explorer with the user's home folder. @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the home folder +.DESCRIPTION + This script launches the File Explorer with the user's home folder. +.EXAMPLE + PS> ./open-home-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $TargetDir = resolve-path "$HOME" + if (-not(test-path "$TargetDir" -pathType container)) { + throw "Home folder at ๐Ÿ“‚$TargetDir doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-home-folder.ps1* diff --git a/Docs/open-internet-archive.md b/Docs/open-internet-archive.md index 5ad5a14d..603b6ae9 100644 --- a/Docs/open-internet-archive.md +++ b/Docs/open-internet-archive.md @@ -1,4 +1,4 @@ -## open-internet-archive.ps1 - Opens the Internet Archive website +## The open-internet-archive.ps1 PowerShell Script This script launches the Web browser with the Internet Archive website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the Internet Archive website +.DESCRIPTION + This script launches the Web browser with the Internet Archive website. +.EXAMPLE + PS> ./open-internet-archive +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://archive.org" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-internet-archive.ps1* diff --git a/Docs/open-jitsi-meet.md b/Docs/open-jitsi-meet.md index aa75a21f..45396376 100644 --- a/Docs/open-jitsi-meet.md +++ b/Docs/open-jitsi-meet.md @@ -1,4 +1,4 @@ -## open-jitsi-meet.ps1 - Opens the Jitsi Meet website +## The open-jitsi-meet.ps1 PowerShell Script This script launches the Web browser with the Jitsi Meet website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the Jitsi Meet website +.DESCRIPTION + This script launches the Web browser with the Jitsi Meet website. +.EXAMPLE + PS> ./open-jitsi-meet +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://meet.jit.si/" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-jitsi-meet.ps1* diff --git a/Docs/open-m-drive.md b/Docs/open-m-drive.md index f7c36527..7a248c68 100644 --- a/Docs/open-m-drive.md +++ b/Docs/open-m-drive.md @@ -1,4 +1,4 @@ -## open-m-drive.ps1 - Opens the M: drive folder +## The open-m-drive.ps1 PowerShell Script This script launches the File Explorer with the M: drive folder. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the M: drive folder +.DESCRIPTION + This script launches the File Explorer with the M: drive folder. +.EXAMPLE + PS> ./open-m-drive +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-file-explorer.ps1" "M:" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-m-drive.ps1* diff --git a/Docs/open-magnifier.md b/Docs/open-magnifier.md index 1005a303..d397c27b 100644 --- a/Docs/open-magnifier.md +++ b/Docs/open-magnifier.md @@ -1,4 +1,4 @@ -## open-magnifier.ps1 - Launch the Magnifier +## The open-magnifier.ps1 PowerShell Script This script launches the Windows Screen Magnifier application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launch the Magnifier +.DESCRIPTION + This script launches the Windows Screen Magnifier application. +.EXAMPLE + PS> ./open-magnifier +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + start-process magnify.exe + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-magnifier.ps1* diff --git a/Docs/open-microsoft-paint.md b/Docs/open-microsoft-paint.md index 9a7b965b..4dfe2c6c 100644 --- a/Docs/open-microsoft-paint.md +++ b/Docs/open-microsoft-paint.md @@ -1,4 +1,4 @@ -## open-microsoft-paint.ps1 - Launches the Microsoft Paint app +## The open-microsoft-paint.ps1 PowerShell Script This script launches the Microsoft Paint application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Microsoft Paint app +.DESCRIPTION + This script launches the Microsoft Paint application. +.EXAMPLE + PS> ./open-microsoft-paint +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + start-process mspaint.exe + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-microsoft-paint.ps1* diff --git a/Docs/open-microsoft-solitaire.md b/Docs/open-microsoft-solitaire.md index e5d6bd08..08821141 100644 --- a/Docs/open-microsoft-solitaire.md +++ b/Docs/open-microsoft-solitaire.md @@ -1,4 +1,4 @@ -## open-microsoft-solitaire.ps1 - Launches Microsoft Solitaire +## The open-microsoft-solitaire.ps1 PowerShell Script This script launches the Microsoft Solitaire application. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches Microsoft Solitaire +.DESCRIPTION + This script launches the Microsoft Solitaire application. +.EXAMPLE + PS> ./open-microsoft-solitaire +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +Start-Process xboxliveapp-1297287741: +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-microsoft-solitaire.ps1* diff --git a/Docs/open-microsoft-store.md b/Docs/open-microsoft-store.md index 99fff00d..d7ababed 100644 --- a/Docs/open-microsoft-store.md +++ b/Docs/open-microsoft-store.md @@ -1,4 +1,4 @@ -## open-microsoft-store.ps1 - Starts the Microsoft Store app +## The open-microsoft-store.ps1 PowerShell Script This script launches the Microsoft Store application. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Starts the Microsoft Store app +.DESCRIPTION + This script launches the Microsoft Store application. +.EXAMPLE + PS> ./open-microsoft-store +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +Start-Process ms-windows-store: +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-microsoft-store.ps1* diff --git a/Docs/open-microsoft-teams.md b/Docs/open-microsoft-teams.md index 70da9ccd..5c364ad6 100644 --- a/Docs/open-microsoft-teams.md +++ b/Docs/open-microsoft-teams.md @@ -1,4 +1,4 @@ -## open-microsoft-teams.ps1 - Launches the Microsoft Teams app +## The open-microsoft-teams.ps1 PowerShell Script This script launches the Microsoft Teams application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Microsoft Teams app +.DESCRIPTION + This script launches the Microsoft Teams application. +.EXAMPLE + PS> ./open-microsoft-teams +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Start-Process msteams: + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-microsoft-teams.ps1* diff --git a/Docs/open-microsoft-weather.md b/Docs/open-microsoft-weather.md index 62b05567..76622c31 100644 --- a/Docs/open-microsoft-weather.md +++ b/Docs/open-microsoft-weather.md @@ -1,4 +1,4 @@ -## open-microsoft-weather.ps1 - Launches the Microsoft Weather app +## The open-microsoft-weather.ps1 PowerShell Script This script launches the Microsoft Weather application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Microsoft Weather app +.DESCRIPTION + This script launches the Microsoft Weather application. +.EXAMPLE + PS> ./open-microsoft-weather +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Start-Process msnweather: + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-microsoft-weather.ps1* diff --git a/Docs/open-music-folder.md b/Docs/open-music-folder.md index bc092d29..68e5d791 100644 --- a/Docs/open-music-folder.md +++ b/Docs/open-music-folder.md @@ -1,4 +1,4 @@ -## open-music-folder.ps1 - Opens the music folder +## The open-music-folder.ps1 PowerShell Script This script launches the File Explorer with the user's music folder. @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the music folder +.DESCRIPTION + This script launches the File Explorer with the user's music folder. +.EXAMPLE + PS> ./open-music-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $TargetDir = resolve-path "$HOME/Music" + if (-not(test-path "$TargetDir" -pathType container)) { + throw "Music folder at ๐Ÿ“‚$TargetDir doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-music-folder.ps1* diff --git a/Docs/open-netflix.md b/Docs/open-netflix.md index f621e262..44d65226 100644 --- a/Docs/open-netflix.md +++ b/Docs/open-netflix.md @@ -1,4 +1,4 @@ -## open-netflix.ps1 - Launches the Netflix app +## The open-netflix.ps1 PowerShell Script This script launches the Netflix application. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Netflix app +.DESCRIPTION + This script launches the Netflix application. +.EXAMPLE + PS> ./open-netflix +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +Start-Process netflix: +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-netflix.ps1* diff --git a/Docs/open-note-pad.md b/Docs/open-note-pad.md index 79ce3222..6ca51d16 100644 --- a/Docs/open-note-pad.md +++ b/Docs/open-note-pad.md @@ -1,4 +1,4 @@ -## open-note-pad.ps1 - Launches the Notepad app +## The open-note-pad.ps1 PowerShell Script This script launches the Notepad application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Notepad app +.DESCRIPTION + This script launches the Notepad application. +.EXAMPLE + PS> ./open-note-pad +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Start-Process notepad.exe + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-note-pad.ps1* diff --git a/Docs/open-obs-studio.md b/Docs/open-obs-studio.md index fb14ec42..2ad163c8 100644 --- a/Docs/open-obs-studio.md +++ b/Docs/open-obs-studio.md @@ -1,4 +1,6 @@ -## open-obs-studio.ps1 - open-obs-studio.ps1 +## The open-obs-studio.ps1 PowerShell Script + +open-obs-studio.ps1 ## Parameters @@ -10,4 +12,34 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Launches OBS Studio +.DESCRIPTION + This script launches the OBS Studio application. +.EXAMPLE + PS> ./open-obs-studio +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function TryLaunching { param([string]$Path, [string]$Dir) + if (test-path "$Path" -pathType leaf) { + start-process -FilePath "$Path" -WorkingDirectory "$Dir" + exit 0 # success + } +} + +try { + TryLaunching "C:\Program Files (x86)\OBS Studio\bin\64bit\obs64.exe" "C:\Program Files (x86)\OBS Studio\bin\64bit\" + TryLaunching "C:\Program Files\OBS Studio\bin\64bit\obs64.exe" "C:\Program Files\OBS Studio\bin\64bit\" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-obs-studio.ps1* diff --git a/Docs/open-office-365.md b/Docs/open-office-365.md index 27f0368e..648c0421 100644 --- a/Docs/open-office-365.md +++ b/Docs/open-office-365.md @@ -1,4 +1,4 @@ -## open-office-365.ps1 - Opens Microsoft Office 365 +## The open-office-365.ps1 PowerShell Script This script launches the Web browser with the Microsoft Office 365 website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Microsoft Office 365 +.DESCRIPTION + This script launches the Web browser with the Microsoft Office 365 website. +.EXAMPLE + PS> ./open-office-365 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://portal.office.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-office-365.ps1* diff --git a/Docs/open-one-drive-folder.md b/Docs/open-one-drive-folder.md index c0f6170f..e7c6cb52 100644 --- a/Docs/open-one-drive-folder.md +++ b/Docs/open-one-drive-folder.md @@ -1,4 +1,4 @@ -## open-one-drive-folder.ps1 - Opens the OneDrive folder +## The open-one-drive-folder.ps1 PowerShell Script This script launches the File Explorer with the user's OneDrive folder. @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the OneDrive folder +.DESCRIPTION + This script launches the File Explorer with the user's OneDrive folder. +.EXAMPLE + PS> ./open-one-drive-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $TargetDirs = resolve-path "$HOME/OneDrive*" + foreach($TargetDir in $TargetDirs) { + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success + } + throw "No OneDrive folder at ๐Ÿ“‚$HOME/Dropbox" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-one-drive-folder.ps1* diff --git a/Docs/open-outlook.md b/Docs/open-outlook.md index 8d7ee0fc..63d60fce 100644 --- a/Docs/open-outlook.md +++ b/Docs/open-outlook.md @@ -1,4 +1,6 @@ -## open-outlook.ps1 - open-outlook.ps1 +## The open-outlook.ps1 PowerShell Script + +open-outlook.ps1 ## Parameters @@ -10,4 +12,34 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Launches the Microsoft Outlook app +.DESCRIPTION + This script launches the Microsoft Outlook email application. +.EXAMPLE + PS> ./open-outlook +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function TryToExec { param($Folder, $Binary) + if (test-path "$Folder/$Binary" -pathType leaf) { + start-process "$Folder/$Binary" -WorkingDirectory "$Folder" + exit 0 # success + } +} + +try { + TryToExec "C:\Program Files\Microsoft Office\root\Office16" "OUTLOOK.EXE" + TryToExec "C:\Programs\Microsoft Office\Office14" "OUTLOOK.EXE" + throw "It seems Outlook isn't installed yet." +} catch { + & "$PSScriptRoot/give-reply.ps1" "Sorry: $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-outlook.ps1* diff --git a/Docs/open-paint-three-d.md b/Docs/open-paint-three-d.md index fc7ec5c1..440b4789 100644 --- a/Docs/open-paint-three-d.md +++ b/Docs/open-paint-three-d.md @@ -1,4 +1,4 @@ -## open-paint-three-d.ps1 - Launches the Paint 3D app +## The open-paint-three-d.ps1 PowerShell Script This script launches the Paint 3D application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Paint 3D app +.DESCRIPTION + This script launches the Paint 3D application. +.EXAMPLE + PS> ./open-paint-3d +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + start-process ms-paint: + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-paint-three-d.ps1* diff --git a/Docs/open-pictures-folder.md b/Docs/open-pictures-folder.md index 78b66091..d469feba 100644 --- a/Docs/open-pictures-folder.md +++ b/Docs/open-pictures-folder.md @@ -1,4 +1,4 @@ -## open-pictures-folder.ps1 - Opens the user's pictures folder +## The open-pictures-folder.ps1 PowerShell Script This script launches the File Explorer with the user's pictures folder. @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the user's pictures folder +.DESCRIPTION + This script launches the File Explorer with the user's pictures folder. +.EXAMPLE + PS> ./open-pictures-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $TargetDir = resolve-path "$HOME/Pictures" + if (-not(test-path "$TargetDir" -pathType container)) { + throw "Pictures folder at ๐Ÿ“‚$TargetDir doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-pictures-folder.ps1* diff --git a/Docs/open-recycle-bin-folder.md b/Docs/open-recycle-bin-folder.md index accd65e1..30bcbd53 100644 --- a/Docs/open-recycle-bin-folder.md +++ b/Docs/open-recycle-bin-folder.md @@ -1,4 +1,4 @@ -## open-recycle-bin-folder.ps1 - Opens the recycle bin folder +## The open-recycle-bin-folder.ps1 PowerShell Script This script launches the File Explorer with the user's recycle bin folder. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the recycle bin folder +.DESCRIPTION + This script launches the File Explorer with the user's recycle bin folder. +.EXAMPLE + PS> ./open-recycle-bin-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + start shell:recyclebinfolder + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-recycle-bin-folder.ps1* diff --git a/Docs/open-remote-desktop.md b/Docs/open-remote-desktop.md index 7748694b..49ca4485 100644 --- a/Docs/open-remote-desktop.md +++ b/Docs/open-remote-desktop.md @@ -1,4 +1,4 @@ -## open-remote-desktop.ps1 - Launches the Remote Desktop app +## The open-remote-desktop.ps1 PowerShell Script This script launches the Remote Desktop application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Remote Desktop app +.DESCRIPTION + This script launches the Remote Desktop application. +.EXAMPLE + PS> ./open-remote-desktop +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + start-process ms-rd: + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-remote-desktop.ps1* diff --git a/Docs/open-repos-folder.md b/Docs/open-repos-folder.md index 17528c38..157eb9b1 100644 --- a/Docs/open-repos-folder.md +++ b/Docs/open-repos-folder.md @@ -1,4 +1,4 @@ -## open-repos-folder.ps1 - Opens the Git repositories folder +## The open-repos-folder.ps1 PowerShell Script This script launches the File Explorer with the user's Git repositories folder. @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the Git repositories folder +.DESCRIPTION + This script launches the File Explorer with the user's Git repositories folder. +.EXAMPLE + PS> ./open-repos-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $TargetDir = Resolve-Path "$HOME/Repos" + if (-not(Test-Path "$TargetDir" -pathType container)) { + throw "Repos folder at ๐Ÿ“‚$TargetDir doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-repos-folder.ps1* diff --git a/Docs/open-screen-clip.md b/Docs/open-screen-clip.md index f9d96528..47c0ab6b 100644 --- a/Docs/open-screen-clip.md +++ b/Docs/open-screen-clip.md @@ -1,4 +1,4 @@ -## open-screen-clip.ps1 - Launches Screen Clip +## The open-screen-clip.ps1 PowerShell Script This script launches the Screen Clip application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches Screen Clip +.DESCRIPTION + This script launches the Screen Clip application. +.EXAMPLE + PS> ./open-screen-clip +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Start-Process ms-screenclip: + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-screen-clip.ps1* diff --git a/Docs/open-screen-sketch.md b/Docs/open-screen-sketch.md index ccbfd0ac..71eb79d4 100644 --- a/Docs/open-screen-sketch.md +++ b/Docs/open-screen-sketch.md @@ -1,4 +1,4 @@ -## open-screen-sketch.ps1 - Launches Screen Sketch +## The open-screen-sketch.ps1 PowerShell Script This script launches the Screen Sketch application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches Screen Sketch +.DESCRIPTION + This script launches the Screen Sketch application. +.EXAMPLE + PS> ./open-screen-sketch +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Start-Process ms-screensketch: + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-screen-sketch.ps1* diff --git a/Docs/open-skype.md b/Docs/open-skype.md index 89f32617..c5e0ffdb 100644 --- a/Docs/open-skype.md +++ b/Docs/open-skype.md @@ -1,4 +1,4 @@ -## open-skype.ps1 - Launches the Skype app +## The open-skype.ps1 PowerShell Script This script launches the Skype application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Skype app +.DESCRIPTION + This script launches the Skype application. +.EXAMPLE + PS> ./open-skype +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Start-Process skype: + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-skype.ps1* diff --git a/Docs/open-snipping-tool.md b/Docs/open-snipping-tool.md index 77e5f060..726fef60 100644 --- a/Docs/open-snipping-tool.md +++ b/Docs/open-snipping-tool.md @@ -1,4 +1,4 @@ -## open-snipping-tool.ps1 - Starts the Snipping Tool +## The open-snipping-tool.ps1 PowerShell Script This script launches the Snipping Tool application. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Starts the Snipping Tool +.DESCRIPTION + This script launches the Snipping Tool application. +.EXAMPLE + PS> ./open-snipping-tool +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +Start-Process SnippingTool.exe +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-snipping-tool.ps1* diff --git a/Docs/open-space-weather.md b/Docs/open-space-weather.md index 8921ae9b..2cdd89ad 100644 --- a/Docs/open-space-weather.md +++ b/Docs/open-space-weather.md @@ -1,4 +1,4 @@ -## open-space-weather.ps1 - Opens the Space Weather website +## The open-space-weather.ps1 PowerShell Script This script launches the Web browser with the Space Weather website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the Space Weather website +.DESCRIPTION + This script launches the Web browser with the Space Weather website. +.EXAMPLE + PS> ./open-space-weather +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://www.spaceweather.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-space-weather.ps1* diff --git a/Docs/open-speed-test.md b/Docs/open-speed-test.md index 7e03b57c..a28a022d 100644 --- a/Docs/open-speed-test.md +++ b/Docs/open-speed-test.md @@ -1,4 +1,4 @@ -## open-speed-test.ps1 - Opens Cloudflare's Speed Test +## The open-speed-test.ps1 PowerShell Script This script launches the Web browser with Cloudflare's speed test website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens Cloudflare's Speed Test +.DESCRIPTION + This script launches the Web browser with Cloudflare's speed test website. +.EXAMPLE + PS> ./open-speed-test +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://speed.cloudflare.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-speed-test.ps1* diff --git a/Docs/open-spotify.md b/Docs/open-spotify.md index 034117e7..c3869da0 100644 --- a/Docs/open-spotify.md +++ b/Docs/open-spotify.md @@ -1,4 +1,4 @@ -## open-spotify.ps1 - Launches the Spotify app +## The open-spotify.ps1 PowerShell Script This script launches the Spotify application. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Spotify app +.DESCRIPTION + This script launches the Spotify application. +.EXAMPLE + PS> ./open-spotify +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +Start-Process spotify: +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-spotify.ps1* diff --git a/Docs/open-stack-overflow.md b/Docs/open-stack-overflow.md index 02a53a9f..c9417b09 100644 --- a/Docs/open-stack-overflow.md +++ b/Docs/open-stack-overflow.md @@ -1,4 +1,4 @@ -## open-stack-overflow.ps1 - Opens the Stack Overflow website +## The open-stack-overflow.ps1 PowerShell Script This script launches the Web browser with the Stack Overflow website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the Stack Overflow website +.DESCRIPTION + This script launches the Web browser with the Stack Overflow website. +.EXAMPLE + PS> ./open-stack-overflow +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://stackoverflow.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-stack-overflow.ps1* diff --git a/Docs/open-start-page.md b/Docs/open-start-page.md index 034ead98..d2aae7e0 100644 --- a/Docs/open-start-page.md +++ b/Docs/open-start-page.md @@ -1,4 +1,4 @@ -## open-start-page.ps1 - Opens the Startpage website +## The open-start-page.ps1 PowerShell Script This script launches the Web browser with the Startpage website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the Startpage website +.DESCRIPTION + This script launches the Web browser with the Startpage website. +.EXAMPLE + PS> ./open-start-page +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://www.startpage.com" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-start-page.ps1* diff --git a/Docs/open-street-map.md b/Docs/open-street-map.md index 722993c6..f3d82610 100644 --- a/Docs/open-street-map.md +++ b/Docs/open-street-map.md @@ -1,4 +1,4 @@ -## open-street-map.ps1 - Opens the OpenStreetMap website +## The open-street-map.ps1 PowerShell Script This script launches the Web browser with the OpenStreetMap website. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the OpenStreetMap website +.DESCRIPTION + This script launches the Web browser with the OpenStreetMap website. +.EXAMPLE + PS> ./open-street-map +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://www.openstreetmap.org" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-street-map.ps1* diff --git a/Docs/open-task-manager.md b/Docs/open-task-manager.md index 61a8fbac..5517a447 100644 --- a/Docs/open-task-manager.md +++ b/Docs/open-task-manager.md @@ -1,4 +1,4 @@ -## open-task-manager.ps1 - Starts the Task Manager +## The open-task-manager.ps1 PowerShell Script This script launches the Windows Task Manager application. @@ -23,4 +23,26 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Starts the Task Manager +.DESCRIPTION + This script launches the Windows Task Manager application. +.EXAMPLE + PS> ./open-task-manager +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + Start-Process taskmgr.exe + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-task-manager.ps1* diff --git a/Docs/open-temporary-folder.md b/Docs/open-temporary-folder.md index a8d4ed98..0dc0640f 100644 --- a/Docs/open-temporary-folder.md +++ b/Docs/open-temporary-folder.md @@ -1,4 +1,6 @@ -## open-temporary-folder.ps1 - open-temporary-folder.ps1 +## The open-temporary-folder.ps1 PowerShell Script + +open-temporary-folder.ps1 ## Parameters @@ -10,4 +12,37 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Opens the temporary folder +.DESCRIPTION + This script launches the File Explorer showing the temporary folder. +.EXAMPLE + PS> ./open-temporary-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function GetTempDir { + if ("$env:TEMP" -ne "") { return "$env:TEMP" } + if ("$env:TMP" -ne "") { return "$env:TMP" } + if ($IsLinux) { return "/tmp" } + return "C:\Temp" +} + +try { + $Path = GetTempDir + if (-not(test-path "$Path" -pathType container)) { + throw "Temporary folder at ๐Ÿ“‚$Path doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" "$Path" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-temporary-folder.ps1* diff --git a/Docs/open-three-d-viewer.md b/Docs/open-three-d-viewer.md index 7eb99968..1300a7c2 100644 --- a/Docs/open-three-d-viewer.md +++ b/Docs/open-three-d-viewer.md @@ -1,4 +1,4 @@ -## open-three-d-viewer.ps1 - Launches the 3D-Viewer app +## The open-three-d-viewer.ps1 PowerShell Script This script launches the 3D-Viewer application. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the 3D-Viewer app +.DESCRIPTION + This script launches the 3D-Viewer application. +.EXAMPLE + PS> ./open-three-d-viewer +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +Start-Process com.microsoft.3dviewer: +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-three-d-viewer.ps1* diff --git a/Docs/open-thunderbird.md b/Docs/open-thunderbird.md index c96eded7..aae889e1 100644 --- a/Docs/open-thunderbird.md +++ b/Docs/open-thunderbird.md @@ -1,4 +1,6 @@ -## open-thunderbird.ps1 - open-thunderbird.ps1 +## The open-thunderbird.ps1 PowerShell Script + +open-thunderbird.ps1 ## Parameters @@ -10,4 +12,32 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Launches the Thunderbird app +.DESCRIPTION + This script launches the Mozilla Thunderbird email application. +.EXAMPLE + PS> ./open-thunderbird +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function TryToExec { param($Folder, $Binary) + if (test-path "$Folder/$Binary" -pathType leaf) { + start-process "$Folder/$Binary" -WorkingDirectory "$Folder" + exit 0 # success + } +} + +try { + TryToExec "C:\Program Files (x86)\Mozilla Thunderbird" "thunderbird.exe" + throw "It seems Thunderbird isn't installed yet." +} catch { + & "$PSScriptRoot/give-reply.ps1" "Sorry: $($Error[0])" +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-thunderbird.ps1* diff --git a/Docs/open-videos-folders.md b/Docs/open-videos-folders.md index 6a2cd212..c0e4935d 100644 --- a/Docs/open-videos-folders.md +++ b/Docs/open-videos-folders.md @@ -1,4 +1,4 @@ -## open-videos-folders.ps1 - Opens the user's videos folder +## The open-videos-folders.ps1 PowerShell Script This script launches the File Explorer with the user's videos folder. @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the user's videos folder +.DESCRIPTION + This script launches the File Explorer with the user's videos folder. +.EXAMPLE + PS> ./open-videos-folder +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $TargetDir = Resolve-Path "$HOME/Videos" + if (-not(Test-Path "$TargetDir" -pathType container)) { + throw "Videos folder at ๐Ÿ“‚$TargetDir doesn't exist (yet)" + } + & "$PSScriptRoot/open-file-explorer.ps1" "$TargetDir" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-videos-folders.ps1* diff --git a/Docs/open-visual-studio.md b/Docs/open-visual-studio.md index 2204ca0b..ae1f5035 100644 --- a/Docs/open-visual-studio.md +++ b/Docs/open-visual-studio.md @@ -1,4 +1,6 @@ -## open-visual-studio.ps1 - open-visual-studio.ps1 +## The open-visual-studio.ps1 PowerShell Script + +open-visual-studio.ps1 ## Parameters @@ -10,4 +12,34 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Launches the Visual Studio app +.DESCRIPTION + This script launches the Microsoft Visual Studio application. +.EXAMPLE + PS> ./open-visual-studio +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function TryLaunching { param($Path) + if (test-path "$Path" -pathType leaf) { + start-process "$Path" + exit 0 # success + } +} + +try { + TryLaunching "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe" + TryLaunching "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of open-visual-studio.ps1* diff --git a/Docs/open-vpn-settings.md b/Docs/open-vpn-settings.md index df307a87..73466ce9 100644 --- a/Docs/open-vpn-settings.md +++ b/Docs/open-vpn-settings.md @@ -1,4 +1,4 @@ -## open-vpn-settings.ps1 - Opens the VPN settings +## The open-vpn-settings.ps1 PowerShell Script This PowerShell script launches the VPN settings of Windows. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Opens the VPN settings +.DESCRIPTION + This PowerShell script launches the VPN settings of Windows. +.EXAMPLE + PS> ./open-vpn-settings +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +Start-Process ms-settings:network-vpn +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-vpn-settings.ps1* diff --git a/Docs/open-windows-defender.md b/Docs/open-windows-defender.md index 97a4e8cc..36ee7ebc 100644 --- a/Docs/open-windows-defender.md +++ b/Docs/open-windows-defender.md @@ -1,4 +1,4 @@ -## open-windows-defender.ps1 - Launches Windows Defender +## The open-windows-defender.ps1 PowerShell Script This script launches the Windows Defender application. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches Windows Defender +.DESCRIPTION + This script launches the Windows Defender application. +.EXAMPLE + PS> ./open-windows-defender +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +Start-Process windowsdefender: +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-windows-defender.ps1* diff --git a/Docs/open-windows-terminal.md b/Docs/open-windows-terminal.md index cfd96799..3917089c 100644 --- a/Docs/open-windows-terminal.md +++ b/Docs/open-windows-terminal.md @@ -1,4 +1,4 @@ -## open-windows-terminal.ps1 - Launches the Windows Terminal app +## The open-windows-terminal.ps1 PowerShell Script This script launches the Windows Terminal application. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the Windows Terminal app +.DESCRIPTION + This script launches the Windows Terminal application. +.EXAMPLE + PS> ./open-windows-terminal +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +Start-Process wt.exe +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-windows-terminal.ps1* diff --git a/Docs/open-xing.md b/Docs/open-xing.md index 6acb676b..3c4d1a2c 100644 --- a/Docs/open-xing.md +++ b/Docs/open-xing.md @@ -1,4 +1,4 @@ -## open-xing.ps1 - Launches the XING app +## The open-xing.ps1 PowerShell Script This script launches the XING application. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Launches the XING app +.DESCRIPTION + This script launches the XING application. +.EXAMPLE + PS> ./open-xing +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +Start-Process xing: +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of open-xing.ps1* diff --git a/Docs/pick-commit.md b/Docs/pick-commit.md index acaa6da8..eed90644 100644 --- a/Docs/pick-commit.md +++ b/Docs/pick-commit.md @@ -1,4 +1,4 @@ -## pick-commit.ps1 - Cherry-picks a Git commit into one or more branches +## The pick-commit.ps1 PowerShell Script Cherry-picks a Git commit into one or more branches (branch names need to be separated by spaces) NOTE: in case of merge conflicts the script stops immediately! @@ -60,4 +60,87 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Cherry-picks a Git commit into one or more branches +.DESCRIPTION + Cherry-picks a Git commit into one or more branches (branch names need to be separated by spaces) + NOTE: in case of merge conflicts the script stops immediately! +.PARAMETER CommitID + Specifies the commit ID +.PARAMETER CommitMessage + Specifies the commit message to use +.PARAMETER Branches + Specifies the list of branches, separated by spaces +.PARAMETER RepoDir + Specifies the path to the Git repository +.EXAMPLE + PS> ./pick-commit 93849f889 "Fix typo" "v1 v2 v3" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$CommitID = "", [string]$CommitMessage = "", [string]$Branches = "", [string]$RepoDir = "$PWD") + +try { + if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + set-location "$RepoDir" + + if ($CommitID -eq "") { $CommitID = read-host "Enter the Git 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 branches (separated by spaces)" } + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + $BranchArray = $Branches.Split(" ") + $NumBranches = $BranchArray.Count + foreach($Branch in $BranchArray) { + + "๐Ÿ’ Switching to branch $Branch ..." + & git checkout --recurse-submodules --force $Branch + if ($lastExitCode -ne "0") { throw "'git checkout $Branch' failed" } + + "๐Ÿ’ Updating submodules..." + & git submodule update --init --recursive + if ($lastExitCode -ne "0") { throw "'git submodule update' failed" } + + "๐Ÿ’ Cleaning the repository from untracked files..." + & git clean -fdx -f + if ($lastExitCode -ne "0") { throw "'git clean -fdx -f' failed" } + + & git submodule foreach --recursive git clean -fdx -f + if ($lastExitCode -ne "0") { throw "'git clean -fdx -f' in submodules failed" } + + "๐Ÿ’ Pulling latest updates..." + & git pull --recurse-submodules + if ($lastExitCode -ne "0") { throw "'git pull' failed" } + + "๐Ÿ’ Checking the status..." + $Result = (git status) + if ($lastExitCode -ne "0") { throw "'git status' failed" } + if ("$Result" -notmatch "nothing to commit, working tree clean") { throw "Branch is NOT clean: $Result" } + + "๐Ÿ’ Cherry picking..." + & git cherry-pick --no-commit "$CommitID" + if ($lastExitCode -ne "0") { throw "'git cherry-pick $CommitID' failed" } + + "๐Ÿ’ Committing..." + & git commit -m "$CommitMessage" + if ($lastExitCode -ne "0") { throw "'git commit' failed" } + + "๐Ÿ’ Pushing..." + & git push + if ($lastExitCode -ne "0") { throw "'git push' failed" } + } + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ cherry picked $CommitID into $NumBranches branches in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of pick-commit.ps1* diff --git a/Docs/ping-weather.md b/Docs/ping-weather.md index 441d77b3..1e49974e 100644 --- a/Docs/ping-weather.md +++ b/Docs/ping-weather.md @@ -1,4 +1,4 @@ -## ping-weather.ps1 - Ping the currrent weather conditions +## The ping-weather.ps1 PowerShell Script This PowerShell script continuously shows the current weather conditions (similar to htop, 10 min update interval by default). @@ -41,4 +41,48 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Ping the currrent weather conditions +.DESCRIPTION + This PowerShell script continuously shows the current weather conditions (similar to htop, 10 min update interval by default). +.PARAMETER Location + Specifies the location to use (determined automatically per default) +.EXAMPLE + PS> ./ping-weather Paris + Sunny ๐ŸŒก23ยฐC โ˜‚๏ธ0.0mm ๐Ÿ’จ9km/h from S โ˜๏ธ0% ๐Ÿ’ง41% โ˜€๏ธUV6 1020hPa ๐Ÿ•—10:24 AM UTC @Paris (Ile-de-France)... +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Location = "", [int]$UpdateInterval = 600000) + +try { + do { + $Weather = (Invoke-WebRequest -URI http://wttr.in/${Location}?format=j1 -userAgent "curl" -useBasicParsing).Content | ConvertFrom-Json + $Description = $Weather.current_condition.WeatherDesc.value + $TempC = $Weather.current_condition.temp_C + $PrecipMM = $Weather.current_condition.precipMM + $WindSpeed = $Weather.current_condition.windspeedKmph + $WindDir = $Weather.current_condition.winddir16Point + $Clouds = $Weather.current_condition.cloudcover + $Humidity = $Weather.current_condition.humidity + $UV = $Weather.current_condition.uvIndex + $Visib = $Weather.current_condition.visibility + $Pressure = $Weather.current_condition.pressure + $Time = $Weather.current_condition.observation_time + $Area = $Weather.nearest_area.areaName.value + $Region = $Weather.nearest_area.region.value + "$Description ๐ŸŒก$($TempC)ยฐC โ˜‚๏ธ$($PrecipMM)mm ๐Ÿ’จ$($WindSpeed)km/h from $WindDir โ˜๏ธ$($Clouds)% ๐Ÿ’ง$($Humidity)% โ˜€๏ธUV$UV ๐Ÿ‘€$($Visib)km $($Pressure)hPa ๐Ÿ•—$Time UTC @$Area ($Region)..." + start-sleep -milliseconds $UpdateInterval + } while ($true) + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of ping-weather.ps1* diff --git a/Docs/play-bee-sound.md b/Docs/play-bee-sound.md index fbd7176a..264d82f1 100644 --- a/Docs/play-bee-sound.md +++ b/Docs/play-bee-sound.md @@ -1,4 +1,4 @@ -## play-bee-sound.ps1 - Plays a bee sound +## The play-bee-sound.ps1 PowerShell Script This PowerShell script plays a bee sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a bee sound +.DESCRIPTION + This PowerShell script plays a bee sound. +.EXAMPLE + PS> ./play-bee-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/bee.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-bee-sound.ps1* diff --git a/Docs/play-beep-sound.md b/Docs/play-beep-sound.md index 261c54d7..e167795a 100644 --- a/Docs/play-beep-sound.md +++ b/Docs/play-beep-sound.md @@ -1,4 +1,4 @@ -## play-beep-sound.ps1 - Plays a short beep sound +## The play-beep-sound.ps1 PowerShell Script This PowerShell script plays a short beep sound. @@ -23,4 +23,22 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a short beep sound +.DESCRIPTION + This PowerShell script plays a short beep sound. +.EXAMPLE + PS> ./play-beep-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +[System.Console]::Beep(500,300) +start-sleep -m 300 +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-beep-sound.ps1* diff --git a/Docs/play-cat-sound.md b/Docs/play-cat-sound.md index 52edeee1..2fdde6d9 100644 --- a/Docs/play-cat-sound.md +++ b/Docs/play-cat-sound.md @@ -1,4 +1,4 @@ -## play-cat-sound.ps1 - Plays a cat sound +## The play-cat-sound.ps1 PowerShell Script This PowerShell script plays a cat sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a cat sound +.DESCRIPTION + This PowerShell script plays a cat sound. +.EXAMPLE + PS> ./play-cat-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/cat.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-cat-sound.ps1* diff --git a/Docs/play-cow-sound.md b/Docs/play-cow-sound.md index 3e1951bd..085d7cfb 100644 --- a/Docs/play-cow-sound.md +++ b/Docs/play-cow-sound.md @@ -1,4 +1,4 @@ -## play-cow-sound.ps1 - Plays a cow sound +## The play-cow-sound.ps1 PowerShell Script This PowerShell script plays a cow sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a cow sound +.DESCRIPTION + This PowerShell script plays a cow sound. +.EXAMPLE + PS> ./play-cow-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/cow.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-cow-sound.ps1* diff --git a/Docs/play-dog-sound.md b/Docs/play-dog-sound.md index 7526c6fa..b4cd085d 100644 --- a/Docs/play-dog-sound.md +++ b/Docs/play-dog-sound.md @@ -1,4 +1,4 @@ -## play-dog-sound.ps1 - Plays a dog sound +## The play-dog-sound.ps1 PowerShell Script This PowerShell script plays a dog sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a dog sound +.DESCRIPTION + This PowerShell script plays a dog sound. +.EXAMPLE + PS> ./play-dog-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/dog.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-dog-sound.ps1* diff --git a/Docs/play-donkey-sound.md b/Docs/play-donkey-sound.md index bd76da73..d6de98db 100644 --- a/Docs/play-donkey-sound.md +++ b/Docs/play-donkey-sound.md @@ -1,4 +1,4 @@ -## play-donkey-sound.ps1 - Plays a donkey sound +## The play-donkey-sound.ps1 PowerShell Script This PowerShell script plays a donkey sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a donkey sound +.DESCRIPTION + This PowerShell script plays a donkey sound. +.EXAMPLE + PS> ./play-donkey-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/donkey.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-donkey-sound.ps1* diff --git a/Docs/play-elephant-sound.md b/Docs/play-elephant-sound.md index e2c62f49..b3248114 100644 --- a/Docs/play-elephant-sound.md +++ b/Docs/play-elephant-sound.md @@ -1,4 +1,4 @@ -## play-elephant-sound.ps1 - Plays an elephant sound +## The play-elephant-sound.ps1 PowerShell Script This PowerShell script plays an elephant sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays an elephant sound +.DESCRIPTION + This PowerShell script plays an elephant sound. +.EXAMPLE + PS> ./play-elephant-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/elephant.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-elephant-sound.ps1* diff --git a/Docs/play-elk-sound.md b/Docs/play-elk-sound.md index e1a3f5a7..4d680c80 100644 --- a/Docs/play-elk-sound.md +++ b/Docs/play-elk-sound.md @@ -1,4 +1,4 @@ -## play-elk-sound.ps1 - Plays an elk sound +## The play-elk-sound.ps1 PowerShell Script This PowerShell script plays an elk sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays an elk sound +.DESCRIPTION + This PowerShell script plays an elk sound. +.EXAMPLE + PS> ./play-elk-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/elk.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-elk-sound.ps1* diff --git a/Docs/play-files.md b/Docs/play-files.md index 39b51bc6..1b487886 100644 --- a/Docs/play-files.md +++ b/Docs/play-files.md @@ -1,4 +1,4 @@ -## play-files.ps1 - Plays audio files (MP3 and WAV) +## The play-files.ps1 PowerShell Script This PowerShell script plays the given audio files (supporting MP3 and WAV format). @@ -32,4 +32,40 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays audio files (MP3 and WAV) +.DESCRIPTION + This PowerShell script plays the given audio files (supporting MP3 and WAV format). +.PARAMETER FilePattern + Specifies the file pattern +.EXAMPLE + PS> ./play-files *.mp3 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$FilePattern = "*") + +try { + $Files = (get-childItem -path "$FilePattern" -attributes !Directory) + "Playing $($Files.Count) files ..." + foreach ($File in $Files) { + if ("$File" -like "*.mp3") { + & "$PSScriptRoot/play-mp3.ps1" "$File" + } elseif ("$File" -like "*.wav") { + & "$PSScriptRoot/play-mp3.ps1" "$File" + } else { + "Skipping $File ..." + } + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of play-files.ps1* diff --git a/Docs/play-frog-sound.md b/Docs/play-frog-sound.md index d3222a00..dd4e7193 100644 --- a/Docs/play-frog-sound.md +++ b/Docs/play-frog-sound.md @@ -1,4 +1,4 @@ -## play-frog-sound.ps1 - Plays a frog sound +## The play-frog-sound.ps1 PowerShell Script This PowerShell script plays a frog sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a frog sound +.DESCRIPTION + This PowerShell script plays a frog sound. +.EXAMPLE + PS> ./play-frog-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/frog.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-frog-sound.ps1* diff --git a/Docs/play-goat-sound.md b/Docs/play-goat-sound.md index 1be47f21..5b5c0925 100644 --- a/Docs/play-goat-sound.md +++ b/Docs/play-goat-sound.md @@ -1,4 +1,4 @@ -## play-goat-sound.ps1 - Plays a goat sound +## The play-goat-sound.ps1 PowerShell Script This PowerShell script plays a goat sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a goat sound +.DESCRIPTION + This PowerShell script plays a goat sound. +.EXAMPLE + PS> ./play-goat-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/goat.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-goat-sound.ps1* diff --git a/Docs/play-gorilla-sound.md b/Docs/play-gorilla-sound.md index 2a0460fd..86483617 100644 --- a/Docs/play-gorilla-sound.md +++ b/Docs/play-gorilla-sound.md @@ -1,4 +1,4 @@ -## play-gorilla-sound.ps1 - Plays a gorilla sound +## The play-gorilla-sound.ps1 PowerShell Script This PowerShell script plays a gorilla sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a gorilla sound +.DESCRIPTION + This PowerShell script plays a gorilla sound. +.EXAMPLE + PS> ./play-gorilla-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/gorilla.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-gorilla-sound.ps1* diff --git a/Docs/play-happy-birthday.md b/Docs/play-happy-birthday.md index 056cf7ab..6a09877d 100644 --- a/Docs/play-happy-birthday.md +++ b/Docs/play-happy-birthday.md @@ -1,4 +1,4 @@ -## play-happy-birthday.ps1 - Plays the Happy Birthday song +## The play-happy-birthday.ps1 PowerShell Script This PowerShell script plays the famous Happy Birthday song. @@ -23,4 +23,45 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays the Happy Birthday song +.DESCRIPTION + This PowerShell script plays the famous Happy Birthday song. +.EXAMPLE + PS> ./play-happy-birthday +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +[System.Console]::Beep(1059.274, 300) +[System.Console]::Beep(1059.274, 200) +[System.Console]::Beep(1188.995, 500) +[System.Console]::Beep(1059.274, 500) +[System.Console]::Beep(1413.961, 500) +[System.Console]::Beep(1334.601, 950) +[System.Console]::Beep(1059.274, 300) +[System.Console]::Beep(1059.274, 200) +[System.Console]::Beep(1188.995, 500) +[System.Console]::Beep(1059.274, 500) +[System.Console]::Beep(1587.117, 500) +[System.Console]::Beep(1413.961, 950) +[System.Console]::Beep(1059.274, 300) +[System.Console]::Beep(1059.274, 200) +[System.Console]::Beep(2118.547, 500) +[System.Console]::Beep(1781.479, 500) +[System.Console]::Beep(1413.961, 500) +[System.Console]::Beep(1334.601, 500) +[System.Console]::Beep(1188.995, 500) +[System.Console]::Beep(1887.411, 300) +[System.Console]::Beep(1887.411, 200) +[System.Console]::Beep(1781.479, 500) +[System.Console]::Beep(1413.961, 500) +[System.Console]::Beep(1587.117, 500) +[System.Console]::Beep(1413.961, 900) +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-happy-birthday.ps1* diff --git a/Docs/play-horse-sound.md b/Docs/play-horse-sound.md index 9c12805d..2fa7c968 100644 --- a/Docs/play-horse-sound.md +++ b/Docs/play-horse-sound.md @@ -1,4 +1,4 @@ -## play-horse-sound.ps1 - Plays a horse sound +## The play-horse-sound.ps1 PowerShell Script This PowerShell script plays a horse sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a horse sound +.DESCRIPTION + This PowerShell script plays a horse sound. +.EXAMPLE + PS> ./play-horse-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/horse.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-horse-sound.ps1* diff --git a/Docs/play-imperial-march.md b/Docs/play-imperial-march.md index 35cc288e..ec0da1b4 100644 --- a/Docs/play-imperial-march.md +++ b/Docs/play-imperial-march.md @@ -1,4 +1,4 @@ -## play-imperial-march.ps1 - Plays the Imperial March (Star Wars) +## The play-imperial-march.ps1 PowerShell Script This PowerShell script plays the Imperial March used in the Star Wars film series. @@ -23,4 +23,38 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays the Imperial March (Star Wars) +.DESCRIPTION + This PowerShell script plays the Imperial March used in the Star Wars film series. +.EXAMPLE + PS> ./play-imperial-march +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +[System.Console]::beep(440, 500) +[System.Console]::beep(440, 500) +[System.Console]::beep(440, 500) +[System.Console]::beep(349, 350) +[System.Console]::beep(523, 150) +[System.Console]::beep(440, 500) +[System.Console]::beep(349, 350) +[System.Console]::beep(523, 150) +[System.Console]::beep(440, 1000) +[System.Console]::beep(659, 500) +[System.Console]::beep(659, 500) +[System.Console]::beep(659, 500) +[System.Console]::beep(698, 350) +[System.Console]::beep(523, 150) +[System.Console]::beep(415, 500) +[System.Console]::beep(349, 350) +[System.Console]::beep(523, 150) +[System.Console]::beep(440, 1000) +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-imperial-march.ps1* diff --git a/Docs/play-jingle-bells.md b/Docs/play-jingle-bells.md index d41945c5..7f82edab 100644 --- a/Docs/play-jingle-bells.md +++ b/Docs/play-jingle-bells.md @@ -1,4 +1,4 @@ -## play-jingle-bells.ps1 - Plays Jingle Bells +## The play-jingle-bells.ps1 PowerShell Script This PowerShell script plays the famous Jingle Bells song. @@ -23,4 +23,166 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays Jingle Bells +.DESCRIPTION + This PowerShell script plays the famous Jingle Bells song. +.EXAMPLE + PS> ./play-jingle-bells +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +$Notes = New-Object -TypeName psobject -Property @{ + REST = 0 + GbelowC = 196 + A = 220 + Asharp = 233 + B = 247 + C = 262 + Csharp = 277 + D = 294 + Dsharp = 311 + E = 330 + F = 349 + Fsharp = 370 + G = 392 + Gsharp = 415 + AA = 440 + AAsharp = 466 + BB = 493 + CC = 523 + CCsharp = 554 + DD = 587 + DDsharp = 622 + EE = 659 + FF = 698 + FFsharp = 740 + GG = 784 + GGsharp = 830 + } +$Duration = New-Object -TypeName psobject -Property @{ + WHOLE = 1600 + HALF = 800 + QUARTER = 400 + EIGHTH = 200 + SIXTEENTH = 100 + } +[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) +[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) +[System.Console]::Beep($Notes.C, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.QUARTER) +[System.Console]::Beep($Notes.F, $Duration.QUARTER) +[System.Console]::Beep($Notes.C, $Duration.HALF ) +[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) +[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) +[System.Console]::Beep($Notes.C, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.QUARTER) +[System.Console]::Beep($Notes.F, $Duration.QUARTER) +[System.Console]::Beep($Notes.D, $Duration.HALF ) +Start-Sleep -m $Duration.EIGHTH +[System.Console]::Beep($Notes.D, $Duration.EIGHTH ) +[System.Console]::Beep($Notes.E, $Duration.QUARTER) +[System.Console]::Beep($Notes.BB, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.QUARTER) +[System.Console]::Beep($Notes.E, $Duration.HALF) +Start-Sleep -m $Duration.EIGHTH +[System.Console]::Beep($Notes.E, $Duration.EIGHTH) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.BB, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.HALF) +[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) +[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) +[System.Console]::Beep($Notes.C, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.QUARTER) +[System.Console]::Beep($Notes.F, $Duration.QUARTER) +[System.Console]::Beep($Notes.C, $Duration.HALF ) +[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) +[System.Console]::Beep($Notes.C, $Duration.EIGHTH ) +[System.Console]::Beep($Notes.C, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.QUARTER) +[System.Console]::Beep($Notes.F, $Duration.QUARTER) +[System.Console]::Beep($Notes.D, $Duration.HALF ) +Start-Sleep -m $Duration.QUARTER +[System.Console]::Beep($Notes.D, $Duration.EIGHTH ) +[System.Console]::Beep($Notes.E, $Duration.QUARTER) +[System.Console]::Beep($Notes.BB, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.QUARTER) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.CC, $Duration.EIGHTH) +[System.Console]::Beep($Notes.DD, $Duration.QUARTER) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.BB, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.QUARTER) +[System.Console]::Beep($Notes.F, $Duration.HALF) +[System.Console]::Beep($Notes.CC, $Duration.HALF) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.HALF) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.HALF) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.F, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.EIGHTH) +[System.Console]::Beep($Notes.AA, $Duration.HALF) +Start-Sleep -m $Duration.EIGHTH +[System.Console]::Beep($Notes.BB, $Duration.QUARTER) +[System.Console]::Beep($Notes.BB, $Duration.QUARTER) +[System.Console]::Beep($Notes.BB, $Duration.QUARTER) +[System.Console]::Beep($Notes.BB, $Duration.EIGHTH) +[System.Console]::Beep($Notes.BB, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.EIGHTH) +[System.Console]::Beep($Notes.AA, $Duration.EIGHTH) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.HALF) +[System.Console]::Beep($Notes.CC, $Duration.HALF) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.HALF) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.HALF) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.F, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.EIGHTH) +[System.Console]::Beep($Notes.AA, $Duration.HALF) +Start-Sleep -m $Duration.EIGHTH +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.CC, $Duration.EIGHTH) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.QUARTER) +[System.Console]::Beep($Notes.AA, $Duration.EIGHTH) +[System.Console]::Beep($Notes.AA, $Duration.EIGHTH) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.CC, $Duration.QUARTER) +[System.Console]::Beep($Notes.BB, $Duration.QUARTER) +[System.Console]::Beep($Notes.G, $Duration.QUARTER) +[System.Console]::Beep($Notes.F, $Duration.HALF) +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-jingle-bells.ps1* diff --git a/Docs/play-lion-sound.md b/Docs/play-lion-sound.md index 5a6ea566..3ac32aec 100644 --- a/Docs/play-lion-sound.md +++ b/Docs/play-lion-sound.md @@ -1,4 +1,4 @@ -## play-lion-sound.ps1 - Plays a lion sound +## The play-lion-sound.ps1 PowerShell Script This PowerShell script plays a lion sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a lion sound +.DESCRIPTION + This PowerShell script plays a lion sound. +.EXAMPLE + PS> ./play-lion-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/lion.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-lion-sound.ps1* diff --git a/Docs/play-m3u.md b/Docs/play-m3u.md index 7dfb22bc..b2b4ed1e 100644 --- a/Docs/play-m3u.md +++ b/Docs/play-m3u.md @@ -1,4 +1,4 @@ -## play-m3u.ps1 - Plays a playlist (.M3U format) +## The play-m3u.ps1 PowerShell Script This PowerShell script plays the given playlist (in .M3U file format) @@ -32,4 +32,56 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a playlist (.M3U format) +.DESCRIPTION + This PowerShell script plays the given playlist (in .M3U file format) +.PARAMETER filename + Specifies the path to the playlist +.EXAMPLE + PS> ./play-m3u C:\MyPlaylist.m3u +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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 + + add-type -assemblyName presentationCore + $MediaPlayer = new-object system.windows.media.mediaplayer + + for ([int]$i=0; $i -lt $Lines.Count; $i++) { + $Line = $Lines[$i] + if ($Line[0] -eq "#") { continue } + if (-not(test-path "$Line" -pathType leaf)) { throw "Can't access audio file: $Line" } + $FullPath = (get-childItem "$Line").fullname + $filename = (get-item "$FullPath").name + do { + $MediaPlayer.open("$FullPath") + $Milliseconds = $MediaPlayer.NaturalDuration.TimeSpan.TotalMilliseconds + } until ($Milliseconds) + [int]$Minutes = $Milliseconds / 60000 + [int]$Seconds = ($Milliseconds / 1000) % 60 + "โ–ถ๏ธPlaying ๐ŸŽต$filename ($($Minutes.ToString('00')):$($Seconds.ToString('00'))) ..." + $MediaPlayer.Volume = 1 + $MediaPlayer.play() + start-sleep -milliseconds $Milliseconds + $MediaPlayer.stop() + $MediaPlayer.close() + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of play-m3u.ps1* diff --git a/Docs/play-mission-impossible.md b/Docs/play-mission-impossible.md index df25b71c..ee1ce830 100644 --- a/Docs/play-mission-impossible.md +++ b/Docs/play-mission-impossible.md @@ -1,4 +1,4 @@ -## play-mission-impossible.ps1 - Plays the Mission Impossible theme +## The play-mission-impossible.ps1 PowerShell Script This PowerShell script plays the Mission Impossible theme. @@ -23,4 +23,66 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays the Mission Impossible theme +.DESCRIPTION + This PowerShell script plays the Mission Impossible theme. +.EXAMPLE + PS> ./play-mission-impossible +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +[System.Console]::Beep(784,150) +Start-Sleep -m 300 +[System.Console]::Beep(784,150) +Start-Sleep -m 300 +[System.Console]::Beep(932,150) +Start-Sleep -m 150 +[System.Console]::Beep(1047,150) +Start-Sleep -m 150 +[System.Console]::Beep(784,150) +Start-Sleep -m 300 +[System.Console]::Beep(784,150) +Start-Sleep -m 300 +[console]::Beep(699,150) +Start-Sleep -m 150 +[System.Console]::Beep(740,150) +Start-Sleep -m 150 +[System.Console]::Beep(784,150) +Start-Sleep -m 300 +[System.Console]::Beep(784,150) +Start-Sleep -m 300 +[System.Console]::Beep(932,150) +Start-Sleep -m 150 +[System.Console]::Beep(1047,150) +Start-Sleep -m 150 +[System.Console]::Beep(784,150) +Start-Sleep -m 300 +[System.Console]::Beep(784,150) +Start-Sleep -m 300 +[System.Console]::Beep(699,150) +Start-Sleep -m 150 +[System.Console]::Beep(740,150) +Start-Sleep -m 150 +[System.Console]::Beep(932,150) +[System.Console]::Beep(784,150) +[System.Console]::Beep(587,1200) +Start-Sleep -m 75 +[System.Console]::Beep(932,150) +[System.Console]::Beep(784,150) +[System.Console]::Beep(554,1200) +Start-Sleep -m 75 +[System.Console]::Beep(932,150) +[System.Console]::Beep(784,150) +[System.Console]::Beep(523,1200) +Start-Sleep -m 150 +[System.Console]::Beep(466,150) +[System.Console]::Beep(523,150) +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-mission-impossible.ps1* diff --git a/Docs/play-mp3.md b/Docs/play-mp3.md index 26dcad24..6599c17c 100644 --- a/Docs/play-mp3.md +++ b/Docs/play-mp3.md @@ -1,4 +1,4 @@ -## play-mp3.ps1 - Plays a MP3 sound file +## The play-mp3.ps1 PowerShell Script This PowerShell script plays a sound file in .MP3 file format. @@ -32,4 +32,55 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a MP3 sound file +.DESCRIPTION + This PowerShell script plays a sound file in .MP3 file format. +.PARAMETER Path + Specifies the path to the .MP3 file +.EXAMPLE + PS> ./play-mp3 C:\thunder.mp3 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Path = "") + +try { + if ($Path -eq "" ) { $Path = read-host "Enter the path to the MP3 sound file" } + + if (-not(test-path "$Path" -pathType leaf)) { throw "Can't access sound file: $Path" } + $FullPath = (get-childItem $Path).fullname + $Filename = (get-item "$FullPath").name + + add-type -assemblyName PresentationCore + $MediaPlayer = new-object System.Windows.Media.MediaPlayer + + do { + $MediaPlayer.open($FullPath) + $Milliseconds = $MediaPlayer.NaturalDuration.TimeSpan.TotalMilliseconds + } until ($Milliseconds) + + [int]$Minutes = $Milliseconds / 60000 + [int]$Seconds = ($Milliseconds / 1000) % 60 + "โ–ถ๏ธ Playing $Filename for $($Minutes.ToString('00')):$($Seconds.ToString('00')) sec..." + $PreviousTitle = $host.ui.RawUI.WindowTitle + $host.ui.RawUI.WindowTitle = "โ–ถ๏ธ $Filename" + $MediaPlayer.Volume = 1 + $MediaPlayer.play() + start-sleep -milliseconds $Milliseconds + $MediaPlayer.stop() + $MediaPlayer.close() + $host.ui.RawUI.WindowTitle = $PreviousTitle + + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of play-mp3.ps1* diff --git a/Docs/play-parrot-sound.md b/Docs/play-parrot-sound.md index cb9171ed..0fbf1b85 100644 --- a/Docs/play-parrot-sound.md +++ b/Docs/play-parrot-sound.md @@ -1,4 +1,4 @@ -## play-parrot-sound.ps1 - Plays a parrot sound +## The play-parrot-sound.ps1 PowerShell Script This PowerShell script plays a parrot sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a parrot sound +.DESCRIPTION + This PowerShell script plays a parrot sound. +.EXAMPLE + PS> ./play-parrot-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/parrot.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-parrot-sound.ps1* diff --git a/Docs/play-pig-sound.md b/Docs/play-pig-sound.md index 506be7be..2d1acea0 100644 --- a/Docs/play-pig-sound.md +++ b/Docs/play-pig-sound.md @@ -1,4 +1,4 @@ -## play-pig-sound.ps1 - Plays a pig sound +## The play-pig-sound.ps1 PowerShell Script This PowerShell script plays a pig sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a pig sound +.DESCRIPTION + This PowerShell script plays a pig sound. +.EXAMPLE + PS> ./play-pig-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/pig.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-pig-sound.ps1* diff --git a/Docs/play-rattlesnake-sound.md b/Docs/play-rattlesnake-sound.md index fefcc6b8..9694c7f3 100644 --- a/Docs/play-rattlesnake-sound.md +++ b/Docs/play-rattlesnake-sound.md @@ -1,4 +1,4 @@ -## play-rattlesnake-sound.ps1 - Plays a rattlesnake sound +## The play-rattlesnake-sound.ps1 PowerShell Script This PowerShell script plays a rattlesnake sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a rattlesnake sound +.DESCRIPTION + This PowerShell script plays a rattlesnake sound. +.EXAMPLE + PS> ./play-rattlesnake-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/rattlesnake.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-rattlesnake-sound.ps1* diff --git a/Docs/play-super-mario.md b/Docs/play-super-mario.md index 61aa74fe..2ad35c2a 100644 --- a/Docs/play-super-mario.md +++ b/Docs/play-super-mario.md @@ -1,4 +1,4 @@ -## play-super-mario.ps1 - Plays the Super Mario intro +## The play-super-mario.ps1 PowerShell Script This PowerShell script plays the Super Mario intro. @@ -23,4 +23,44 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays the Super Mario intro +.DESCRIPTION + This PowerShell script plays the Super Mario intro. +.EXAMPLE + PS> ./play-super-mario +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +[console]::beep(659,250) ##E +[console]::beep(659,250) ##E +[console]::beep(659,300) ##E +[console]::beep(523,250) ##C +[console]::beep(659,250) ##E +[console]::beep(784,300) ##G +[console]::beep(392,300) ##g +[console]::beep(523,275) ## C +[console]::beep(392,275) ##g +[console]::beep(330,275) ##e +[console]::beep(440,250) ##a +[console]::beep(494,250) ##b +[console]::beep(466,275) ##a# +[console]::beep(440,275) ##a +[console]::beep(392,275) ##g +[console]::beep(659,250) ##E +[console]::beep(784,250) ## G +[console]::beep(880,275) ## A +[console]::beep(698,275) ## F +[console]::beep(784,225) ## G +[console]::beep(659,250) ## E +[console]::beep(523,250) ## C +[console]::beep(587,225) ## D +[console]::beep(494,225) ## B +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-super-mario.ps1* diff --git a/Docs/play-tetris-melody.md b/Docs/play-tetris-melody.md index d329642c..ed79a34f 100644 --- a/Docs/play-tetris-melody.md +++ b/Docs/play-tetris-melody.md @@ -1,4 +1,4 @@ -## play-tetris-melody.ps1 - Plays the Tetris melody +## The play-tetris-melody.ps1 PowerShell Script This PowerShell script plays the Tetris melody. @@ -23,4 +23,134 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays the Tetris melody +.DESCRIPTION + This PowerShell script plays the Tetris melody. +.EXAMPLE + PS> ./play-tetris-melody +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +[System.Console]::Beep(1320,500) +[System.Console]::Beep(990,250) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(1188,250) +[System.Console]::Beep(1320,125) +[System.Console]::Beep(1188,125) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(990,250) +[System.Console]::Beep(880,500) +[System.Console]::Beep(880,250) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(1320,500) +[System.Console]::Beep(1188,250) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(990,750) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(1188,500) +[System.Console]::Beep(1320,500) +[System.Console]::Beep(1056,500) +[System.Console]::Beep(880,500) +[System.Console]::Beep(880,500) +start-sleep -milliseconds 250 +[System.Console]::Beep(1188,500) +[System.Console]::Beep(1408,250) +[System.Console]::Beep(1760,500) +[System.Console]::Beep(1584,250) +[System.Console]::Beep(1408,250) +[System.Console]::Beep(1320,750) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(1320,500) +[System.Console]::Beep(1188,250) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(990,500) +[System.Console]::Beep(990,250) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(1188,500) +[System.Console]::Beep(1320,500) +[System.Console]::Beep(1056,500) +[System.Console]::Beep(880,500) +[System.Console]::Beep(880,500) +start-sleep -milliseconds 500 +[System.Console]::Beep(1320,500) +[System.Console]::Beep(990,250) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(1188,250) +[System.Console]::Beep(1320,125) +[System.Console]::Beep(1188,125) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(990,250) +[System.Console]::Beep(880,500) +[System.Console]::Beep(880,250) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(1320,500) +[System.Console]::Beep(1188,250) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(990,750) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(1188,500) +[System.Console]::Beep(1320,500) +[System.Console]::Beep(1056,500) +[System.Console]::Beep(880,500) +[System.Console]::Beep(880,500) +start-sleep -milliseconds 250 +[System.Console]::Beep(1188,500) +[System.Console]::Beep(1408,250) +[System.Console]::Beep(1760,500) +[System.Console]::Beep(1584,250) +[System.Console]::Beep(1408,250) +[System.Console]::Beep(1320,750) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(1320,500) +[System.Console]::Beep(1188,250) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(990,500) +[System.Console]::Beep(990,250) +[System.Console]::Beep(1056,250) +[System.Console]::Beep(1188,500) +[System.Console]::Beep(1320,500) +[System.Console]::Beep(1056,500) +[System.Console]::Beep(880,500) +[System.Console]::Beep(880,500) +start-sleep -milliseconds 500 +[System.Console]::Beep(660,1000) +[System.Console]::Beep(528,1000) +[System.Console]::Beep(594,1000) +[System.Console]::Beep(495,1000) +[System.Console]::Beep(528,1000) +[System.Console]::Beep(440,1000) +[System.Console]::Beep(419,1000) +[System.Console]::Beep(495,1000) +[System.Console]::Beep(660,1000) +[System.Console]::Beep(528,1000) +[System.Console]::Beep(594,1000) +[System.Console]::Beep(495,1000) +[System.Console]::Beep(528,500) +[System.Console]::Beep(660,500) +[System.Console]::Beep(880,1000) +[System.Console]::Beep(838,2000) +[System.Console]::Beep(660,1000) +[System.Console]::Beep(528,1000) +[System.Console]::Beep(594,1000) +[System.Console]::Beep(495,1000) +[System.Console]::Beep(528,1000) +[System.Console]::Beep(440,1000) +[System.Console]::Beep(419,1000) +[System.Console]::Beep(495,1000) +[System.Console]::Beep(660,1000) +[System.Console]::Beep(528,1000) +[System.Console]::Beep(594,1000) +[System.Console]::Beep(495,1000) +[System.Console]::Beep(528,500) +[System.Console]::Beep(660,500) +[System.Console]::Beep(880,1000) +[System.Console]::Beep(838,2000) +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-tetris-melody.ps1* diff --git a/Docs/play-vulture-sound.md b/Docs/play-vulture-sound.md index 6ca6a5e6..ed878dff 100644 --- a/Docs/play-vulture-sound.md +++ b/Docs/play-vulture-sound.md @@ -1,4 +1,4 @@ -## play-vulture-sound.ps1 - Plays a vulture sound +## The play-vulture-sound.ps1 PowerShell Script This PowerShell script plays a vulture sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a vulture sound +.DESCRIPTION + This PowerShell script plays a vulture sound. +.EXAMPLE + PS> ./play-vulture-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/vulture.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-vulture-sound.ps1* diff --git a/Docs/play-wolf-sound.md b/Docs/play-wolf-sound.md index 578794c6..cbb8ace4 100644 --- a/Docs/play-wolf-sound.md +++ b/Docs/play-wolf-sound.md @@ -1,4 +1,4 @@ -## play-wolf-sound.ps1 - Plays a wolf sound +## The play-wolf-sound.ps1 PowerShell Script This PowerShell script plays a wolf sound. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Plays a wolf sound +.DESCRIPTION + This PowerShell script plays a wolf sound. +.EXAMPLE + PS> ./play-wolf-sound +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/play-mp3.ps1" "$PSScriptRoot/../Data/Sounds/wolf.mp3" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of play-wolf-sound.ps1* diff --git a/Docs/poweroff.md b/Docs/poweroff.md index b6a8b77f..faf6fa03 100644 --- a/Docs/poweroff.md +++ b/Docs/poweroff.md @@ -1,4 +1,4 @@ -## poweroff.ps1 - Halts the computer (needs admin rights) +## The poweroff.ps1 PowerShell Script This script halts the local computer immediately (needs admin rights). @@ -23,4 +23,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Halts the computer (needs admin rights) +.DESCRIPTION + This script halts the local computer immediately (needs admin rights). +.EXAMPLE + PS> ./poweroff +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +try { + if ($IsLinux) { + sudo shutdown + } else { + Stop-Computer + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of poweroff.ps1* diff --git a/Docs/print-image.md b/Docs/print-image.md index 29a63283..52a6a9f5 100644 --- a/Docs/print-image.md +++ b/Docs/print-image.md @@ -1,4 +1,4 @@ -## print-image.ps1 - Prints an image +## The print-image.ps1 PowerShell Script This PowerShell script shows the printer dialogue to print the given image file. @@ -32,4 +32,33 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Prints an image +.DESCRIPTION + This PowerShell script shows the printer dialogue to print the given image file. +.PARAMETER Path + Specifies the path to the image file +.EXAMPLE + PS> ./print-image dog.jpg +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param($Path = "") + +try { + if ("$Path" -eq "") { + $Path = Read-Host "Enter path to the image file" + } + Start-Process -filepath $Path -verb print + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of print-image.ps1* diff --git a/Docs/publish-to-ipfs.md b/Docs/publish-to-ipfs.md index 94693165..af6a8608 100644 --- a/Docs/publish-to-ipfs.md +++ b/Docs/publish-to-ipfs.md @@ -1,4 +1,4 @@ -## publish-to-ipfs.ps1 - Publishes files & folders to IPFS +## The publish-to-ipfs.ps1 PowerShell Script This script publishes the given files and folders to IPFS. @@ -50,4 +50,65 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Publishes files & folders to IPFS +.DESCRIPTION + This script publishes the given files and folders to IPFS. +.PARAMETER FilePattern + Specifies the file pattern +.PARAMETER HashList + Specifies the path to the resulting hash list +.PARAMETER DF_Hashes + Specifies the path to the resulting digital forensic hashes +.EXAMPLE + PS> ./publish-to-ipfs C:\MyFile.txt +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$FilePattern = "", [string]$HashList = "IPFS_hashes.txt", [string]$DF_Hashes = "file_checksums.xml") + +try { + if ($FilePattern -eq "") { $FilePattern = read-host "Enter file(s)/directories to publish" } + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + Write-Host "โณ (1/3) Searching for IPFS executable..." -NoNewline + & ipfs --version + if ($lastExitCode -ne "0") { throw "Can't execute 'ipfs' - make sure IPFS is installed and available" } + + if (test-path "$FilePattern" -pathType container) { + "โณ (2/3) Publishing folder $FilePattern/..." + & ipfs add -r "$FilePattern" > $HashList + [int]$Count = 1 + "" + "โณ (3/3) Calculating digital forensics hashes to $DF_HASHES ..." + & nice hashdeep -c md5,sha1,sha256 -r -d -l -j 1 "$FilePattern" > $DF_Hashes + } else { + $FileList = (get-childItem "$FilePattern") + foreach ($File in $FileList) { + if (test-path "$FilePattern" -pathType container) { + "โณ (2/3) Publishing folder $File/..." + & ipfs add -r "$File" >> $HashList + } else { + "โณ (3/3) Publishing file $File..." + & ipfs add "$File" >> $HashList + } + } + [int]$Count = $FileList.Count + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ published $Count file(s)/folder(s) to IPFS in $Elapsed sec" + " NOTE: to publish it to IPNS execute: ipfs name publish " + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of publish-to-ipfs.ps1* diff --git a/Docs/pull-repo.md b/Docs/pull-repo.md index 0fbca0be..93ecffad 100644 --- a/Docs/pull-repo.md +++ b/Docs/pull-repo.md @@ -1,4 +1,4 @@ -## pull-repo.ps1 - Pulls repository updates +## The pull-repo.ps1 PowerShell Script This PowerShell script pulls updates for a local Git repository (including submodules). @@ -32,4 +32,52 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Pulls repository updates +.DESCRIPTION + This PowerShell script pulls updates for a local Git repository (including submodules). +.PARAMETER RepoDir + Specifies the file path to the local Git repository (default is working directory) +.EXAMPLE + PS> ./pull-repo +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RepoDir = "$PWD") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + Write-Host "โณ (1/4) Searching for Git executable... " -noNewline + & git --version + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + $RepoDirName = (Get-Item "$RepoDir").Name + "โณ (2/4) Checking Git repository ๐Ÿ“‚$RepoDirName... " + if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access folder: $RepoDir" } + + $Result = (git -C "$RepoDir" status) + if ("$Result" -match "HEAD detached at ") { throw "Currently in detached HEAD state (not on a branch!), so nothing to pull" } + + "โณ (3/4) Pulling updates..." + & git -C "$RepoDir" pull --recurse-submodules=yes + if ($lastExitCode -ne "0") { throw "'git pull' failed with exit code $lastExitCode" } + + "โณ (4/4) Updating submodules... " + & git -C "$RepoDir" submodule update --init --recursive + if ($lastExitCode -ne "0") { throw "'git submodule update' failed with exit code $lastExitCode" } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ updated ๐Ÿ“‚$RepoDirName repository in $Elapsed sec." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of pull-repo.ps1* diff --git a/Docs/pull-repos.md b/Docs/pull-repos.md index 0e2c6975..23f23da5 100644 --- a/Docs/pull-repos.md +++ b/Docs/pull-repos.md @@ -1,4 +1,4 @@ -## pull-repos.ps1 - Pulls updates for Git repos +## The pull-repos.ps1 PowerShell Script This PowerShell script pulls updates for all Git repositories in a folder (including submodules). @@ -32,4 +32,59 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Pulls updates for Git repos +.DESCRIPTION + This PowerShell script pulls updates for all Git repositories in a folder (including submodules). +.PARAMETER ParentDir + Specifies the path to the parent folder +.EXAMPLE + PS> ./pull-repos C:\MyRepos +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$ParentDir = "$PWD") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + Write-Host "โณ (1) Searching for Git executable... " -NoNewline + & git --version + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + $ParentDirName = (Get-Item "$ParentDir").Name + Write-Host "โณ (2) Checking parent folder ๐Ÿ“‚$ParentDirName... " -NoNewline + if (-not(Test-Path "$ParentDir" -pathType container)) { throw "Can't access folder: $ParentDir" } + $Folders = (Get-ChildItem "$ParentDir" -attributes Directory) + $NumFolders = $Folders.Count + "$NumFolders subfolders" + + [int]$Step = 3 + [int]$Failed = 0 + foreach ($Folder in $Folders) { + $FolderName = (Get-Item "$Folder").Name + "โณ ($Step/$($NumFolders + 2)) Pulling into ๐Ÿ“‚$FolderName... " + + & git -C "$Folder" pull --recurse-submodules --jobs=4 + if ($lastExitCode -ne "0") { $Failed++; write-warning "'git pull' in ๐Ÿ“‚$FolderName failed" } + + & git -C "$Folder" submodule update --init --recursive + if ($lastExitCode -ne "0") { throw "'git submodule update' in ๐Ÿ“‚$Folder failed with exit code $lastExitCode" } + + $Step++ + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ pulled $NumFolders Git repositories in $Elapsed sec ($Failed failed)." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of pull-repos.ps1* diff --git a/Docs/query-smart-data.md b/Docs/query-smart-data.md index f0a9650e..292aede6 100644 --- a/Docs/query-smart-data.md +++ b/Docs/query-smart-data.md @@ -1,4 +1,4 @@ -## query-smart-data.ps1 - Queries and saves the S.M.A.R.T. data of your HDD's/SSD's +## The query-smart-data.ps1 PowerShell Script Queries the S.M.A.R.T. data of your HDD/SSD's and saves it to the current/given directory. (use smart-data2csv.ps1 to generate a CSV table for analysis). @@ -34,4 +34,68 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Queries and saves the S.M.A.R.T. data of your HDD's/SSD's +.DESCRIPTION + Queries the S.M.A.R.T. data of your HDD/SSD's and saves it to the current/given directory. + (use smart-data2csv.ps1 to generate a CSV table for analysis). + Requires smartctl (smartmontools) and admin rights. For automation copy this script to /etc/cron.daily +.PARAMETER Directory + Specifies the path to the target directory +.EXAMPLE + PS> ./query-smart-data +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +param([string]$Directory = "") + + +function CheckIfInstalled { + try { + $null = $(smartctl --version) + } catch { + write-error "smartctl is not installed - make sure smartmontools are installed" + exit 1 + } +} + +try { + if ($Directory -eq "") { + $Directory = "$PWD" + } + + write-output "(1) Checking for 'smartctl'..." + CheckIfInstalled + + write-output "(2) Scanning for S.M.A.R.T. devices..." + $Devices = $(smartctl --scan-open) + + [int]$DevNo = 1 + foreach($Device in $Devices) { + write-output "(3) Querying data from S.M.A.R.T. device $Device..." + + $Time = (Get-Date) + $Filename = "$Directory/SMART-dev$($DevNo)-$($Time.Year)-$($Time.Month)-$($Time.Day).json" + write-output "(4) Saving data to $Filename..." + + $Cmd = "smartctl --all --json " + $Device + + Invoke-Expression $Cmd > $Filename + $DevNo++ + } + + "โœ”๏ธ Done." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of query-smart-data.ps1* diff --git a/Docs/reboot-fritzbox.md b/Docs/reboot-fritzbox.md index 4760624a..b4a9b5aa 100644 --- a/Docs/reboot-fritzbox.md +++ b/Docs/reboot-fritzbox.md @@ -1,4 +1,4 @@ -## reboot-fritzbox.ps1 - Reboots the FRITZ!Box device +## The reboot-fritzbox.ps1 PowerShell Script This PowerShell script reboots the FRITZ!Box device @@ -41,4 +41,107 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Reboots the FRITZ!Box device +.DESCRIPTION + This PowerShell script reboots the FRITZ!Box device +.PARAMETER Username + Specifies the user name +.PARAMETER Password + Specifies the password +.EXAMPLE + PS> ./reboot-fritzbox +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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" } +$FB_FQDN = "fritz.box" + +if ($PSVersionTable.PSVersion.Major -lt 3) { + write-host "ERROR: Minimum Powershell Version 3.0 is required!" -F Yellow + return +} + +[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12' + +[xml]$serviceinfo = Invoke-RestMethod -Method GET -Uri "http://$($FB_FQDN):49000/tr64desc.xml" +[System.Xml.XmlNamespaceManager]$ns = new-Object System.Xml.XmlNamespaceManager $serviceinfo.NameTable +$ns.AddNamespace("ns",$serviceinfo.DocumentElement.NamespaceURI) +[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true } + + +function Execute-SOAPRequest { param([Xml]$SOAPRequest, [string]$soapactionheader, [String]$URL) + try { + $wr = [System.Net.WebRequest]::Create($URL) + $wr.Headers.Add('SOAPAction',$soapactionheader) + $wr.ContentType = 'text/xml; charset="utf-8"' + $wr.Accept = 'text/xml' + $wr.Method = 'POST' + $wr.PreAuthenticate = $true + $wr.Credentials = [System.Net.NetworkCredential]::new($Username,$Password) + + $requestStream = $wr.GetRequestStream() + $SOAPRequest.Save($requestStream) + $requestStream.Close() + [System.Net.HttpWebResponse]$wresp = $wr.GetResponse() + $responseStream = $wresp.GetResponseStream() + $responseXML = [Xml]([System.IO.StreamReader]($responseStream)).ReadToEnd() + $responseStream.Close() + return $responseXML + } catch { + if ($_.Exception.InnerException.Response){ + throw ([System.IO.StreamReader]($_.Exception.InnerException.Response.GetResponseStream())).ReadToEnd() + } else { + throw $_.Exception.InnerException + } + } +} + +function New-Request { + param( + [parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string]$urn, + [parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string]$action, + [hashtable]$parameter = @{}, + $Protocol = 'https' + ) + # SOAP Request Body Template + [xml]$request = @" + + + + + +"@ + $service = $serviceinfo.SelectNodes('//ns:service',$ns) | ?{$_.ServiceType -eq $URN} + if(!$service){throw "URN does not exist."} + $actiontag = $request.CreateElement('u',$action,$service.serviceType) + $parameter.GetEnumerator() | %{ + $el = $request.CreateElement($_.Key) + $el.InnerText = $_.Value + $actiontag.AppendChild($el)| out-null + } + $request.GetElementsByTagName('s:Body')[0].AppendChild($actiontag) | out-null + $resp = Execute-SOAPRequest $request "$($service.serviceType)#$($action)" "$($Protocol)://$($FB_FQDN):$(@{$true=$script:secport;$false=49000}[($Protocol -eq 'https')])$($service.controlURL)" + return $resp +} + +$script:secport = (New-Request -urn "urn:dslforum-org:service:DeviceInfo:1" -action 'GetSecurityPort' -proto 'http').Envelope.Body.GetSecurityPortResponse.NewSecurityPort + +function Reboot-FritzBox { + $resp = New-Request -urn 'urn:dslforum-org:service:DeviceConfig:1' -action 'Reboot' + return $resp.Envelope.Body.InnerText +} + +$Result = Reboot-FritzBox +echo $Result +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of reboot-fritzbox.ps1* diff --git a/Docs/reboot.md b/Docs/reboot.md index d2ff65e4..43d0878e 100644 --- a/Docs/reboot.md +++ b/Docs/reboot.md @@ -1,4 +1,4 @@ -## reboot.ps1 - Reboots the computer (needs admin rights) +## The reboot.ps1 PowerShell Script This PowerShell script reboots the local computer immediately (needs admin rights). @@ -23,4 +23,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Reboots the computer (needs admin rights) +.DESCRIPTION + This PowerShell script reboots the local computer immediately (needs admin rights). +.EXAMPLE + PS> ./reboot +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +try { + if ($IsLinux) { + & sudo reboot + } else { + Restart-Computer + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of reboot.ps1* diff --git a/Docs/remind-me.md b/Docs/remind-me.md index 5a426919..5bd2b71a 100644 --- a/Docs/remind-me.md +++ b/Docs/remind-me.md @@ -1,4 +1,4 @@ -## remind-me.ps1 - Creates a scheduled task that will display a popup message +## The remind-me.ps1 PowerShell Script This PowerShell script creates a scheduled task that will display a popup message. @@ -45,4 +45,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Creates a scheduled task that will display a popup message +.DESCRIPTION + This PowerShell script creates a scheduled task that will display a popup message. +.EXAMPLE + PS> ./remind-me "Dentist" "4/10/2021 12:00 PM" + + TaskPath TaskName State + -------- -------- ----- + \ Reminder_451733811 Ready +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#requires -version 4 + +param([string]$Message = "", [datetime]$Time) + +try { + if ($Message -eq "") { $Message = read-host "Enter reminder message" } + + $Task = New-ScheduledTaskAction -Execute msg -Argument "* $Message" + $Trigger = New-ScheduledTaskTrigger -Once -At $Time + $Random = (Get-Random) + Register-ScheduledTask -Action $Task -Trigger $Trigger -TaskName "Reminder_$Random" -Description "Reminder" + exit 0 +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of remind-me.ps1* diff --git a/Docs/remove-empty-dirs.md b/Docs/remove-empty-dirs.md index ec8d170c..c9c5e075 100644 --- a/Docs/remove-empty-dirs.md +++ b/Docs/remove-empty-dirs.md @@ -1,4 +1,4 @@ -## remove-empty-dirs.ps1 - Removes all empty subfolders within a directory tree +## The remove-empty-dirs.ps1 PowerShell Script This PowerShell script removes all empty subfolders within a directory tree. @@ -32,4 +32,55 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Removes all empty subfolders within a directory tree +.DESCRIPTION + This PowerShell script removes all empty subfolders within a directory tree. +.PARAMETER DirTree + Specifies the path to the directory tree +.EXAMPLE + PS> ./remove-empty-dirs C:\Temp +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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 @{ + Object = $Folder + Depth = ($Folder.FullName.Split("\")).Count + } + } + $Folders = $Folders | Sort Depth -Descending + + $Deleted = @() + foreach ($Folder in $Folders) + { + if ($Folder.Object.GetFileSystemInfos().Count -eq 0) { + $Deleted += New-Object PSObject -Property @{ + Folder = $Folder.Object.FullName + Deleted = (Get-Date -Format "hh:mm:ss tt") + Created = $Folder.Object.CreationTime + 'Last Modified' = $Folder.Object.LastWriteTime + Owner = (Get-Acl $Folder.Object.FullName).Owner + } + Remove-Item -Path $Folder.Object.FullName -Force + } + } + "โœ”๏ธ Done." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of remove-empty-dirs.ps1* diff --git a/Docs/remove-print-jobs.md b/Docs/remove-print-jobs.md index c5f86da5..ca6d9dd9 100644 --- a/Docs/remove-print-jobs.md +++ b/Docs/remove-print-jobs.md @@ -1,4 +1,4 @@ -## remove-print-jobs.ps1 - Removes all jobs from all printers +## The remove-print-jobs.ps1 PowerShell Script This PowerShell script removes all print jobs from all printer devices. @@ -23,4 +23,38 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Removes all jobs from all printers +.DESCRIPTION + This PowerShell script removes all print jobs from all printer devices. +.EXAMPLE + PS> ./remove-print-jobs +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -Version 4 + +try { + $printers = Get-Printer + if ($printers.Count -eq 0) { throw "No printer found" } + + foreach ($printer in $printers) { + $printjobs = Get-PrintJob -PrinterObject $printer + foreach ($printjob in $printjobs) { + Remove-PrintJob -InputObject $printjob + } + } + + "โœ”๏ธ all print jobs removed" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of remove-print-jobs.ps1* diff --git a/Docs/remove-tag.md b/Docs/remove-tag.md index b2c1269d..22dcbc8e 100644 --- a/Docs/remove-tag.md +++ b/Docs/remove-tag.md @@ -1,4 +1,4 @@ -## remove-tag.ps1 - Removes a Git tag (locally, remote, or both) +## The remove-tag.ps1 PowerShell Script This PowerShell script removes a Git tag, either locally, remote, or both. @@ -50,4 +50,57 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Removes a Git tag (locally, remote, or both) +.DESCRIPTION + This PowerShell script removes a Git tag, either locally, remote, or both. +.PARAMETER TagName + Specifies the Git tag name +.PARAMETER Mode + Specifies either locally, remote, or both +.PARAMETER RepoDir + Specifies the path to the Git repository +.EXAMPLE + PS> ./remove-tag v1.7 locally +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$TagName = "", [string]$Mode = "", [string]$RepoDir = "$PWD") + +try { + if ($TagName -eq "") { $TagName = read-host "Enter new tag name" } + if ($Mode -eq "") { $Mode = read-host "Remove the tag locally, remote, or both" } + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + + $Null = (git --version) + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + if (($Mode -eq "locally") -or ($Mode -eq "both")) { + "Removing local tag..." + & git -C "$RepoDir" tag --delete $TagName + if ($lastExitCode -ne "0") { throw "'git tag --delete' failed with exit code $lastExitCode" } + } + + if (($Mode -eq "remote") -or ($Mode -eq "both")) { + "Removing remote tag..." + & git -C "$RepoDir" push origin :refs/tags/$TagName + if ($lastExitCode -ne "0") { throw "'git push origin' failed with exit code $lastExitCode" } + } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ removed tag '$TagName' in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of remove-tag.ps1* diff --git a/Docs/repeat-last-reply.md b/Docs/repeat-last-reply.md index 38411c19..7765e7d2 100644 --- a/Docs/repeat-last-reply.md +++ b/Docs/repeat-last-reply.md @@ -1,4 +1,6 @@ -## repeat-last-reply.ps1 - repeat-last-reply.ps1 +## The repeat-last-reply.ps1 PowerShell Script + +repeat-last-reply.ps1 ## Parameters @@ -10,4 +12,35 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Repeats the last reply +.DESCRIPTION + This PowerShell script repeats the last reply by text-to-speech (TTS). +.EXAMPLE + PS> ./repeat-last-reply +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function GetTempDir { + if ("$env:TEMP" -ne "") { return "$env:TEMP" } + if ("$env:TMP" -ne "") { return "$env:TMP" } + if ($IsLinux) { return "/tmp" } + return "C:\Temp" +} + +if (test-path "$(GetTempDir)/last_reply_given.txt" -pathType leaf) { + $Reply = "It was: " + $Reply += Get-Content "$(GetTempDir)/last_reply_given.txt" +} else { + $Reply = "Sorry, I can't remember." +} + +& "$PSScriptRoot/give-reply.ps1" "$Reply" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of repeat-last-reply.ps1* diff --git a/Docs/replace-in-files.md b/Docs/replace-in-files.md index 53d7a833..cc4d6fd5 100644 --- a/Docs/replace-in-files.md +++ b/Docs/replace-in-files.md @@ -1,4 +1,4 @@ -## replace-in-files.ps1 - Search and replace a pattern in the given files by the replacement +## The replace-in-files.ps1 PowerShell Script This PowerShell script searches and replaces a pattern in the given files by the replacement. @@ -50,4 +50,52 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Search and replace a pattern in the given files by the replacement +.DESCRIPTION + This PowerShell script searches and replaces a pattern in the given files by the replacement. +.PARAMETER pattern + Specifies the pattern to look for +.PARAMETER replacement + Specifies the replacement +.PARAMETER files + Specifies the file to scan +.EXAMPLE + PS> ./replace-in-files NSA "No Such Agency" C:\Temp\*.txt +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$pattern = "", [string]$replacement = "", [string]$files = "") + +function ReplaceInFile { param([string]$FilePath, [string]$Pattern, [string]$Replacement) + + [System.IO.File]::WriteAllText($FilePath, + ([System.IO.File]::ReadAllText($FilePath) -replace $Pattern, $Replacement) + ) +} + +try { + if ($pattern -eq "" ) { $pattern = read-host "Enter search pattern" } + if ($replacement -eq "" ) { $replacement = read-host "Enter replacement" } + if ($files -eq "" ) { $files = read-host "Enter files" } + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + $fileList = (get-childItem -path "$files" -attributes !Directory) + foreach($file in $fileList) { + ReplaceInFile $file $pattern $replacement + } + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "OK, replaced '$pattern' by '$replacement' in $($fileList.Count) files in $Elapsed sec." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of replace-in-files.ps1* diff --git a/Docs/restart-network-adapters.md b/Docs/restart-network-adapters.md index 33e00cd9..812809bf 100644 --- a/Docs/restart-network-adapters.md +++ b/Docs/restart-network-adapters.md @@ -1,4 +1,4 @@ -## restart-network-adapters.ps1 - Restarts the network adapters (needs admin rights) +## The restart-network-adapters.ps1 PowerShell Script This PowerShell script restarts all local network adapters (needs admin rights). @@ -23,4 +23,33 @@ Author: Markus Fleschutz | License: CC0 ## Related Links htts://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Restarts the network adapters (needs admin rights) +.DESCRIPTION + This PowerShell script restarts all local network adapters (needs admin rights). +.EXAMPLE + PS> ./restart-network-adapters +.LINK + htts://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +#Requires -RunAsAdministrator + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + Get-NetAdapter | Restart-NetAdapter + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ restarted all local network adapters in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of restart-network-adapters.ps1* diff --git a/Docs/roll-a-dice.md b/Docs/roll-a-dice.md index 1b7d5ea2..107e2214 100644 --- a/Docs/roll-a-dice.md +++ b/Docs/roll-a-dice.md @@ -1,4 +1,4 @@ -## roll-a-dice.ps1 - Replies to "Roll a dice" +## The roll-a-dice.ps1 PowerShell Script This PowerShell script rolls a dice and returns the number by text-to-speech (TTS). @@ -23,4 +23,24 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Replies to "Roll a dice" +.DESCRIPTION + This PowerShell script rolls a dice and returns the number by text-to-speech (TTS). +.EXAMPLE + PS> ./roll-a-dice +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +$Reply = "It's", "I get", "Now it's", "OK, I have" | Get-Random +$Number = "1", "2", "3", "4", "5", "6" | Get-Random + +& "$PSScriptRoot/give-reply.ps1" "$Reply $Number." +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of roll-a-dice.ps1* diff --git a/Docs/save-screenshot.md b/Docs/save-screenshot.md index 44229979..7a604d7c 100644 --- a/Docs/save-screenshot.md +++ b/Docs/save-screenshot.md @@ -1,4 +1,4 @@ -## save-screenshot.ps1 - Saves a single screenshot +## The save-screenshot.ps1 PowerShell Script This PowerShell script takes a single screenshot and saves it into a target folder (the user's pictures folder by default). @@ -33,4 +33,50 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Saves a single screenshot +.DESCRIPTION + This PowerShell script takes a single screenshot and saves it into a target folder (the user's pictures folder by default). +.PARAMETER TargetFolder + Specifies the target folder (the user's pictures folder by default) +.EXAMPLE + PS> ./save-screenshot + โœ”๏ธ screenshot saved to C:\Users\Markus\Pictures\2021-10-10T14-33-22.png +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$TargetFolder = "$HOME/Pictures") + +function TakeScreenshot { param([string]$FilePath) + Add-Type -Assembly System.Windows.Forms + $ScreenBounds = [Windows.Forms.SystemInformation]::VirtualScreen + $ScreenshotObject = New-Object Drawing.Bitmap $ScreenBounds.Width, $ScreenBounds.Height + $DrawingGraphics = [Drawing.Graphics]::FromImage($ScreenshotObject) + $DrawingGraphics.CopyFromScreen( $ScreenBounds.Location, [Drawing.Point]::Empty, $ScreenBounds.Size) + $DrawingGraphics.Dispose() + $ScreenshotObject.Save($FilePath) + $ScreenshotObject.Dispose() +} + +try { + if (-not(test-path "$TargetFolder" -pathType container)) { + throw "Target folder at ๐Ÿ“‚$TargetFolder doesn't exist" + } + $Time = (Get-Date) + $Filename = "$($Time.Year)-$($Time.Month)-$($Time.Day)T$($Time.Hour)-$($Time.Minute)-$($Time.Second).png" + $FilePath = (Join-Path $TargetFolder $Filename) + TakeScreenshot $FilePath + + "โœ”๏ธ screenshot saved to $FilePath" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of save-screenshot.ps1* diff --git a/Docs/scan-ports.md b/Docs/scan-ports.md index dc1cd958..921bff1b 100644 --- a/Docs/scan-ports.md +++ b/Docs/scan-ports.md @@ -1,4 +1,4 @@ -## scan-ports.ps1 - Scans the network for open/closed ports +## The scan-ports.ps1 PowerShell Script This PowerShell script scans the network for open or closed ports. @@ -23,4 +23,38 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Scans the network for open/closed ports +.DESCRIPTION + This PowerShell script scans the network for open or closed ports. +.EXAMPLE + PS> ./scan-ports +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +$network = "192.168.178" +$port = 8080 +$range = 1..254 +$ErrorActionPreference= "silentlycontinue" + +foreach($add in $range) { + $ip = "{0}.{1}" -F $network,$add + write-progress "Scanning IP $ip" -PercentComplete (($add/$range.Count)*100) + if (Test-Connection -BufferSize 32 -Count 1 -quiet -ComputerName $ip) { + $socket = new-object System.Net.Sockets.TcpClient($ip, $port) + if ($socket.Connected) { + write-output "TCP port $port at $ip is open" + $socket.Close() + } else { + write-output "TCP port $port at $ip is not open" + } + } +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of scan-ports.ps1* diff --git a/Docs/search-filename.md b/Docs/search-filename.md index 0b1cf0bc..2c3d5af7 100644 --- a/Docs/search-filename.md +++ b/Docs/search-filename.md @@ -1,4 +1,4 @@ -## search-filename.ps1 - Lists all files and folder names matching a search pattern +## The search-filename.ps1 PowerShell Script This PowerShell script serves as a quick Powershell replacement to the search functionality in Windows After you pass in a root folder and a search term, the script will list all files and folders matching that phrase. @@ -42,4 +42,50 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists all files and folder names matching a search pattern +.DESCRIPTION + This PowerShell script serves as a quick Powershell replacement to the search functionality in Windows + After you pass in a root folder and a search term, the script will list all files and folders matching that phrase. +.PARAMETER path + Specifies the path +.PARAMETER term + Specifies the search term +.EXAMPLE + PS> ./search-filename +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param( +[Parameter(Mandatory=$true)] +$path, +[Parameter(Mandatory=$true)] +$term +) +# Recursive search function +Write-Host "Results:" +function Search-Folder($FilePath, $SearchTerm) { + # Get children + $children = Get-ChildItem -Path $FilePath + # For each child, see if it matches the search term, and if it is a folder, search it too. + foreach ($child in $children) { + $name = $child.Name + if ($name -match $SearchTerm) { + Write-Host "$FilePath\$name" + } + $isdir = Test-Path -Path "$FilePath\$name" -PathType Container + if ($isdir) { + Search-Folder -FilePath "$FilePath\$name" -SearchTerm $SearchTerm + } + } +} +# Call the search function +Search-Folder -FilePath $path -SearchTerm $term +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of search-filename.ps1* diff --git a/Docs/search-files.md b/Docs/search-files.md index 93b2b48f..a4188752 100644 --- a/Docs/search-files.md +++ b/Docs/search-files.md @@ -1,4 +1,4 @@ -## search-files.ps1 - Searches for a pattern in files +## The search-files.ps1 PowerShell Script This PowerShell script searches for a pattern in the given files. @@ -41,4 +41,47 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Searches for a pattern in files +.DESCRIPTION + This PowerShell script searches for a pattern in the given files. +.PARAMETER pattern + Specifies the search pattern +.PARAMETER files + Specifies the files +.EXAMPLE + PS> ./search-files UFO C:\Temp\*.txt +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$pattern = "", [string]$files = "") + +function ListLocations { param([string]$Pattern, [string]$Path) + $List = Select-String -Path $Path -Pattern "$Pattern" + foreach ($Item in $List) { + New-Object PSObject -Property @{ + 'Path' = "$($Item.Path)" + 'Line' = "$($Item.LineNumber)" + 'Text' = "$($Item.Line)" + } + } + write-output "(found $($List.Count) locations with pattern '$pattern')" +} + +try { + if ($pattern -eq "" ) { $pattern = read-host "Enter search pattern" } + if ($files -eq "" ) { $files = read-host "Enter path to files" } + + ListLocations $pattern $files | format-table -property Path,Line,Text + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of search-files.ps1* diff --git a/Docs/send-email.md b/Docs/send-email.md index 7b08af88..6fa111c1 100644 --- a/Docs/send-email.md +++ b/Docs/send-email.md @@ -1,4 +1,4 @@ -## send-email.ps1 - Sends an email message +## The send-email.ps1 PowerShell Script This PowerShell script sends an email message. @@ -23,4 +23,40 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sends an email message +.DESCRIPTION + This PowerShell script sends an email message. +.EXAMPLE + PS> ./send-email +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +$smtpServer = "smtp.example.com" +$From = read-host "Enter sender email address" +$To = read-host "Enter recipient email address" +$Subject = read-host "Enter subject" +$Body = read-host "Enter message" + +try { + $msg = new-object Net.Mail.MailMessage + $smtp = new-object Net.Mail.SmtpClient($smtpServer) + $msg.From = $From + $msg.ReplyTo = $From + $msg.To.Add($To) + $msg.subject = $Subject + $msg.body = $Body + $smtp.Send($msg) + "โœ”๏ธ Message sent." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of send-email.ps1* diff --git a/Docs/send-tcp.md b/Docs/send-tcp.md index fbab1131..0fbbfaa4 100644 --- a/Docs/send-tcp.md +++ b/Docs/send-tcp.md @@ -1,4 +1,4 @@ -## send-tcp.ps1 - Sends a TCP message to an IP address and port +## The send-tcp.ps1 PowerShell Script This PowerShell script sends a TCP message to the given IP address and port. @@ -50,4 +50,50 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sends a TCP message to an IP address and port +.DESCRIPTION + This PowerShell script sends a TCP message to the given IP address and port. +.PARAMETER TargetIP + Specifies the target IP address +.PARAMETER TargetPort + Specifies the target port number +.PARAMETER Message + Specifies the message to send +.EXAMPLE + PS> ./send-tcp 192.168.100.100 8080 "TEST" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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) + $Stream = $Socket.GetStream() + $Writer = New-Object System.IO.StreamWriter($Stream) + $Message | % { + $Writer.WriteLine($_) + $Writer.Flush() + } + $Stream.Close() + $Socket.Close() + + "โœ”๏ธ Done." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of send-tcp.ps1* diff --git a/Docs/send-udp.md b/Docs/send-udp.md index 5935c39f..0fc4c9d8 100644 --- a/Docs/send-udp.md +++ b/Docs/send-udp.md @@ -1,4 +1,6 @@ -## send-udp.ps1 - +## The send-udp.ps1 PowerShell Script + + ## Parameters ```powershell @@ -9,4 +11,47 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Sends a UDP datagram message to an IP address and port +.DESCRIPTION + This PowerShell script sends a UDP datagram message to an IP address and port. +.PARAMETER TargetIP + Specifies the target IP address +.PARAMETER TargetPort + Specifies the target port number +.PARAMETER Message + Specifies the message text to send +.EXAMPLE + PS> ./send-udp 192.168.100.100 8080 "TEST" + โœ”๏ธ Done. +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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) + $Socket = New-Object System.Net.Sockets.UDPClient + $EncodedText = [Text.Encoding]::ASCII.GetBytes($Message) + $SendMessage = $Socket.Send($EncodedText, $EncodedText.Length, $EndPoints) + $Socket.Close() + + "โœ”๏ธ Done." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of send-udp.ps1* diff --git a/Docs/set-profile.md b/Docs/set-profile.md index 51922221..6deb1f5b 100644 --- a/Docs/set-profile.md +++ b/Docs/set-profile.md @@ -1,4 +1,4 @@ -## set-profile.ps1 - Sets the user's PowerShell profile +## The set-profile.ps1 PowerShell Script This PowerShell script sets the PowerShell profile for the current user. @@ -23,4 +23,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the user's PowerShell profile +.DESCRIPTION + This PowerShell script sets the PowerShell profile for the current user. +.EXAMPLE + PS> ./set-profile +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "โณ Step 1/3 - Querying path to PowerShell profile 'CurrentUserCurrentHost'..." + $PathToProfile = $PROFILE.CurrentUserCurrentHost + "$PathToProfile" + + "โณ Step 2/3 - Creating the profile (if non-existent)..." + $Null = New-Item -Path $profile -ItemType "file" -Force + + "โณ Step 3/3 - Copying my-profile.ps1..." + $PathToRepo = "$PSScriptRoot/.." + Copy-Item "$PathToRepo/Scripts/my-profile.ps1" "$PathToProfile" -force + + "โœ”๏ธ updated PowerShell profile by my-profile.ps1 - it gets active on next login" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of set-profile.ps1* diff --git a/Docs/set-timer.md b/Docs/set-timer.md index cee7e0bd..87321b89 100644 --- a/Docs/set-timer.md +++ b/Docs/set-timer.md @@ -1,4 +1,4 @@ -## set-timer.ps1 - Sets a timer for a countdown +## The set-timer.ps1 PowerShell Script This PowerShell script sets a timer for a countdown. @@ -32,4 +32,38 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets a timer for a countdown +.DESCRIPTION + This PowerShell script sets a timer for a countdown. +.PARAMETER Seconds + Specifies the number of seconds +.EXAMPLE + PS> ./set-timer 60 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([int]$Seconds = 0) + +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" + start-sleep -s 1 + } + + "โœ”๏ธ $Seconds seconds countdown finished" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of set-timer.ps1* diff --git a/Docs/set-volume.md b/Docs/set-volume.md index abc38b40..5918c1ca 100644 --- a/Docs/set-volume.md +++ b/Docs/set-volume.md @@ -1,4 +1,4 @@ -## set-volume.ps1 - Sets the volume +## The set-volume.ps1 PowerShell Script This PowerShell script sets the audio volume in percent. @@ -32,4 +32,43 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the volume +.DESCRIPTION + This PowerShell script sets the audio volume in percent. +.PARAMETER volume + Specifies the percent number +.EXAMPLE + PS> ./set-volume 50 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +Param([Parameter(Mandatory=$true)] [ValidateRange(0,100)] [Int] $Volume) + +try { + # Create the Windows Shell object. + $obj = New-Object -ComObject WScript.Shell + + # First, set volume to zero. + 1..50 | ForEach-Object { $obj.SendKeys( [char] 174 ) } + + # Calculate number of (volume up) key presses + $keyPresses = [Math]::Ceiling( $Volume / 2 ) + + # Raise volume to specified level. + for( $i = 0; $i -lt $keyPresses; $i++ ) { + $obj.SendKeys( [char] 175 ) + } + & "$PSScriptRoot/give-reply.ps1" "$($Volume)% volume." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of set-volume.ps1* diff --git a/Docs/set-wallpaper.md b/Docs/set-wallpaper.md index 5d84e68d..983e8648 100644 --- a/Docs/set-wallpaper.md +++ b/Docs/set-wallpaper.md @@ -1,4 +1,4 @@ -## set-wallpaper.ps1 - Sets the given image file as desktop wallpaper +## The set-wallpaper.ps1 PowerShell Script This PowerShell script sets the given image file as desktop wallpaper (.JPG or .PNG supported) @@ -41,4 +41,77 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sets the given image file as desktop wallpaper +.DESCRIPTION + This PowerShell script sets the given image file as desktop wallpaper (.JPG or .PNG supported) +.PARAMETER ImageFile + Specifies the path to the image file +.PARAMETER Style + Specifies either Fill, Fit, Stretch, Tile, Center, or Span (default) +.EXAMPLE + PS> ./set-wallpaper C:\ocean.jpg +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$ImageFile = "", [string]$Style = "Span") + +function SetWallPaper { + param([string]$Image, [ValidateSet('Fill', 'Fit', 'Stretch', 'Tile', 'Center', 'Span')][string]$Style) + + $WallpaperStyle = switch($Style) { + "Fill" {"10"} + "Fit" {"6"} + "Stretch" {"2"} + "Tile" {"0"} + "Center" {"0"} + "Span" {"22"} + } + + if ($Style -eq "Tile") { + New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name WallpaperStyle -PropertyType String -Value $WallpaperStyle -Force + New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name TileWallpaper -PropertyType String -Value 1 -Force + } else { + New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name WallpaperStyle -PropertyType String -Value $WallpaperStyle -Force + New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name TileWallpaper -PropertyType String -Value 0 -Force + } + Add-Type -TypeDefinition @" + using System; + using System.Runtime.InteropServices; + + public class Params + { + [DllImport("User32.dll",CharSet=CharSet.Unicode)] + public static extern int SystemParametersInfo (Int32 uAction, + Int32 uParam, + String lpvParam, + Int32 fuWinIni); + } +"@ + + $SPI_SETDESKWALLPAPER = 0x0014 + $UpdateIniFile = 0x01 + $SendChangeEvent = 0x02 + + $fWinIni = $UpdateIniFile -bor $SendChangeEvent + + $ret = [Params]::SystemParametersInfo($SPI_SETDESKWALLPAPER, 0, $Image, $fWinIni) +} + +try { + if ($ImageFile -eq "" ) { $ImageFile = read-host "Enter path to image file" } + + SetWallPaper -Image $ImageFile -Style $Style + "โœ”๏ธ Done." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of set-wallpaper.ps1* diff --git a/Docs/show-lightnings.md b/Docs/show-lightnings.md index adfaa974..c54035f8 100644 --- a/Docs/show-lightnings.md +++ b/Docs/show-lightnings.md @@ -1,4 +1,4 @@ -## show-lightnings.ps1 - Shows Lightnings in OpenStreetMap +## The show-lightnings.ps1 PowerShell Script This PowerShell script launches the Web browser and shows lightnings in OpenStreetMap. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Shows Lightnings in OpenStreetMap +.DESCRIPTION + This PowerShell script launches the Web browser and shows lightnings in OpenStreetMap. +.EXAMPLE + PS> ./show-lightnings +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://www.lightningmaps.org" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of show-lightnings.ps1* diff --git a/Docs/show-notification.md b/Docs/show-notification.md index 5d94ea2d..a25d43d1 100644 --- a/Docs/show-notification.md +++ b/Docs/show-notification.md @@ -1,4 +1,4 @@ -## show-notification.ps1 - Shows a notification +## The show-notification.ps1 PowerShell Script This PowerShell script shows a toast-message notification for the Windows 10 Notification Center. @@ -47,4 +47,36 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Shows a notification +.DESCRIPTION + This PowerShell script shows a toast-message notification for the Windows 10 Notification Center. +.EXAMPLE + PS> ./show-notification "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Text = "Hello World", [string]$Title = "NOTE", [int]$Duration = 5000) + +try { + Add-Type -AssemblyName System.Windows.Forms + $global:balloon = New-Object System.Windows.Forms.NotifyIcon + $path = (Get-Process -id $pid).Path + $balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) + $balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Info + $balloon.BalloonTipText = $Text + $balloon.BalloonTipTitle = $Title + $balloon.Visible = $true + $balloon.ShowBalloonTip($Duration) + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of show-notification.ps1* diff --git a/Docs/show-traffic.md b/Docs/show-traffic.md index e3845380..884602d2 100644 --- a/Docs/show-traffic.md +++ b/Docs/show-traffic.md @@ -1,4 +1,4 @@ -## show-traffic.ps1 - Shows the current traffic +## The show-traffic.ps1 PowerShell Script This PowerShell script launches the Web browser with MSN showing the current traffic. @@ -23,4 +23,21 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Shows the current traffic +.DESCRIPTION + This PowerShell script launches the Web browser with MSN showing the current traffic. +.EXAMPLE + PS> ./show-traffic +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +& "$PSScriptRoot/open-default-browser.ps1" "https://www.msn.com/en-us/traffic?lvl=11&intent=roadClosures" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of show-traffic.ps1* diff --git a/Docs/simulate-presence.md b/Docs/simulate-presence.md index c9911ab8..58a6b886 100644 --- a/Docs/simulate-presence.md +++ b/Docs/simulate-presence.md @@ -1,4 +1,4 @@ -## simulate-presence.ps1 - Simulates the human presence against burglars +## The simulate-presence.ps1 PowerShell Script This PowerShell script simulates the human presence against burglars. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Simulates the human presence against burglars +.DESCRIPTION + This PowerShell script simulates the human presence against burglars. +.PARAMETER IPaddress + Specifies the IP address of the Shelly1 device +.EXAMPLE + PS> ./simulate-presence 192.168.100.100 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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 + & "$PSScriptRoot/switch-shelly1.ps1" $IPaddress off 0 + start-sleep -s 60 + } + + "โœ”๏ธ Done." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of simulate-presence.ps1* diff --git a/Docs/smart-data2csv.md b/Docs/smart-data2csv.md index f5790000..262ace8b 100644 --- a/Docs/smart-data2csv.md +++ b/Docs/smart-data2csv.md @@ -1,4 +1,4 @@ -## smart-data2csv.ps1 - Converts the S.M.A.R.T. JSON files in a folder to a CSV table for analysis +## The smart-data2csv.ps1 PowerShell Script This PowerShell script converts the S.M.A.R.T. JSON files in the current/given directory to a CSV table for analysis (use query-smart-data.ps1 to generate those JSON files). @@ -33,4 +33,104 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Converts the S.M.A.R.T. JSON files in a folder to a CSV table for analysis +.DESCRIPTION + This PowerShell script converts the S.M.A.R.T. JSON files in the current/given directory + to a CSV table for analysis (use query-smart-data.ps1 to generate those JSON files). +.PARAMETER Directory + Specifies the path to the directory +.EXAMPLE + PS> ./smart-data2csv +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Directory = "") + +function WriteCsvHeader { param([PSCustomObject]$File) + foreach($Entry in $File.ata_smart_attributes.table) { + [int]$ID = $Entry.id + $Name = $Entry.name + write-host -nonewline "$Name ($ID);" + } + write-host "" +} + +function WriteCsvDataRow { param([PSCustomObject]$File) + foreach($Entry in $File.ata_smart_attributes.table) { + [int]$ID = $Entry.id + switch ($ID) { + 1 { write-host -nonewline "$($Entry.raw.value);" } + 4 { write-host -nonewline "$($Entry.raw.value);" } + 7 { write-host -nonewline "$($Entry.raw.value);" } + 9 { write-host -nonewline "$($Entry.raw.value);" } + 12 { write-host -nonewline "$($Entry.raw.value);" } + 190 { write-host -nonewline "$($Entry.raw.string);" } + 191 { write-host -nonewline "$($Entry.raw.value);" } + 192 { write-host -nonewline "$($Entry.raw.value);" } + 193 { write-host -nonewline "$($Entry.raw.value);" } + 195 { write-host -nonewline "$($Entry.raw.value);" } + 240 { write-host -nonewline "$($Entry.raw.string);" } + 241 { write-host -nonewline "$($Entry.raw.value);" } + 242 { write-host -nonewline "$($Entry.raw.value);" } + default { write-host -nonewline "$($Entry.value);" } + } + } + write-host "" +} + +try { + if ($Directory -eq "" ) { + $Directory = "$PWD" + } + + $Filenames = get-childitem -path "$Directory/SMART*.json" + $ModelFamily = $ModelName = $SerialNumber = "" + + [int]$Row = 1 + foreach($Filename in $Filenames) { + $File = get-content $Filename | ConvertFrom-Json + + if ($File.model_family -ne $ModelFamily) { + if ($ModelFamily -eq "") { + $ModelFamily = $File.model_family + } else { + write-error "Different model families: $ModelFamily vs. $($File.model_family)" + exit 1 + } + } + if ($File.model_name -ne $ModelName) { + if ($ModelName -eq "") { + $ModelName = $File.model_name + } else { + write-error "Different model names: $ModelName vs. $($File.model_name)" + exit 1 + } + } + if ($File.serial_number -ne $SerialNumber) { + if ($SerialNumber -eq "") { + $SerialNumber = $File.serial_number + } else { + write-error "Different serial numbbers: $SerialNumber vs. $($File.serial_number)" + exit 1 + } + } + + if ($Row -eq 1) { + WriteCsvHeader $File + } + WriteCsvDataRow $File + $Row++ + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of smart-data2csv.ps1* diff --git a/Docs/speak-arabic.md b/Docs/speak-arabic.md index 06716313..acece182 100644 --- a/Docs/speak-arabic.md +++ b/Docs/speak-arabic.md @@ -1,4 +1,4 @@ -## speak-arabic.ps1 - Speaks text with an Arabic text-to-speech voice +## The speak-arabic.ps1 PowerShell Script This PowerShell script speaks the given text with an Arabic text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text with an Arabic text-to-speech voice +.DESCRIPTION + This PowerShell script speaks the given text with an Arabic text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-arabic "ุฃู‡ู„ุงู‹" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Arabic text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Arabic*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Arabic voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-arabic.ps1* diff --git a/Docs/speak-checklist.md b/Docs/speak-checklist.md index 2520cd5d..65f110cf 100644 --- a/Docs/speak-checklist.md +++ b/Docs/speak-checklist.md @@ -1,4 +1,4 @@ -## speak-checklist.ps1 - Speaks a checklist by text-to-speech +## The speak-checklist.ps1 PowerShell Script This PowerShell script speaks the given checklist by text-to-speech (TTS). @@ -32,4 +32,42 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks a checklist by text-to-speech +.DESCRIPTION + This PowerShell script speaks the given checklist by text-to-speech (TTS). +.PARAMETER Name + Specifies the name of the checklist +.EXAMPLE + PS> ./speak-checklist +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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 + foreach($Line in $Lines) { + if ($Line -like "HEAD*") { & "$PSScriptRoot/write-big.ps1" "$($Line.substring(5))"; continue } + + "" + & "$PSScriptRoot/give-reply.ps1" "$($Step). $Line" + $Dummy = read-host " Say or press to continue" + $Step++ + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-checklist.ps1* diff --git a/Docs/speak-countdown.md b/Docs/speak-countdown.md index 45d13491..6bc3b771 100644 --- a/Docs/speak-countdown.md +++ b/Docs/speak-countdown.md @@ -1,4 +1,4 @@ -## speak-countdown.ps1 - Speaks a countdown by text-to-speech +## The speak-countdown.ps1 PowerShell Script This PowerShell script speaks a countdown by text-to-speech (TTS) starting from a given number. @@ -32,4 +32,34 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks a countdown by text-to-speech +.DESCRIPTION + This PowerShell script speaks a countdown by text-to-speech (TTS) starting from a given number. +.PARAMETER StartNumber + Specifies the number to start from (10 by default) +.EXAMPLE + PS> ./speak-countdown 60 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([int]$StartNumber = 10) + +try { + for ([int]$i = $StartNumber; $i -gt 0; $i--) { + & "$PSScriptRoot/give-reply.ps1" $i + start-sleep -milliseconds 200 + } + & "$PSScriptRoot/give-reply.ps1" "zero" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-countdown.ps1* diff --git a/Docs/speak-danish.md b/Docs/speak-danish.md index 59db96d6..b5f55009 100644 --- a/Docs/speak-danish.md +++ b/Docs/speak-danish.md @@ -1,4 +1,4 @@ -## speak-danish.ps1 - Speaks text in Danish +## The speak-danish.ps1 PowerShell Script This PowerShell script speaks the given text with a Danish text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in Danish +.DESCRIPTION + This PowerShell script speaks the given text with a Danish text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-danish Hej +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Danish text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Danish*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Danish voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-danish.ps1* diff --git a/Docs/speak-dutch.md b/Docs/speak-dutch.md index c784a2d2..ad32ccc4 100644 --- a/Docs/speak-dutch.md +++ b/Docs/speak-dutch.md @@ -1,4 +1,4 @@ -## speak-dutch.ps1 - Speaks text in Dutch +## The speak-dutch.ps1 PowerShell Script This PowerShell script speaks the given text with a Dutch text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in Dutch +.DESCRIPTION + This PowerShell script speaks the given text with a Dutch text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-dutch Hallo +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Dutch text to speak" } + + $TTSVoice = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTSVoice.GetVoices()) { + if ($Voice.GetDescription() -like "*- Dutch*") { + $TTSVoice.Voice = $Voice + [void]$TTSVoice.Speak($text) + exit 0 # success + } + } + throw "No Dutch voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-dutch.ps1* diff --git a/Docs/speak-english.md b/Docs/speak-english.md index 150e9915..f119c586 100644 --- a/Docs/speak-english.md +++ b/Docs/speak-english.md @@ -1,4 +1,4 @@ -## speak-english.ps1 - Speaks text in English +## The speak-english.ps1 PowerShell Script This PowerShell scripts speaks the given text with an English text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in English +.DESCRIPTION + This PowerShell scripts speaks the given text with an English text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-english Hello +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ("$text" -eq "") { $text = read-host "Enter the English text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- English*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No English voice for text-to-speech (TTS) found - please install one." +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-english.ps1* diff --git a/Docs/speak-epub.md b/Docs/speak-epub.md index 9f0ce02a..71e0f73e 100644 --- a/Docs/speak-epub.md +++ b/Docs/speak-epub.md @@ -1,4 +1,4 @@ -## speak-epub.ps1 - Speaks the content of the given Epub file by text-to-speech (TTS). +## The speak-epub.ps1 PowerShell Script This PowerShell script speaks the content of the given Epub file by text-to-speech (TTS). @@ -32,4 +32,102 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks the content of the given Epub file by text-to-speech (TTS). +.DESCRIPTION + This PowerShell script speaks the content of the given Epub file by text-to-speech (TTS). +.PARAMETER Filename + Specifies the path to the Epub file +.EXAMPLE + PS> ./speak-epub C:\MyBook.epub +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Filename = "") + +function Speak { param([string]$Text) + write-output "$Text" + $Voice = new-object -ComObject SAPI.SPVoice + $Voices = $Voice.GetVoices() + foreach ($OtherVoice in $Voices) { + $Description = $OtherVoice.GetDescription() + if ($Description -like "*- English (United States)") { + $Voice.Voice = $OtherVoice + break + } + } + [void]$Voice.Speak($Text) +} + +function ReadBook() { param([string]$book, [string]$bookPath, [int]$lineNumber = 0) + $data = Get-Content $book + for([int]$i=$lineNumber;$i -lt $data.Count;$i++) { + Set-Content -Path $bookPath"\progress.txt" -Value ($book+","+$i) + $line = $data[$i] + if ($line.Contains("")) { + $line = $line -Replace "<.+?>","" + Speak $line + } + if ($line.contains("<p")) { + $line = $line -Replace "<.+?>","" + Speak $line + } + } + Set-Content -Path $bookPath"\progress.txt" -Value ("") +} + +function UnzipFile() { param([string]$file, [string]$dest) + $shell = new-object -com shell.application + $zip = $shell.NameSpace($file) + foreach($item in $zip.items()) { + $shell.Namespace($dest).copyhere($item) + } +} + +if ($Filename -eq "") { + $Filename = read-host "Enter path to .epub file" +} +write-output "Reading $Filename ..." +$file = get-item $Filename +if (-not(Test-Path $file.DirectoryName+"\"+$file.Name+".zip")) { + $zipFile = $file.DirectoryName+"\"+$file.Name+".zip" + $file.CopyTo($zipFile) +} + +$destination = $file.DirectoryName+"\"+$file.Name.Replace($file.Extension,"") +if (-not(Test-Path $destination)) { + md $destination + UnzipFile -file $zipFile -dest $destination +} + +[xml]$container = Get-Content $destination"\META-INF\container.xml" +$contentFilePath = $container.container.rootfiles.rootfile."full-path" +[xml]$content = Get-Content $destination"\"$contentFilePath +$tmpPath = Get-Item $destination"\"$contentFilePath +$bookPath = $tmpPath.DirectoryName +$progress = $null + +foreach($item in $content.package.manifest.Item) { + if ($item."media-type" -eq "application/xhtml+xml") { + if (Test-Path $bookPath+"\progress.txt") { + $progress = Get-Content $bookPath"\progress.txt" + $progress = $progress.Split(",") + } + $bookFileName = $item.href + if ($progress.Count -eq 2) { + if ($progress[0] -eq $bookPath+"\"+$bookFileName) { + ReadBook -book $bookPath"\"$bookFileName -bookPath $bookPath -lineNumber $progress[1] + } + } + else { + ReadBook -book $bookPath"\"$bookFileName -bookPath $bookPath + } + } +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-epub.ps1* diff --git a/Docs/speak-file.md b/Docs/speak-file.md index 8dff9a2c..78627cd3 100644 --- a/Docs/speak-file.md +++ b/Docs/speak-file.md @@ -1,4 +1,4 @@ -## speak-file.ps1 - Speaks file content by text-to-speech +## The speak-file.ps1 PowerShell Script This PowerShell script speaks the content of the given text file by text-to-speech (TTS). @@ -32,4 +32,35 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks file content by text-to-speech +.DESCRIPTION + This PowerShell script speaks the content of the given text file by text-to-speech (TTS). +.PARAMETER File + Specifies the path to the text file +.EXAMPLE + PS> ./speak-file C:\MyFile.txt +.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 text file" } + + $Text = Get-Content $File + + $Voice = new-object -ComObject SAPI.SPVoice + $Result = $Voice.Speak($Text) + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-file.ps1* diff --git a/Docs/speak-french.md b/Docs/speak-french.md index 306330ac..55ff72bd 100644 --- a/Docs/speak-french.md +++ b/Docs/speak-french.md @@ -1,4 +1,4 @@ -## speak-french.ps1 - Speaks text in French +## The speak-french.ps1 PowerShell Script This PowerShell script speaks the given text with a French text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in French +.DESCRIPTION + This PowerShell script speaks the given text with a French text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-french Salut +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the French text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- French*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No French voice for text-to-speech (TTS) found - please install one." +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-french.ps1* diff --git a/Docs/speak-german.md b/Docs/speak-german.md index d408c1f2..621139ef 100644 --- a/Docs/speak-german.md +++ b/Docs/speak-german.md @@ -1,4 +1,4 @@ -## speak-german.ps1 - Speaks text in German +## The speak-german.ps1 PowerShell Script This PowerShell script speaks the given text with a German text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in German +.DESCRIPTION + This PowerShell script speaks the given text with a German text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-german Hallo +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the German text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- German*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No German voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-german.ps1* diff --git a/Docs/speak-greek.md b/Docs/speak-greek.md index 37568bd8..3779f73a 100644 --- a/Docs/speak-greek.md +++ b/Docs/speak-greek.md @@ -1,4 +1,4 @@ -## speak-greek.ps1 - Speaks text with a Greek text-to-speech voice +## The speak-greek.ps1 PowerShell Script This PowerShell script speaks the given text with a Greek text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text with a Greek text-to-speech voice +.DESCRIPTION + This PowerShell script speaks the given text with a Greek text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-greek "ฮณฮตฮนฮฑ" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Greek text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Greek*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Greek voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-greek.ps1* diff --git a/Docs/speak-hindi.md b/Docs/speak-hindi.md index e9c2da24..b3c04682 100644 --- a/Docs/speak-hindi.md +++ b/Docs/speak-hindi.md @@ -1,4 +1,4 @@ -## speak-hindi.ps1 - Speaks text with a Hindi text-to-speech voice +## The speak-hindi.ps1 PowerShell Script This PowerShell script speaks the given text with a Hindi text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text with a Hindi text-to-speech voice +.DESCRIPTION + This PowerShell script speaks the given text with a Hindi text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-hindi "เคจเคฎเคธเฅเคคเฅ‡" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Hindi text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Hindi*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Hindi voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-hindi.ps1* diff --git a/Docs/speak-italian.md b/Docs/speak-italian.md index 648400c4..9238c11e 100644 --- a/Docs/speak-italian.md +++ b/Docs/speak-italian.md @@ -1,4 +1,4 @@ -## speak-italian.ps1 - Speaks text in Italian +## The speak-italian.ps1 PowerShell Script This PowerShell script speaks the given text with an Italian text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in Italian +.DESCRIPTION + This PowerShell script speaks the given text with an Italian text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-italian Ciao +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Italian text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Italian*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Italian voice for text-to-speech (TTS) found - please install one." +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-italian.ps1* diff --git a/Docs/speak-japanese.md b/Docs/speak-japanese.md index 8698d29f..f187af2f 100644 --- a/Docs/speak-japanese.md +++ b/Docs/speak-japanese.md @@ -1,4 +1,4 @@ -## speak-japanese.ps1 - Speaks text in Japanese +## The speak-japanese.ps1 PowerShell Script This PowerShell script speaks the given text with a Japanese text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in Japanese +.DESCRIPTION + This PowerShell script speaks the given text with a Japanese text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-japanese "ใƒใƒญใƒผ" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Japanese text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Japanese*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Japanese voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-japanese.ps1* diff --git a/Docs/speak-latin.md b/Docs/speak-latin.md index d5a0b584..fec46444 100644 --- a/Docs/speak-latin.md +++ b/Docs/speak-latin.md @@ -1,4 +1,4 @@ -## speak-latin.ps1 - Speaks text in Latin +## The speak-latin.ps1 PowerShell Script This PowerShell script speaks the given text with a Latin text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in Latin +.DESCRIPTION + This PowerShell script speaks the given text with a Latin text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-latin Salve +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Latin text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Latin*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Latin voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-latin.ps1* diff --git a/Docs/speak-mandarin.md b/Docs/speak-mandarin.md index 4e1a5276..b8de2e12 100644 --- a/Docs/speak-mandarin.md +++ b/Docs/speak-mandarin.md @@ -1,4 +1,4 @@ -## speak-mandarin.ps1 - Speaks text with a Mandarin text-to-speech voice +## The speak-mandarin.ps1 PowerShell Script This PowerShell script speaks the given text with a Mandarin text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text with a Mandarin text-to-speech voice +.DESCRIPTION + This PowerShell script speaks the given text with a Mandarin text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-mandarin "ไฝ ๅฅฝ" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Mandarin text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Mandarin*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Mandarin voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-mandarin.ps1* diff --git a/Docs/speak-polish.md b/Docs/speak-polish.md index d2d50214..c658e352 100644 --- a/Docs/speak-polish.md +++ b/Docs/speak-polish.md @@ -1,4 +1,4 @@ -## speak-polish.ps1 - Speaks text in Polish +## The speak-polish.ps1 PowerShell Script This PowerShell script speaks the given text with a Polish text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in Polish +.DESCRIPTION + This PowerShell script speaks the given text with a Polish text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-polish czeล›ฤ‡ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Polish text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Polish*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Polish voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-polish.ps1* diff --git a/Docs/speak-portuguese.md b/Docs/speak-portuguese.md index db9d4220..3613a1cf 100644 --- a/Docs/speak-portuguese.md +++ b/Docs/speak-portuguese.md @@ -1,4 +1,4 @@ -## speak-portuguese.ps1 - Speaks text in Portuguese +## The speak-portuguese.ps1 PowerShell Script This PowerShell script speaks the given text with a Portuguese text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in Portuguese +.DESCRIPTION + This PowerShell script speaks the given text with a Portuguese text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-portuguese Olรก +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Portuguese text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Portuguese*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Portuguese voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-portuguese.ps1* diff --git a/Docs/speak-spanish.md b/Docs/speak-spanish.md index 1fae9afa..a1f1a8d8 100644 --- a/Docs/speak-spanish.md +++ b/Docs/speak-spanish.md @@ -1,4 +1,4 @@ -## speak-spanish.ps1 - Speaks text in Spanish +## The speak-spanish.ps1 PowerShell Script This PowerShell script speaks the given text with a Spanish text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in Spanish +.DESCRIPTION + This PowerShell script speaks the given text with a Spanish text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-spanish Hola +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Spanish text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Spanish*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Spanish voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-spanish.ps1* diff --git a/Docs/speak-swedish.md b/Docs/speak-swedish.md index dc86e679..4ee032c4 100644 --- a/Docs/speak-swedish.md +++ b/Docs/speak-swedish.md @@ -1,4 +1,4 @@ -## speak-swedish.ps1 - Speaks text in Swedish +## The speak-swedish.ps1 PowerShell Script This PowerShell script speaks the given text with a Swedish text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in Swedish +.DESCRIPTION + This PowerShell script speaks the given text with a Swedish text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-swedish Hallรฅ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Swedish text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Swedish*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Swedish voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-swedish.ps1* diff --git a/Docs/speak-test.md b/Docs/speak-test.md index 3655be90..05fa5082 100644 --- a/Docs/speak-test.md +++ b/Docs/speak-test.md @@ -1,4 +1,6 @@ -## speak-test.ps1 - speak-test.ps1 +## The speak-test.ps1 PowerShell Script + +speak-test.ps1 ## Parameters @@ -10,4 +12,67 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Performs a text-to-speech test +.DESCRIPTION + This PowerShell script performs a text-to-speech (TTS) test. +.EXAMPLE + PS> ./speak-test +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function Speak { param([string]$Text) + write-output "'$Text'" + [void]$Voice.speak("$Text") +} + +try { + $Voice = new-object -ComObject SAPI.SPVoice + $DefaultVolume = $Voice.volume + $DefaultRate = $Voice.rate + Speak("This is the default voice with default volume $DefaultVolume and speed $DefaultRate") + + $Voice.rate = -10 + Speak("Let's speak very, very slow") + $Voice.rate = -5 + Speak("Let's speak very slow") + $Voice.rate = -3 + Speak("Let's speak slow") + $Voice.rate = 0 + Speak("Let's speak normal") + $Voice.rate = 2 + Speak("Let's speak fast") + $Voice.rate = 5 + Speak("Let's speak very fast") + $Voice.rate = 10 + Speak("Let's speak very, very fast") + $Voice.rate = $DefaultRate + + $Voice.volume = 100 + Speak("Let's try 100% volume") + $Voice.volume = 75 + Speak("Let's try 75% volume") + $Voice.volume = 50 + Speak("Let's try 50% volume") + $Voice.volume = 25 + Speak("Let's try 25% volume") + $Voice.volume = $DefaultVolume + + $Voices = $Voice.GetVoices() + foreach ($OtherVoice in $Voices) { + $Voice.Voice = $OtherVoice + $Description = $OtherVoice.GetDescription() + Speak("Hi, I'm the voice called $Description") + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-test.ps1* diff --git a/Docs/speak-text.md b/Docs/speak-text.md index e54f7f81..6df9c8da 100644 --- a/Docs/speak-text.md +++ b/Docs/speak-text.md @@ -1,4 +1,4 @@ -## speak-text.ps1 - Speaks text by the default text-to-speech voice +## The speak-text.ps1 PowerShell Script This PowerShell script speaks the given text by the default text-to-speech (TTS) voice. @@ -32,4 +32,33 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text by the default text-to-speech voice +.DESCRIPTION + This PowerShell script speaks the given text by the default text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to read +.EXAMPLE + PS> ./speak-text "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the text to speak" } + + $Voice = new-object -ComObject SAPI.SPVoice + [void]$Voice.Speak($text) + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-text.ps1* diff --git a/Docs/speak-ukrainian.md b/Docs/speak-ukrainian.md index 2a13a7db..c28324cd 100644 --- a/Docs/speak-ukrainian.md +++ b/Docs/speak-ukrainian.md @@ -1,4 +1,4 @@ -## speak-ukrainian.ps1 - Speaks text in Ukrainian +## The speak-ukrainian.ps1 PowerShell Script This PowerShell script speaks the given text with a Ukrainian text-to-speech (TTS) voice. @@ -32,4 +32,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Speaks text in Ukrainian +.DESCRIPTION + This PowerShell script speaks the given text with a Ukrainian text-to-speech (TTS) voice. +.PARAMETER text + Specifies the text to speak +.EXAMPLE + PS> ./speak-ukrainian "ะŸั€ะธะฒั–ั‚" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "") { $text = read-host "Enter the Ukrainian text to speak" } + + $TTS = New-Object -ComObject SAPI.SPVoice + foreach ($Voice in $TTS.GetVoices()) { + if ($Voice.GetDescription() -like "*- Ukrainian*") { + $TTS.Voice = $Voice + [void]$TTS.Speak($text) + exit 0 # success + } + } + throw "No Ukrainian voice for text-to-speech (TTS) found - please install one" +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of speak-ukrainian.ps1* diff --git a/Docs/spell-word.md b/Docs/spell-word.md index b4219f23..7e84cebf 100644 --- a/Docs/spell-word.md +++ b/Docs/spell-word.md @@ -1,4 +1,4 @@ -## spell-word.ps1 - Spells a word +## The spell-word.ps1 PowerShell Script This PowerShell script spells the given word by text-to-speech (TTS). @@ -32,4 +32,38 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Spells a word +.DESCRIPTION + This PowerShell script spells the given word by text-to-speech (TTS). +.PARAMETER word + Specifies the word to spell +.EXAMPLE + PS> ./spell-word +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$word = "") + +try { + if ($word -eq "" ) { $word = read-host "Enter word to spell" } + + [char[]]$ArrayOfChars = $word.ToUpper() + $Reply = "" + foreach($Char in $ArrayOfChars) { + $Reply += $Char + $Reply += " " + } + & "$PSScriptRoot/give-reply.ps1" "$Reply" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of spell-word.ps1* diff --git a/Docs/start-calibre-server.md b/Docs/start-calibre-server.md index 3e9c959b..fc9a51bf 100644 --- a/Docs/start-calibre-server.md +++ b/Docs/start-calibre-server.md @@ -1,4 +1,4 @@ -## start-calibre-server.ps1 - Starts a Calibre server +## The start-calibre-server.ps1 PowerShell Script This PowerShell script starts a local Calibre server as background process (using Web port 8099 by default). @@ -48,4 +48,41 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Starts a Calibre server +.DESCRIPTION + This PowerShell script starts a local Calibre server as background process (using Web port 8099 by default). +.PARAMETER port + Specifies the Web port number (8099 by default) +.EXAMPLE + PS> ./start-calibre-server +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([int]$Port = 8099, [string]$UserDB = "$HOME/CalibreUsers.sqlite", [string]$Logfile = "$HOME/CalibreServer.log") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + "โณ Step 1/2 - Searching for Calibre server executable..." + & calibre-server --version + if ($lastExitCode -ne "0") { throw "Can't execute 'calibre-server' - make sure Calibre server is installed and available" } + + "โณ Step 2/2 - Starting Calibre server as background process..." + " (Web port $Port, user DB at $UserDB, log file at $Logfile)" + & calibre-server --port $Port --num-per-page 100 --userdb $UserDB --log $Logfile --daemonize $HOME/'Calibre Library' + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ started Calibre server in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of start-calibre-server.ps1* diff --git a/Docs/start-ipfs-server.md b/Docs/start-ipfs-server.md index 5ff8058e..179c4fb2 100644 --- a/Docs/start-ipfs-server.md +++ b/Docs/start-ipfs-server.md @@ -1,4 +1,4 @@ -## start-ipfs-server.ps1 - Start an IPFS server +## The start-ipfs-server.ps1 PowerShell Script This PowerShell script starts a local IPFS server as a daemon process. @@ -23,4 +23,63 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Start an IPFS server +.DESCRIPTION + This PowerShell script starts a local IPFS server as a daemon process. +.EXAMPLE + PS> ./start-ipfs-server +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + Write-Host "โณ (1/5) Searching for IPFS executable... " -noNewline + & ipfs --version + if ($lastExitCode -ne "0") { throw "Can't execute 'ipfs' - make sure IPFS is installed and available" } + "โณ (2/5) Init IPFS with profile 'lowpower'..." + & ipfs init --profile lowpower + + "โณ (3/5) Configuring IPFS..." + & ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001 + if ($lastExitCode -ne "0") { throw "'ipfs config Addresses.API' failed with exit code $lastExitCode" } + + & ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8765 + if ($lastExitCode -ne "0") { throw "'ipfs config Addresses.Gateway' failed with exit code $lastExitCode" } + + $Hostname = $(hostname) + & ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '[\"http://miami:5001\", \"http://localhost:3000\", \"http://127.0.0.1:5001\", \"https://webui.ipfs.io\"]' + if ($lastExitCode -ne "0") { throw "'ipfs config Access-Control-Allow-Origin' failed with exit code $lastExitCode" } + + & ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '[\"PUT\", \"POST\"]' + if ($lastExitCode -ne "0") { throw "'ipfs config Access-Control-Allow-Methods' failed with exit code $lastExitCode" } + + & ipfs config --json AutoNAT.Throttle.GlobalLimit 1 # (30 by default) + if ($lastExitCode -ne "0") { throw "'ipfs config AutoNAT.Throttle.GlobalLimit 1' failed with exit code $lastExitCode" } + + & ipfs config --json AutoNAT.Throttle.PeerLimit 1 # (3 by default) + if ($lastExitCode -ne "0") { throw "'ipfs config AutoNAT.Throttle.PeerLimit 1' failed with exit code $lastExitCode" } + "" + Write-Host "โณ (4/5) Increasing UDP receive buffer size..." -noNewline + & sudo sysctl -w net.core.rmem_max=2500000 + if ($lastExitCode -ne "0") { throw "'sysctl' failed with exit code $lastExitCode" } + "โณ (5/5) Starting IPFS daemon..." +# Start-Process nohup 'ipfs daemon' + Start-Process nohup -ArgumentList 'ipfs','daemon' -RedirectStandardOutput "$HOME/console.out" -RedirectStandardError "$HOME/console.err" + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ started IPFS server in $Elapsed sec" + "โš ๏ธ NOTE: make sure your router does not block TCP/UDP port 4001 for IPv4 and IPv6" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of start-ipfs-server.ps1* diff --git a/Docs/suspend.md b/Docs/suspend.md index 766709f9..31517df1 100644 --- a/Docs/suspend.md +++ b/Docs/suspend.md @@ -1,4 +1,4 @@ -## suspend.ps1 - Suspends the computer +## The suspend.ps1 PowerShell Script This PowerShell script suspends the local computer immediately. @@ -23,4 +23,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Suspends the computer +.DESCRIPTION + This PowerShell script suspends the local computer immediately. +.EXAMPLE + PS> ./suspend +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Bye bye." + & rundll32.exe powrprof.dll,SetSuspendState 0,1,0 # bHibernate,bForce,bWakeupEventsDisabled + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of suspend.ps1* diff --git a/Docs/switch-branch.md b/Docs/switch-branch.md index 33b2ab5f..4ba48e2b 100644 --- a/Docs/switch-branch.md +++ b/Docs/switch-branch.md @@ -1,4 +1,4 @@ -## switch-branch.ps1 - Switches the Git branch +## The switch-branch.ps1 PowerShell Script This PowerShell script switches to another branch in a Git repository (including submodules). @@ -41,4 +41,67 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Switches the Git branch +.DESCRIPTION + This PowerShell script switches to another branch in a Git repository (including submodules). +.PARAMETER BranchName + Specifies the branch name +.PARAMETER RepoDir + Specifies the path to the Git repository +.EXAMPLE + PS> ./switch-branch main C:\MyRepo +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$BranchName = "", [string]$RepoDir = "$PWD") + +try { + if ($BranchName -eq "") { $BranchName = read-host "Enter name of branch to switch to" } + if ($RepoDir -eq "") { $RepoDir = read-host "Enter path to the Git repository" } + + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + Write-Host "โณ (1/6) Searching for Git executable... " -noNewline + & git --version + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + $RepoDir = Resolve-Path "$RepoDir" + $RepoDirName = (Get-Item "$RepoDir").Name + "โณ (2/6) Checking folder ๐Ÿ“‚$RepoDirName..." + if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + + $Result = (git status) + if ($lastExitCode -ne "0") { throw "'git status' in $RepoDir failed with exit code $lastExitCode" } + if ("$Result" -notmatch "nothing to commit, working tree clean") { throw "Git repository is NOT clean: $Result" } + + "โณ (3/6) Fetching updates..." + & git -C "$RepoDir" fetch --all --prune --prune-tags --force + if ($lastExitCode -ne "0") { throw "'git fetch' failed with exit code $lastExitCode" } + + "โณ (4/6) Switching to branch '$BranchName'..." + & git -C "$RepoDir" checkout --recurse-submodules "$BranchName" + if ($lastExitCode -ne "0") { throw "'git checkout $BranchName' failed with exit code $lastExitCode" } + + "โณ (5/6) Pulling updates..." + & git -C "$RepoDir" pull --recurse-submodules + if ($lastExitCode -ne "0") { throw "'git pull' failed with exit code $lastExitCode" } + + "โณ (6/6) Updating submodules..." + & git -C "$RepoDir" submodule update --init --recursive + if ($lastExitCode -ne "0") { throw "'git submodule update' failed with exit code $lastExitCode" } + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ switched ๐Ÿ“‚$RepoDirName repo to $BranchName branch in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of switch-branch.ps1* diff --git a/Docs/switch-shelly1.md b/Docs/switch-shelly1.md index 16292fec..bea55e78 100644 --- a/Docs/switch-shelly1.md +++ b/Docs/switch-shelly1.md @@ -1,4 +1,4 @@ -## switch-shelly1.ps1 - Switches a Shelly1 device +## The switch-shelly1.ps1 PowerShell Script This PowerShell script switches a Shelly1 device in the local network. @@ -50,4 +50,40 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Switches a Shelly1 device +.DESCRIPTION + This PowerShell script switches a Shelly1 device in the local network. +.PARAMETER Host + Specifies either the hostname or IP address of the Shelly1 device +.PARAMETER TurnMode + Specifies either 'on', 'off', or 'toggle' +.PARAMETER Timer + Specifies the timer in seconds (0 = infinite) +.EXAMPLE + PS> ./switch-shelly1 192.168.100.100 toggle 10 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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)" + + "โœ”๏ธ switched Shelly1 device at $Host to $TurnMode for $Timer sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of switch-shelly1.ps1* diff --git a/Docs/sync-repo.md b/Docs/sync-repo.md index 99b9f733..9d2c89f8 100644 --- a/Docs/sync-repo.md +++ b/Docs/sync-repo.md @@ -1,4 +1,4 @@ -## sync-repo.ps1 - Synchronizes a Git repository +## The sync-repo.ps1 PowerShell Script This PowerShell script synchronizes a Git repository by push & pull (including submodules). @@ -32,4 +32,48 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Synchronizes a Git repository +.DESCRIPTION + This PowerShell script synchronizes a Git repository by push & pull (including submodules). +.PARAMETER RepoDir + Specifies the path to the Git repository +.EXAMPLE + PS> ./sync-repo C:\MyRepo +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$RepoDir = "$PWD") + +try { + $StopWatch = [system.diagnostics.stopwatch]::startNew() + + "โณ Step 1/3: Checking requirements..." + if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } + + & git --version + if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } + + "โณ Step 2/3: Pushing local updates..." + & git -C "$RepoDir" push + if ($lastExitCode -ne "0") { throw "'git push' failed" } + + "โณ Step 3/3: Pulling remote updates..." + & git -C "$RepoDir" pull --all --recurse-submodules --jobs=4 + if ($lastExitCode -ne "0") { throw "'git pull' failed" } + + $RepoDirName = (Get-Item "$RepoDir").Name + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ synchronized Git repo ๐Ÿ“‚$RepoDirName in $Elapsed sec" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of sync-repo.ps1* diff --git a/Docs/tell-joke.md b/Docs/tell-joke.md index 1b64ae9b..3027d0bb 100644 --- a/Docs/tell-joke.md +++ b/Docs/tell-joke.md @@ -1,4 +1,4 @@ -## tell-joke.ps1 - Tells a joke by text-to-speech +## The tell-joke.ps1 PowerShell Script This PowerShell script selects a random Chuck Norris joke in Data/jokes.csv and speaks it by text-to-speech (TTS). @@ -23,4 +23,32 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Tells a joke by text-to-speech +.DESCRIPTION + This PowerShell script selects a random Chuck Norris joke in Data/jokes.csv and speaks it by text-to-speech (TTS). +.EXAMPLE + PS> ./tell-joke +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Table = Import-CSV "$PSScriptRoot/../Data/jokes.csv" + + $Generator = New-Object System.Random + $Index = [int]$Generator.next(0, $Table.Count - 1) + $Reply = $Table[$Index].Joke + + & "$PSScriptRoot/give-reply.ps1" "$Reply" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of tell-joke.ps1* diff --git a/Docs/tell-quote.md b/Docs/tell-quote.md index 800867dc..758b2a93 100644 --- a/Docs/tell-quote.md +++ b/Docs/tell-quote.md @@ -1,4 +1,4 @@ -## tell-quote.ps1 - Tells a quote by text-to-speech +## The tell-quote.ps1 PowerShell Script This PowerShell script selects a random quote in Data/quotes.csv and speaks it by text-to-speech (TTS). @@ -23,4 +23,34 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Tells a quote by text-to-speech +.DESCRIPTION + This PowerShell script selects a random quote in Data/quotes.csv and speaks it by text-to-speech (TTS). +.EXAMPLE + PS> ./tell-quote +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Table = import-csv "$PSScriptRoot/../Data/quotes.csv" + + $Generator = New-Object System.Random + $Index = [int]$Generator.next(0, $Table.Count - 1) + $Quote = $Table[$Index].Quote + $Author = $Table[$Index].Author + $Reply = "$Quote (by $Author)" + + & "$PSScriptRoot/give-reply.ps1" "$Reply" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of tell-quote.ps1* diff --git a/Docs/toggle-caps-lock.md b/Docs/toggle-caps-lock.md index da7383a3..61f739de 100644 --- a/Docs/toggle-caps-lock.md +++ b/Docs/toggle-caps-lock.md @@ -1,4 +1,4 @@ -## toggle-caps-lock.ps1 - Toggle Caps Lock +## The toggle-caps-lock.ps1 PowerShell Script This PowerShell script toggles the Caps Lock key state. @@ -23,4 +23,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Toggle Caps Lock +.DESCRIPTION + This PowerShell script toggles the Caps Lock key state. +.EXAMPLE + PS> ./toggle-caps-lock +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $wsh = New-Object -ComObject WScript.Shell + $wsh.SendKeys('{CAPSLOCK}') + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of toggle-caps-lock.ps1* diff --git a/Docs/toggle-num-lock.md b/Docs/toggle-num-lock.md index e7048543..fccf0f0f 100644 --- a/Docs/toggle-num-lock.md +++ b/Docs/toggle-num-lock.md @@ -1,4 +1,4 @@ -## toggle-num-lock.ps1 - Toggle Num Lock +## The toggle-num-lock.ps1 PowerShell Script This PowerShell script toggles the Num Lock key state. @@ -23,4 +23,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Toggle Num Lock +.DESCRIPTION + This PowerShell script toggles the Num Lock key state. +.EXAMPLE + PS> ./toggle-num-lock +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $wsh = New-Object -ComObject WScript.Shell + $wsh.SendKeys('{NUMLOCK}') + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of toggle-num-lock.ps1* diff --git a/Docs/toggle-scroll-lock.md b/Docs/toggle-scroll-lock.md index 7130352f..75d49d1a 100644 --- a/Docs/toggle-scroll-lock.md +++ b/Docs/toggle-scroll-lock.md @@ -1,4 +1,4 @@ -## toggle-scroll-lock.ps1 - Toggle Scroll Lock +## The toggle-scroll-lock.ps1 PowerShell Script This PowerShell script toggles the Scroll Lock key state. @@ -23,4 +23,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Toggle Scroll Lock +.DESCRIPTION + This PowerShell script toggles the Scroll Lock key state. +.EXAMPLE + PS> ./toggle-scroll-lock +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $wsh = New-Object -ComObject WScript.Shell + $wsh.SendKeys('{SCROLLLOCK}') + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of toggle-scroll-lock.ps1* diff --git a/Docs/translate-file.md b/Docs/translate-file.md index 2ac80cb4..03068db2 100644 --- a/Docs/translate-file.md +++ b/Docs/translate-file.md @@ -1,4 +1,4 @@ -## translate-file.ps1 - Translates a text file into another language +## The translate-file.ps1 PowerShell Script This PowerShell script translates a text file into another language. @@ -50,4 +50,54 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Translates a text file into another language +.DESCRIPTION + This PowerShell script translates a text file into another language. +.PARAMETER File + Specifies the file to translate +.PARAMETER SourceLang + Specifies the source language +.PARAMETER TargetLang + Specifies the target language +.EXAMPLE + PS> ./translate-file C:\Memo.txt en de +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$File = "", [string]$SourceLang = "", [string]$TargetLang = "") + +function UseLibreTranslate { param([string]$Text, [string]$SourceLang, [string]$TargetLang) + $Parameters = @{"q"="$Text"; "source"="$SourceLang"; "target"="$TargetLang"; } + $Result = (Invoke-WebRequest -Uri https://libretranslate.com/translate -Method POST -Body ($Parameters|ConvertTo-Json) -ContentType "application/json").content | ConvertFrom-Json + start-sleep -milliseconds 3000 # 20 requests per minute maximum + return $Result.translatedText +} + +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 } + if ("$Line" -eq " ") { write-output "$Line"; continue } + if ("$Line" -like "===*") { write-output "$Line"; continue } + if ("$Line" -like "---*") { write-output "$Line"; continue } + if ("$Line" -like "!*(/*)") { write-output "$Line"; continue } + $Result = UseLibreTranslate $Line $SourceLang $TargetLang + write-output $Result + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of translate-file.ps1* diff --git a/Docs/translate-files.md b/Docs/translate-files.md index 6a2d20f9..db348812 100644 --- a/Docs/translate-files.md +++ b/Docs/translate-files.md @@ -1,4 +1,6 @@ -## translate-files.ps1 - +## The translate-files.ps1 PowerShell Script + + ## Parameters ```powershell @@ -9,4 +11,56 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Translates text files into any supported language +.DESCRIPTION + This PowerShell script translates text files into any supported language. +.PARAMETER FilePattern + Specifies the file pattern +.EXAMPLE + PS> ./translate-files C:\Temp\*.txt +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$FilePattern = "") + +function DetectSourceLang { param([string]$Filename) + if ("$Filename" -like "*Deutsch*") { return "de" } + if ("$Filename" -like "*English*") { return "en" } + if ("$Filename" -like "*Franรงais*") { return "fr" } + return "unknown" +} + +function TranslateFilename { param([string]$Filename, [string]$SourceLang, [string]$TargetLang) + if ($SourceLang -eq "de") { $SourceLanguage = "Deutsch" } + if ($SourceLang -eq "en") { $SourceLanguage = "English" } + if ($SourceLang -eq "fr") { $SourceLanguage = "Franรงais" } + $TargetLanguage = ("$PSScriptRoot/translate-text.ps1" $SourceLanguage $SourceLang $TargetLang) + return $Filename.replace($SourceLanguage, $TargetLanguage) +} + +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) { + $SourceLang = DetectSourceLang $SourceFile + foreach($TargetLang in $TargetLanguages) { + if ($SourceLang -eq $TargetLang) { continue } + $TargetFile = TranslateFilename $SourceFile $SourceLang $TargetLang + & "$PSScriptRoot/translate-file.ps1" $SourceFile $SourceLang $TargetLang > $TargetFile + } + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of translate-files.ps1* diff --git a/Docs/translate-text.md b/Docs/translate-text.md index 6ec14073..069e683f 100644 --- a/Docs/translate-text.md +++ b/Docs/translate-text.md @@ -1,4 +1,4 @@ -## translate-text.ps1 - Translates text into other languages +## The translate-text.ps1 PowerShell Script This PowerShell script translates text into other languages. @@ -48,4 +48,51 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Translates text into other languages +.DESCRIPTION + This PowerShell script translates text into other languages. +.PARAMETER Text + Specifies the text to translate +.PARAMETER SourceLang + Specifies the source language +.PARAMETER TargetLang + Specifies the target language +.EXAMPLE + PS> ./translate-text "Hello World" de en +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Text = "", [string]$SourceLangCode = "en", [string]$TargetLangCode = "any") + +function UseLibreTranslate { param([string]$Text, [string]$SourceLangCode, [string]$TargetLangCode) + $Parameters = @{"q"="$Text"; "source"="$SourceLangCode"; "target"="$TargetLangCode"; } + $Result = (Invoke-WebRequest -Uri https://translate.mentality.rip/translate -Method POST -Body ($Parameters|ConvertTo-Json) -ContentType "application/json" -useBasicParsing).content | ConvertFrom-Json + return $Result.translatedText +} + +try { + if ($Text -eq "" ) { $Text = read-host "Enter text to translate" } + + if ($TargetLangCode -eq "any") { + $TargetLangCodes = "ar","de","es","fr","ga","hi","it","ja","ko","pt","ru","zh" + foreach($TargetLangCode in $TargetLangCodes) { + $Translation = UseLibreTranslate $Text $SourceLangCode $TargetLangCode + write-output "$($TargetLangCode): $Translation" + } + } else { + $Translation = UseLibreTranslate $Text $SourceLangCode $TargetLangCode + write-output "$Translation" + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of translate-text.ps1* diff --git a/Docs/turn-volume-down.md b/Docs/turn-volume-down.md index 25704d2d..8b3367ba 100644 --- a/Docs/turn-volume-down.md +++ b/Docs/turn-volume-down.md @@ -1,4 +1,4 @@ -## turn-volume-down.ps1 - Turns the volume down +## The turn-volume-down.ps1 PowerShell Script This PowerShell script turns the audio volume down (-10% by default). @@ -32,4 +32,34 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Turns the volume down +.DESCRIPTION + This PowerShell script turns the audio volume down (-10% by default). +.PARAMETER percent + Specifies the percent number +.EXAMPLE + PS> ./turn-volume-down +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([int]$percent = 10) + +try { + $obj = New-Object -com wscript.shell + for ([int]$i = 0; $i -lt $percent; $i += 2) { + $obj.SendKeys([char]174) # each tick is -2% + } + & "$PSScriptRoot/give-reply.ps1" "$($percent)% softer." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of turn-volume-down.ps1* diff --git a/Docs/turn-volume-fully-up.md b/Docs/turn-volume-fully-up.md index 1709defd..c92f0049 100644 --- a/Docs/turn-volume-fully-up.md +++ b/Docs/turn-volume-fully-up.md @@ -1,4 +1,4 @@ -## turn-volume-fully-up.ps1 - Turns audio volume fully up +## The turn-volume-fully-up.ps1 PowerShell Script This PowerShell script turns the audio volume fully up to 100%. @@ -23,4 +23,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Turns audio volume fully up +.DESCRIPTION + This PowerShell script turns the audio volume fully up to 100%. +.EXAMPLE + PS> ./turn-volume-fully-up +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $obj = New-Object -com wscript.shell + for ([int]$i = 0; $i -lt 100; $i += 2) { + $obj.SendKeys([char]175) # each tick is +2% + } + & "$PSScriptRoot/give-reply.ps1" "Hundred percent now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of turn-volume-fully-up.ps1* diff --git a/Docs/turn-volume-off.md b/Docs/turn-volume-off.md index f73b2da6..2b1f6204 100644 --- a/Docs/turn-volume-off.md +++ b/Docs/turn-volume-off.md @@ -1,4 +1,4 @@ -## turn-volume-off.ps1 - Turn audio off +## The turn-volume-off.ps1 PowerShell Script This PowerShell script mutes the default audio device immediately. @@ -23,4 +23,28 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Turn audio off +.DESCRIPTION + This PowerShell script mutes the default audio device immediately. +.EXAMPLE + PS> ./turn-volume-off +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $obj = new-object -com wscript.shell + $obj.SendKeys([char]173) + & "$PSScriptRoot/give-reply.ps1" "Audio is off." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of turn-volume-off.ps1* diff --git a/Docs/turn-volume-on.md b/Docs/turn-volume-on.md index b830d9a7..ce1a0954 100644 --- a/Docs/turn-volume-on.md +++ b/Docs/turn-volume-on.md @@ -1,4 +1,4 @@ -## turn-volume-on.ps1 - Turn audio on +## The turn-volume-on.ps1 PowerShell Script This PowerShell script immediately unmutes the audio output. @@ -23,4 +23,28 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Turn audio on +.DESCRIPTION + This PowerShell script immediately unmutes the audio output. +.EXAMPLE + PS> .\turn-volume-on +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $obj = new-object -com wscript.shell + $obj.SendKeys([char]173) + & "$PSScriptRoot/give-reply.ps1" "Audio is on." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of turn-volume-on.ps1* diff --git a/Docs/turn-volume-up.md b/Docs/turn-volume-up.md index 3886e1b4..b5c4b49c 100644 --- a/Docs/turn-volume-up.md +++ b/Docs/turn-volume-up.md @@ -1,4 +1,4 @@ -## turn-volume-up.ps1 - Turns the volume up +## The turn-volume-up.ps1 PowerShell Script This PowerShell script turns the audio volume up (+10% by default). @@ -32,4 +32,34 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Turns the volume up +.DESCRIPTION + This PowerShell script turns the audio volume up (+10% by default). +.PARAMETER percent + Specifies the percent number +.EXAMPLE + PS> ./turn-volume-up +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([int]$percent = 10) + +try { + $obj = New-Object -com wscript.shell + for ([int]$i = 0; $i -lt $percent; $i += 2) { + $obj.SendKeys([char]175) # each tick is +2% + } + & "$PSScriptRoot/give-reply.ps1" "$($percent)% louder." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of turn-volume-up.ps1* diff --git a/Docs/uninstall-crystal-disk-info.md b/Docs/uninstall-crystal-disk-info.md index 0fb084cc..95f40e9a 100644 --- a/Docs/uninstall-crystal-disk-info.md +++ b/Docs/uninstall-crystal-disk-info.md @@ -1,4 +1,4 @@ -## uninstall-crystal-disk-info.ps1 - Uninstalls CrystalDiskInfo +## The uninstall-crystal-disk-info.ps1 PowerShell Script This PowerShell script uninstalls CrystalDiskInfo from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls CrystalDiskInfo +.DESCRIPTION + This PowerShell script uninstalls CrystalDiskInfo from the local computer. +.EXAMPLE + PS> ./uninstall-crystal-disk-info +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling CrystalDiskInfo, please wait..." + + & winget uninstall "CrystalDiskInfo" + if ($lastExitCode -ne "0") { throw "Can't uninstall CrystalDiskInfo, is it installed?" } + + "CrystalDiskInfo is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-crystal-disk-info.ps1* diff --git a/Docs/uninstall-crystal-disk-mark.md b/Docs/uninstall-crystal-disk-mark.md index 3899386c..d3fb8c93 100644 --- a/Docs/uninstall-crystal-disk-mark.md +++ b/Docs/uninstall-crystal-disk-mark.md @@ -1,4 +1,4 @@ -## uninstall-crystal-disk-mark.ps1 - Uninstalls CrystalDiskMark +## The uninstall-crystal-disk-mark.ps1 PowerShell Script This PowerShell script uninstalls CrystalDiskMark from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls CrystalDiskMark +.DESCRIPTION + This PowerShell script uninstalls CrystalDiskMark from the local computer. +.EXAMPLE + PS> ./uninstall-crystal-disk-mark +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling CrystalDiskMark, please wait..." + + & winget uninstall "CrystalDiskMark Shizuku Edition" + if ($lastExitCode -ne "0") { throw "Can't uninstall CrystalDiskMark, is it installed?" } + + "CrystalDiskMark is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-crystal-disk-mark.ps1* diff --git a/Docs/uninstall-discord.md b/Docs/uninstall-discord.md index aad3dc75..0b572e34 100644 --- a/Docs/uninstall-discord.md +++ b/Docs/uninstall-discord.md @@ -1,4 +1,4 @@ -## uninstall-discord.ps1 - Uninstalls Discord +## The uninstall-discord.ps1 PowerShell Script This PowerShell script uninstalls Discord from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Discord +.DESCRIPTION + This PowerShell script uninstalls Discord from the local computer. +.EXAMPLE + PS> ./uninstall-discord +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Discord, please wait..." + + & winget uninstall "Discord" + if ($lastExitCode -ne "0") { throw "Can't uninstall Discord, is it installed?" } + + "Discord is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-discord.ps1* diff --git a/Docs/uninstall-edge.md b/Docs/uninstall-edge.md index 0c7006cd..30b68d17 100644 --- a/Docs/uninstall-edge.md +++ b/Docs/uninstall-edge.md @@ -1,4 +1,4 @@ -## uninstall-edge.ps1 - Uninstalls Microsoft Edge +## The uninstall-edge.ps1 PowerShell Script This PowerShell script uninstalls Microsoft Edge from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Microsoft Edge +.DESCRIPTION + This PowerShell script uninstalls Microsoft Edge from the local computer. +.EXAMPLE + PS> ./uninstall-edge +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Microsoft Edge, please wait..." + + & winget uninstall "Microsoft Edge Browser" + if ($lastExitCode -ne "0") { throw "Can't uninstall Edge, is it installed?" } + + "Microsoft Edge is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-edge.ps1* diff --git a/Docs/uninstall-firefox.md b/Docs/uninstall-firefox.md index af3f2a8b..ce02577d 100644 --- a/Docs/uninstall-firefox.md +++ b/Docs/uninstall-firefox.md @@ -1,4 +1,4 @@ -## uninstall-firefox.ps1 - Uninstalls Mozilla Firefox +## The uninstall-firefox.ps1 PowerShell Script This PowerShell script uninstalls Mozilla Firefox from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Mozilla Firefox +.DESCRIPTION + This PowerShell script uninstalls Mozilla Firefox from the local computer. +.EXAMPLE + PS> ./uninstall-firefox +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Mozilla Firefox, please wait..." + + & winget uninstall "Mozilla Firefox" + if ($lastExitCode -ne "0") { throw "Can't uninstall Firefox, is it installed?" } + + "Mozilla Firefox is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-firefox.ps1* diff --git a/Docs/uninstall-git-extensions.md b/Docs/uninstall-git-extensions.md index 68d0ba45..57c1549a 100644 --- a/Docs/uninstall-git-extensions.md +++ b/Docs/uninstall-git-extensions.md @@ -1,4 +1,4 @@ -## uninstall-git-extensions.ps1 - Uninstalls Git Extensions +## The uninstall-git-extensions.ps1 PowerShell Script This PowerShell script uninstalls Git Extensions from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Git Extensions +.DESCRIPTION + This PowerShell script uninstalls Git Extensions from the local computer. +.EXAMPLE + PS> ./uninstall-git-extensions +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Git Extensions, please wait..." + + & winget uninstall --id GitExtensionsTeam.GitExtensions + if ($lastExitCode -ne "0") { throw "Can't uninstall Git Extensions, is it installed?" } + + "Git Extensions is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-git-extensions.ps1* diff --git a/Docs/uninstall-irfanview.md b/Docs/uninstall-irfanview.md index 8a4fa8a3..59a09343 100644 --- a/Docs/uninstall-irfanview.md +++ b/Docs/uninstall-irfanview.md @@ -1,4 +1,4 @@ -## uninstall-irfanview.ps1 - Uninstalls IrfanView +## The uninstall-irfanview.ps1 PowerShell Script This PowerShell script uninstalls IrfanView from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls IrfanView +.DESCRIPTION + This PowerShell script uninstalls IrfanView from the local computer. +.EXAMPLE + PS> ./uninstall-irfanview +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling IrfanView, please wait..." + + & winget uninstall "IrfanView64" + if ($lastExitCode -ne "0") { throw "Can't uninstall IrfanView, is it installed?" } + + "IrfanView is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-irfanview.ps1* diff --git a/Docs/uninstall-microsoft-teams.md b/Docs/uninstall-microsoft-teams.md index 5ad7acd9..ad11208a 100644 --- a/Docs/uninstall-microsoft-teams.md +++ b/Docs/uninstall-microsoft-teams.md @@ -1,4 +1,4 @@ -## uninstall-microsoft-teams.ps1 - Uninstalls Microsoft Teams +## The uninstall-microsoft-teams.ps1 PowerShell Script This PowerShell script uninstalls Microsoft Teams from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Microsoft Teams +.DESCRIPTION + This PowerShell script uninstalls Microsoft Teams from the local computer. +.EXAMPLE + PS> ./uninstall-microsoft-teams +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Microsoft Teams, please wait..." + + & winget uninstall --id Microsoft.Teams + if ($lastExitCode -ne "0") { throw "Can't uninstall Microsoft Teams, is it installed?" } + + "Microsoft Teams is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-microsoft-teams.ps1* diff --git a/Docs/uninstall-netflix.md b/Docs/uninstall-netflix.md index 24c2404c..691e19bd 100644 --- a/Docs/uninstall-netflix.md +++ b/Docs/uninstall-netflix.md @@ -1,4 +1,4 @@ -## uninstall-netflix.ps1 - Uninstalls Netflix +## The uninstall-netflix.ps1 PowerShell Script This PowerShell script uninstalls Netflix from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Netflix +.DESCRIPTION + This PowerShell script uninstalls Netflix from the local computer. +.EXAMPLE + PS> ./uninstall-netflix +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Netflix, please wait..." + + & winget uninstall "Netflix" + if ($lastExitCode -ne "0") { throw "Can't uninstall Netflix, is it installed?" } + + "Netflix is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-netflix.ps1* diff --git a/Docs/uninstall-nine-zip.md b/Docs/uninstall-nine-zip.md index 3f0ca836..01175578 100644 --- a/Docs/uninstall-nine-zip.md +++ b/Docs/uninstall-nine-zip.md @@ -1,4 +1,4 @@ -## uninstall-nine-zip.ps1 - Uninstalls 9 ZIP +## The uninstall-nine-zip.ps1 PowerShell Script This PowerShell script uninstalls 9 ZIP from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/talk2windows +## Source Code +<# +.SYNOPSIS + Uninstalls 9 ZIP +.DESCRIPTION + This PowerShell script uninstalls 9 ZIP from the local computer. +.EXAMPLE + PS> ./uninstall-nine-zip +.LINK + https://github.com/fleschutz/talk2windows +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling 9 ZIP, please wait..." + + & winget uninstall "9 ZIP - open rar, zip, 7zip, gzip" + if ($lastExitCode -ne "0") { throw "Can't uninstall 9 ZIP, is it installed?" } + + "9 ZIP is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-nine-zip.ps1* diff --git a/Docs/uninstall-one-calendar.md b/Docs/uninstall-one-calendar.md index f77ad091..cbbf63b9 100644 --- a/Docs/uninstall-one-calendar.md +++ b/Docs/uninstall-one-calendar.md @@ -1,4 +1,6 @@ -## uninstall-one-calendar.ps1 - uninstall-one-calendar.ps1 +## The uninstall-one-calendar.ps1 PowerShell Script + +uninstall-one-calendar.ps1 ## Parameters @@ -10,4 +12,31 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +c<# +.SYNOPSIS + Uninstalls One Calendar +.DESCRIPTION + This PowerShell script uninstalls One Calendar from the local computer. +.EXAMPLE + PS> ./uninstall-one-calendar +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling One Calendar, please wait..." + + & winget uninstall "One Calendar" + if ($lastExitCode -ne "0") { throw "Can't uninstall One Calendar, is it installed?" } + + "One Calendar is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-one-calendar.ps1* diff --git a/Docs/uninstall-opera-browser.md b/Docs/uninstall-opera-browser.md index 9719d0e3..cc5989ab 100644 --- a/Docs/uninstall-opera-browser.md +++ b/Docs/uninstall-opera-browser.md @@ -1,4 +1,4 @@ -## uninstall-opera-browser.ps1 - Uninstalls Opera Browser +## The uninstall-opera-browser.ps1 PowerShell Script This PowerShell script uninstalls Opera Browser from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Opera Browser +.DESCRIPTION + This PowerShell script uninstalls Opera Browser from the local computer. +.EXAMPLE + PS> ./uninstall-opera-browser +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Opera Browser, please wait..." + + & winget uninstall "Opera Browser" + if ($lastExitCode -ne "0") { throw "Can't uninstall Opera Browser, is it installed?" } + + "Opera Browser is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-opera-browser.ps1* diff --git a/Docs/uninstall-opera-gx.md b/Docs/uninstall-opera-gx.md index 0c2097e7..6f061800 100644 --- a/Docs/uninstall-opera-gx.md +++ b/Docs/uninstall-opera-gx.md @@ -1,4 +1,4 @@ -## uninstall-opera-gx.ps1 - Uninstalls Opera GX +## The uninstall-opera-gx.ps1 PowerShell Script This PowerShell script uninstalls Opera GX from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Opera GX +.DESCRIPTION + This PowerShell script uninstalls Opera GX from the local computer. +.EXAMPLE + PS> ./uninstall-opera-gx +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Opera GX, please wait..." + + & winget uninstall "Opera GX" + if ($lastExitCode -ne "0") { throw "Can't uninstall Opera Browser, is it installed?" } + + "Opera GX is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-opera-gx.ps1* diff --git a/Docs/uninstall-paint-3d.md b/Docs/uninstall-paint-3d.md index 9796e2b5..edaf2c0e 100644 --- a/Docs/uninstall-paint-3d.md +++ b/Docs/uninstall-paint-3d.md @@ -1,4 +1,4 @@ -## uninstall-paint-3d.ps1 - Uninstalls Paint 3D +## The uninstall-paint-3d.ps1 PowerShell Script This PowerShell script uninstalls Paint 3D from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Paint 3D +.DESCRIPTION + This PowerShell script uninstalls Paint 3D from the local computer. +.EXAMPLE + PS> ./uninstall-paint-3d +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Paint 3D, please wait..." + + & winget uninstall "Paint 3D" + if ($lastExitCode -ne "0") { throw "Can't uninstall Paint 3D, is it installed?" } + + "Paint 3D is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-paint-3d.ps1* diff --git a/Docs/uninstall-rufus.md b/Docs/uninstall-rufus.md index 9f490e2a..5a05ff8f 100644 --- a/Docs/uninstall-rufus.md +++ b/Docs/uninstall-rufus.md @@ -1,4 +1,4 @@ -## uninstall-rufus.ps1 - Uninstalls Rufus +## The uninstall-rufus.ps1 PowerShell Script This PowerShell script uninstalls Rufus from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Rufus +.DESCRIPTION + This PowerShell script uninstalls Rufus from the local computer. +.EXAMPLE + PS> ./uninstall-rufus +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Rufus, please wait..." + + & winget uninstall "Rufus" + if ($lastExitCode -ne "0") { throw "Can't uninstall Rufus, is it installed?" } + + "Rufus is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-rufus.ps1* diff --git a/Docs/uninstall-skype.md b/Docs/uninstall-skype.md index bb426ec2..61eb92e6 100644 --- a/Docs/uninstall-skype.md +++ b/Docs/uninstall-skype.md @@ -1,4 +1,4 @@ -## uninstall-skype.ps1 - Uninstalls Skype +## The uninstall-skype.ps1 PowerShell Script This PowerShell script uninstalls Skype from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Skype +.DESCRIPTION + This PowerShell script uninstalls Skype from the local computer. +.EXAMPLE + PS> ./uninstall-skype +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Skype, please wait..." + + & winget uninstall "Skype" + if ($lastExitCode -ne "0") { throw "Can't uninstall Skype, is it installed?" } + + "Skype is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-skype.ps1* diff --git a/Docs/uninstall-spotify.md b/Docs/uninstall-spotify.md index 0ecabf43..190a4ed0 100644 --- a/Docs/uninstall-spotify.md +++ b/Docs/uninstall-spotify.md @@ -1,4 +1,4 @@ -## uninstall-spotify.ps1 - Uninstalls Spotify +## The uninstall-spotify.ps1 PowerShell Script This PowerShell script uninstalls Spotify from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Spotify +.DESCRIPTION + This PowerShell script uninstalls Spotify from the local computer. +.EXAMPLE + PS> ./uninstall-spotify +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Spotify, please wait..." + + & winget uninstall "Spotify - Music and Podcasts" + if ($lastExitCode -ne "0") { throw "Can't uninstall Spotify, is it installed?" } + + "Spotify is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-spotify.ps1* diff --git a/Docs/uninstall-twitter.md b/Docs/uninstall-twitter.md index b319673f..cea19ae2 100644 --- a/Docs/uninstall-twitter.md +++ b/Docs/uninstall-twitter.md @@ -1,4 +1,4 @@ -## uninstall-twitter.ps1 - Uninstalls Twitter +## The uninstall-twitter.ps1 PowerShell Script This PowerShell script uninstalls Twitter from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Twitter +.DESCRIPTION + This PowerShell script uninstalls Twitter from the local computer. +.EXAMPLE + PS> ./uninstall-twitter +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Twitter, please wait..." + + & winget uninstall "Twitter" + if ($lastExitCode -ne "0") { throw "Can't uninstall Twitter, is it installed?" } + + "Twitter is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-twitter.ps1* diff --git a/Docs/uninstall-visual-studio-code.md b/Docs/uninstall-visual-studio-code.md index 47d481b9..f54ab0e7 100644 --- a/Docs/uninstall-visual-studio-code.md +++ b/Docs/uninstall-visual-studio-code.md @@ -1,4 +1,4 @@ -## uninstall-visual-studio-code.ps1 - Uninstalls Visual Studio Code +## The uninstall-visual-studio-code.ps1 PowerShell Script This PowerShell script uninstalls Visual Studio Code from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Visual Studio Code +.DESCRIPTION + This PowerShell script uninstalls Visual Studio Code from the local computer. +.EXAMPLE + PS> ./uninstall-visual-studio-code +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Visual Studio Code, please wait..." + + & winget uninstall "Visual Studio Code" + if ($lastExitCode -ne "0") { throw "Can't uninstall Visual Studio Code, is it installed?" } + + "Visual Studio Code is uninstalled now." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-visual-studio-code.ps1* diff --git a/Docs/uninstall-vlc.md b/Docs/uninstall-vlc.md index 11e4adfe..c0b654aa 100644 --- a/Docs/uninstall-vlc.md +++ b/Docs/uninstall-vlc.md @@ -1,4 +1,4 @@ -## uninstall-vlc.ps1 - Uninstalls VLC +## The uninstall-vlc.ps1 PowerShell Script This PowerShell script uninstalls the VLC media player from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls VLC +.DESCRIPTION + This PowerShell script uninstalls the VLC media player from the local computer. +.EXAMPLE + PS> ./uninstall-vlc +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling VLC media player, please wait..." + + & winget uninstall "VLC" + if ($lastExitCode -ne "0") { throw "Can't uninstall VLC media player, is it installed?" } + + "VLC media player is uninstalled now." + exit 0 # success +} catch { + "Sorry: $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-vlc.ps1* diff --git a/Docs/uninstall-windows-terminal.md b/Docs/uninstall-windows-terminal.md index 60739ac9..9f8698e8 100644 --- a/Docs/uninstall-windows-terminal.md +++ b/Docs/uninstall-windows-terminal.md @@ -1,4 +1,4 @@ -## uninstall-windows-terminal.ps1 - Uninstalls Windows Terminal +## The uninstall-windows-terminal.ps1 PowerShell Script This PowerShell script uninstalls Windows Terminal from the local computer. @@ -23,4 +23,31 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uninstalls Windows Terminal +.DESCRIPTION + This PowerShell script uninstalls Windows Terminal from the local computer. +.EXAMPLE + PS> ./uninstall-windows-terminal +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "Uninstalling Windows Terminal, please wait..." + + & winget uninstall --id Microsoft.WindowsTerminal + if ($lastExitCode -ne "0") { throw "Can't uninstall Windows Terminal, is it installed?" } + + "Windows Terminal is uninstalled now." + exit 0 # success +} catch { + "Sorry: $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of uninstall-windows-terminal.ps1* diff --git a/Docs/upgrade-ubuntu.md b/Docs/upgrade-ubuntu.md index 414ac9df..c400cd4c 100644 --- a/Docs/upgrade-ubuntu.md +++ b/Docs/upgrade-ubuntu.md @@ -1,4 +1,4 @@ -## upgrade-ubuntu.ps1 - Upgrades Ubuntu Linux +## The upgrade-ubuntu.ps1 PowerShell Script This PowerShell script upgrades Ubuntu Linux to the latest (LTS) release. @@ -23,4 +23,60 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Upgrades Ubuntu Linux +.DESCRIPTION + This PowerShell script upgrades Ubuntu Linux to the latest (LTS) release. +.EXAMPLE + PS> .\upgrade-ubuntu.ps1 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + "" + "๐Ÿ‘‰ Step 1/4: Perform a backup" + "It's strongly recommended to backup your data BEFORE the upgrade!" + $Confirm = read-host "Press <Return> to continue..." + + "" + "๐Ÿ‘‰ Step 2/4: Install update-manager-core, Upgrade Packages & Reboot" + $Confirm = read-host "Enter <yes> to perform this step (otherwise it will be skipped)" + if ($Confirm -eq "yes") { + sudo apt install update-manager-core + sudo apt update + sudo apt list --upgradable + sudo apt upgrade + sudo reboot + } + + "" + "๐Ÿ‘‰ Step 3/4: Remove obsolete kernel modules" + $Confirm = read-host "Enter <yes> to perform this step (otherwise it will be skipped)" + if ($Confirm -eq "yes") { + sudo apt --purge autoremove + } + + "" + "๐Ÿ‘‰ Step 4/4: Upgrade Ubuntu & reboot" + $Confirm = read-host "Enter <LTS> to upgrade to latest LTS release, <latest> to upgrade to latest Ubuntu release (otherwise this step will be skipped)" + if ($Confirm -eq "LTS") { + sudo do-release-upgrade + sudo reboot + } elseif ($Confirm -eq "latest") { + sudo do-release-upgrade -d + sudo reboot + } + + "โœ”๏ธ Done." + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of upgrade-ubuntu.ps1* diff --git a/Docs/upload-file.md b/Docs/upload-file.md index 45e22729..6d06b019 100644 --- a/Docs/upload-file.md +++ b/Docs/upload-file.md @@ -1,4 +1,4 @@ -## upload-file.ps1 - Uploads a local file to a FTP server +## The upload-file.ps1 PowerShell Script This PowerShell script uploads a local file to a FTP server. @@ -59,4 +59,82 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uploads a local file to a FTP server +.DESCRIPTION + This PowerShell script uploads a local file to a FTP server. +.PARAMETER File + Specifies the path to the local file +.PARAMETER URL + Specifies the FTP server URL +.PARAMETER Username + Specifies the user name +.PARAMETER Password + Specifies the password +.EXAMPLE + PS> .\upload-file.ps1 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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: + $FullPath = Resolve-Path "$File" + if (-not(test-path "$FullPath" -pathType leaf)) { throw "Can't access file: $FullPath" } + $Filename = (Get-Item $FullPath).Name + $FileSize = (Get-Item $FullPath).Length + "โณ Uploading ๐Ÿ“„$Filename ($FileSize bytes) to $URL ..." + + # prepare request: + $Request = [Net.WebRequest]::Create("$URL/$Filename") + $Request.Credentials = New-Object System.Net.NetworkCredential("$Username", "$Password") + $Request.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile + $Request.EnableSSL = $EnableSSL + $Request.UseBinary = $UseBinary + $Request.UsePassive = $UsePassive + $Request.KeepAlive = $KeepAlive + [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$IgnoreCert} + + $fileStream = [System.IO.File]::OpenRead("$FullPath") + $ftpStream = $Request.GetRequestStream() + + $Buf = New-Object Byte[] 32KB + while (($DataRead = $fileStream.Read($Buf, 0, $Buf.Length)) -gt 0) + { + $ftpStream.Write($Buf, 0, $DataRead) + $pct = ($fileStream.Position / $fileStream.Length) + Write-Progress -Activity "Uploading" -Status ("{0:P0} complete:" -f $pct) -PercentComplete ($pct * 100) + } + + # cleanup: + $ftpStream.Dispose() + $fileStream.Dispose() + + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โœ”๏ธ uploaded ๐Ÿ“„$Filename to $URL in $Elapsed sec" + exit 0 # success +} catch { + [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0]) after $Elapsed sec." + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of upload-file.ps1* diff --git a/Docs/upload-to-dropbox.md b/Docs/upload-to-dropbox.md index 72a8e87c..a0b1e045 100644 --- a/Docs/upload-to-dropbox.md +++ b/Docs/upload-to-dropbox.md @@ -1,4 +1,4 @@ -## upload-to-dropbox.ps1 - Uploads a file to Dropbox +## The upload-to-dropbox.ps1 PowerShell Script This PowerShell script uploads a local file to Dropbox. @@ -31,4 +31,39 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Uploads a file to Dropbox +.DESCRIPTION + This PowerShell script uploads a local file to Dropbox. +.PARAMETER Path + Specifies the path to the local file +.EXAMPLE + PS> .\upload-to-dropbox.ps1 my.txt +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([Parameter (Mandatory = $True, ValueFromPipeline = $True)] [Alias("f")] [string]$SourceFilePath) + +try { + $DropBoxAccessToken = "YOUR-DROPBOX-ACCESS-TOKEN-HERE" # Replace with your DropBox Access Token + $outputFile = Split-Path $SourceFilePath -leaf + $TargetFilePath="/$outputFile" + $arg = '{ "path": "' + $TargetFilePath + '", "mode": "add", "autorename": true, "mute": false }' + $authorization = "Bearer " + $DropBoxAccessToken + $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" + $headers.Add("Authorization", $authorization) + $headers.Add("Dropbox-API-Arg", $arg) + $headers.Add("Content-Type", 'application/octet-stream') + Invoke-RestMethod -Uri https://content.dropboxapi.com/2/files/upload -Method Post -InFile $SourceFilePath -Headers $headers + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0]) after $Elapsed sec." + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of upload-to-dropbox.ps1* diff --git a/Docs/wakeup.md b/Docs/wakeup.md index e659689a..d16e2ed1 100644 --- a/Docs/wakeup.md +++ b/Docs/wakeup.md @@ -1,4 +1,4 @@ -## wakeup.ps1 - Sends a magic packet to a computer to wake him up +## The wakeup.ps1 PowerShell Script This PowerShell script sends a magic UDP packet twice to a computer to wake him up (requires Wake-On-LAN). @@ -50,4 +50,53 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Sends a magic packet to a computer to wake him up +.DESCRIPTION + This PowerShell script sends a magic UDP packet twice to a computer to wake him up (requires Wake-On-LAN). +.PARAMETER MACaddress + Specifies the host's MAC address (e.g. 11:22:33:44:55:66) +.PARAMETER IPaddress + Specifies the host's IP address or subnet address (e.g. 255.255.255.255) +.PARAMETER Port + Specifies the UDP port (9 by default) +.EXAMPLE + PS> ./wakeup 11:22:33:44:55:66 192.168.100.100 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$MACaddress = "", [string]$IPaddress = "", [int]$Port=9) + +function Send-WOL { param([string]$mac, [string]$ip, [int]$port) + $broadcast = [Net.IPAddress]::Parse($ip) + + $mac=(($mac.replace(":","")).replace("-","")).replace(".","") + $target=0,2,4,6,8,10 | % {[convert]::ToByte($mac.substring($_,2),16)} + $packet = (,[byte]255 * 6) + ($target * 16) + + $UDPclient = new-Object System.Net.Sockets.UdpClient + $UDPclient.Connect($broadcast,$port) + [void]$UDPclient.Send($packet, 102) +} + +try { + if ($MACaddress -eq "" ) { $MACaddress = read-host "Enter the host's MAC address (e.g. 00:11:22:33:44:55)" } + if ($IPaddress -eq "" ) { $IPaddress = read-host "Enter the host's 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 + + "โœ”๏ธ sent magic packet $MACaddress to IP $IPaddress port $Port (twice)" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of wakeup.ps1* diff --git a/Docs/weather-report.md b/Docs/weather-report.md index df7d2ba1..44472634 100644 --- a/Docs/weather-report.md +++ b/Docs/weather-report.md @@ -1,4 +1,4 @@ -## weather-report.ps1 - Lists the local weather report +## The weather-report.ps1 PowerShell Script This PowerShell script lists the local weather report. @@ -32,4 +32,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the local weather report +.DESCRIPTION + This PowerShell script lists the local weather report. +.PARAMETER GeoLocation + Specifies the geographic location to use (determine automatically by default) +.EXAMPLE + PS> ./weather-report Paris +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$GeoLocation = "") # empty means determine automatically + +try { + (Invoke-WebRequest http://v2d.wttr.in/$GeoLocation -userAgent "curl" -useBasicParsing).Content + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of weather-report.ps1* diff --git a/Docs/weather.md b/Docs/weather.md index a56a10fc..6b28fff6 100644 --- a/Docs/weather.md +++ b/Docs/weather.md @@ -1,4 +1,4 @@ -## weather.ps1 - Lists the current weather forecast +## The weather.ps1 PowerShell Script This PowerShell script lists the current weather forecast. @@ -32,4 +32,30 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Lists the current weather forecast +.DESCRIPTION + This PowerShell script lists the current weather forecast. +.PARAMETER GeoLocation + Specifies the geographic location to use +.EXAMPLE + PS> ./weather Paris +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$GeoLocation = "") # empty means determine automatically + +try { + (Invoke-WebRequest http://wttr.in/$GeoLocation -userAgent "curl" -useBasicParsing).Content + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of weather.ps1* diff --git a/Docs/what-is.md b/Docs/what-is.md index 12444d56..266d25c7 100644 --- a/Docs/what-is.md +++ b/Docs/what-is.md @@ -1,4 +1,4 @@ -## what-is.ps1 - Prints a description of an abbreviation +## The what-is.ps1 PowerShell Script This PowerShell script prints a description of the given abbreviation. @@ -32,4 +32,50 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Prints a description of an abbreviation +.DESCRIPTION + This PowerShell script prints a description of the given abbreviation. +.PARAMETER abbreviation + Specifies the appreviation to look for +.EXAMPLE + PS> ./what-is IAS +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$abbreviation = "") + +function Reply { param([string]$Text) + & "$PSScriptRoot/give-reply.ps1" "$Text" +} + +try { + if ($abbreviation -eq "" ) { $abbreviation = read-host "Enter the abbreviation" } + + $FoundOne = $false + $Files = (get-childItem "$PSScriptRoot/../Data/Abbr/*.csv") + + foreach ($File in $Files) { + $Table = import-csv "$File" + foreach($Row in $Table) { + if ($Row.Abbr -eq $abbreviation) { + $Basename = (get-item "$File").Basename + Reply "In $Basename $($Row.Abbr) may refer to $($Row.Term)" + $FoundOne = $true + } + } + } + + if ($FoundOne -eq $false) { Reply "Sorry, no database entry found." } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of what-is.ps1* diff --git a/Docs/write-animated.md b/Docs/write-animated.md index e31a9b32..14cd0ac6 100644 --- a/Docs/write-animated.md +++ b/Docs/write-animated.md @@ -1,4 +1,4 @@ -## write-animated.ps1 - Writes animated text +## The write-animated.ps1 PowerShell Script This PowerShell script writes animated text. @@ -103,4 +103,59 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes animated text +.DESCRIPTION + This PowerShell script writes animated text. +.EXAMPLE + PS> ./write-animated "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param($Line1 = "", $Line2 = "", $Line3 = "", $Line4 = "", $Line5 = "", $Line6 = "", $Line7 = "", $Line8 = "", $Line9 = "", [int]$Speed = 30) # 30 ms pause + +$TerminalWidth = 120 # characters + +function WriteLine { param([string]$Line, [int]$Speed) + [int]$Start = 1 + [int]$End = $Line.Length + $StartPosition = $HOST.UI.RawUI.CursorPosition + $Spaces = " " + + if ($Line -eq "") { return } + foreach ($Pos in $Start .. $End) { + $TextToDisplay = $Spaces.Substring(0, $TerminalWidth / 2 - $pos / 2) + $Line.Substring(0, $Pos) + write-host -nonewline $TextToDisplay + start-sleep -milliseconds $Speed + $HOST.UI.RawUI.CursorPosition = $StartPosition + } + write-host "" +} + +if ($Line1 -eq "") { + $Line1 = "Welcome to PowerShell Scripts" + $Line2 = " " + $Line3 = "This repository contains useful and cross-platform PowerShell scripts." + $Line4 = " " + $Line5 = "Best regards," + $Line6 = "Markus" +} +write-host "" +WriteLine $Line1 $Speed +WriteLine $Line2 $Speed +WriteLine $Line3 $Speed +WriteLine $Line4 $Speed +WriteLine $Line5 $Speed +WriteLine $Line6 $Speed +WriteLine $Line7 $Speed +WriteLine $Line8 $Speed +WriteLine $Line9 $Speed +write-host "" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of write-animated.ps1* diff --git a/Docs/write-big.md b/Docs/write-big.md index 6df823e6..d65b9b08 100644 --- a/Docs/write-big.md +++ b/Docs/write-big.md @@ -1,4 +1,4 @@ -## write-big.ps1 - Writes text in big letters +## The write-big.ps1 PowerShell Script This PowerShell script writes the given text in big letters. @@ -32,4 +32,429 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes text in big letters +.DESCRIPTION + This PowerShell script writes the given text in big letters. +.PARAMETER text + Specifies the text to write +.EXAMPLE + PS> ./write-big "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +Set-StrictMode -Version Latest + +function BigA { param([int]$Row) + switch($Row) { + 1 { return " __ " } + 2 { return " /__\ " } + 3 { return " /(__)\ " } + 4 { return "(__/\__)" } + } +} + +function BigB { param([int]$Row) + switch($Row) { + 1 { return " ____ " } + 2 { return "| _ )" } + 3 { return "| _ ( " } + 4 { return "|____)" } + } +} + +function BigC { param([int]$Row) + switch($Row) { + 1 { return " ___ " } + 2 { return " / __)" } + 3 { return "( (__ " } + 4 { return " \___)" } + } +} + +function BigD { param([int]$Row) + switch($Row) { + 1 { return " ____ " } + 2 { return "| _ \ " } + 3 { return "| (_) )" } + 4 { return "|____/ " } + } +} + +function BigE { param([int]$Row) + switch($Row) { + 1 { return " ____ " } + 2 { return "| ___)" } + 3 { return "| __) " } + 4 { return "|____)" } + } +} + +function BigF { param([int]$Row) + switch($Row) { + 1 { return " ____ " } + 2 { return "| ___)" } + 3 { return "| __) " } + 4 { return "|_) " } + } +} + +function BigG { param([int]$Row) + switch($Row) { + 1 { return " ____ " } + 2 { return " / ___)" } + 3 { return "( (__-." } + 4 { return " \____|" } + } +} + +function BigH { param([int]$Row) + switch($Row) { + 1 { return " _ _ " } + 2 { return "| |_| |" } + 3 { return "| _ |" } + 4 { return "|_| |_|" } + } +} + +function BigI { param([int]$Row) + switch($Row) { + 1 { return " _ " } + 2 { return "| |" } + 3 { return "| |" } + 4 { return "|_|" } + } +} + +function BigJ { param([int]$Row) + switch($Row) { + 1 { return " __ " } + 2 { return " ( |" } + 3 { return ".-_) |" } + 4 { return "\____|" } + } +} + +function BigK { param([int]$Row) + switch($Row) { + 1 { return " _ _ " } + 2 { return "| |/ )" } + 3 { return "| ( " } + 4 { return "|_|\_)" } + } +} + +function BigL { param([int]$Row) + switch($Row) { + 1 { return " _ " } + 2 { return "| | " } + 3 { return "| |__ " } + 4 { return "|____)" } + } +} + +function BigM { param([int]$Row) + switch($Row) { + 1 { return " _ _ " } + 2 { return "| \ / |" } + 3 { return "| \/ |" } + 4 { return "|_| |_|" } + } +} + +function BigN { param([int]$Row) + switch($Row) { + 1 { return " _ _ " } + 2 { return "| \ | |" } + 3 { return "| \| |" } + 4 { return "|_| \_|" } + } +} + +function BigO { param([int]$Row) + switch($Row) { + 1 { return " ___ " } + 2 { return " / _ \ " } + 3 { return "( (_) )" } + 4 { return " \___/ " } + } +} + +function BigP { param([int]$Row) + switch($Row) { + 1 { return " ____ " } + 2 { return "| _ \" } + 3 { return "| __/" } + 4 { return "|_| " } + } +} + +function BigQ { param([int]$Row) + switch($Row) { + 1 { return " ____ " } + 2 { return " / _ \ " } + 3 { return "( (_) ( " } + 4 { return " \___/\\" } + } +} + +function BigR { param([int]$Row) + switch($Row) { + 1 { return " ____ " } + 2 { return "| _ \" } + 3 { return "| /" } + 4 { return "|_|\_)" } + } +} + +function BigS { param([int]$Row) + switch($Row) { + 1 { return " ____ " } + 2 { return "/ __)" } + 3 { return "\__ \" } + 4 { return "(____/" } + } +} + +function BigT { param([int]$Row) + switch($Row) { + 1 { return " _____ " } + 2 { return "|_ _|" } + 3 { return " | | " } + 4 { return " |_| " } + } +} + +function BigU { param([int]$Row) + switch($Row) { + 1 { return " _ _ " } + 2 { return "| | | |" } + 3 { return "| |_| |" } + 4 { return "|_____|" } + } +} + +function BigV { param([int]$Row) + switch($Row) { + 1 { return " _ _ " } + 2 { return "( \/ )" } + 3 { return " \ / " } + 4 { return " \/ " } + } +} + +function BigW { param([int]$Row) + switch($Row) { + 1 { return " __ __ " } + 2 { return "\ \/\/ /" } + 3 { return " \ / " } + 4 { return " \_/\_/ " } + } +} + +function BigX { param([int]$Row) + switch($Row) { + 1 { return " _ _ " } + 2 { return "( \/ )" } + 3 { return " ) ( " } + 4 { return "(_/\_)" } + } +} + +function BigY { param([int]$Row) + switch($Row) { + 1 { return " _ _ " } + 2 { return "( \/ )" } + 3 { return " \ / " } + 4 { return " (__) " } + } +} + +function BigZ { param([int]$Row) + switch($Row) { + 1 { return " ____ " } + 2 { return "(_ )" } + 3 { return " / /_ " } + 4 { return "(____)" } + } +} + +function Big0 { param([int]$Row) + switch($Row) { + 1 { return " ___ " } + 2 { return " / _ \ " } + 3 { return "( (_) )" } + 4 { return " \___/ " } + } +} + +function Big1 { param([int]$Row) + switch($Row) { + 1 { return " ___ " } + 2 { return "/_ |" } + 3 { return " | |" } + 4 { return " |_|" } + } +} + +function Big2 { param([int]$Row) + switch($Row) { + 1 { return " ___ " } + 2 { return "(__ \ " } + 3 { return " / _/ " } + 4 { return "(____)" } + } +} + +function Big3 { param([int]$Row) + switch($Row) { + 1 { return " ___ " } + 2 { return "(__ )" } + 3 { return " (_ \" } + 4 { return "(___/" } + } +} + +function Big4 { param([int]$Row) + switch($Row) { + 1 { return " __ " } + 2 { return " /. | " } + 3 { return "(_ _)" } + 4 { return " |_| " } + } +} + +function Big5 { param([int]$Row) + switch($Row) { + 1 { return " ____ " } + 2 { return "| ___)" } + 3 { return "|__ \ " } + 4 { return "(___/ " } + } +} + +function Big6 { param([int]$Row) + switch($Row) { + 1 { return " _ " } + 2 { return " / ) " } + 3 { return "/ _ \" } + 4 { return "\___/" } + } +} + +function Big7 { param([int]$Row) + switch($Row) { + 1 { return " ___ " } + 2 { return "(__ )" } + 3 { return " / / " } + 4 { return "(_/ " } + } +} + +function Big8 { param([int]$Row) + switch($Row) { + 1 { return " ___ " } + 2 { return "( _ )" } + 3 { return "/ _ \" } + 4 { return "\___/" } + } +} + +function Big9 { param([int]$Row) + switch($Row) { + 1 { return " ___ " } + 2 { return "/ _ \" } + 3 { return "\_ /" } + 4 { return " (_/ " } + } +} + +function BigColon { param([int]$Row) + switch($Row) { + 1 { return " " } + 2 { return " o " } + 3 { return " o " } + 4 { return " " } + } +} + +function BigMinus { param([int]$Row) + switch($Row) { + 1 { return " " } + 2 { return " ____ " } + 3 { return "(____)" } + 4 { return " " } + } +} + +function BigChar { param([string]$Char, [int]$Row) + switch($Char) { + 'A' { return BigA $Row } + 'B' { return BigB $Row } + 'C' { return BigC $Row } + 'D' { return BigD $Row } + 'E' { return BigE $Row } + 'F' { return BigF $Row } + 'G' { return BigG $Row } + 'H' { return BigH $Row } + 'I' { return BigI $Row } + 'J' { return BigJ $Row } + 'K' { return BigK $Row } + 'L' { return BigL $Row } + 'M' { return BigM $Row } + 'N' { return BigN $Row } + 'O' { return BigO $Row } + 'P' { return BigP $Row } + 'Q' { return BigQ $Row } + 'R' { return BigR $Row } + 'S' { return BigS $Row } + 'T' { return BigT $Row } + 'U' { return BigU $Row } + 'V' { return BigV $Row } + 'W' { return BigW $Row } + 'X' { return BigX $Row } + 'Y' { return BigY $Row } + 'Z' { return BigZ $Row } + '0' { return Big0 $Row } + '1' { return Big1 $Row } + '2' { return Big2 $Row } + '3' { return Big3 $Row } + '4' { return Big4 $Row } + '5' { return Big5 $Row } + '6' { return Big6 $Row } + '7' { return Big7 $Row } + '8' { return Big8 $Row } + '9' { return Big9 $Row } + ':' { return BigColon $Row } + '-' { return BigMinus $Row } + } + return " " +} + +try { + if ($text -eq "" ) { [String]$text = read-host "Enter text to write" } + + [char[]]$ArrayOfChars = $text.ToUpper() + write-output "" + for ($Row = 1; $Row -lt 5; $Row++) { + $Line = "" + foreach($Char in $ArrayOfChars) { + $Line += BigChar $Char $Row + } + write-output $Line + } + write-output "" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of write-big.ps1* diff --git a/Docs/write-blue.md b/Docs/write-blue.md index 53774872..2a232829 100644 --- a/Docs/write-blue.md +++ b/Docs/write-blue.md @@ -1,4 +1,4 @@ -## write-blue.ps1 - Writes text in a blue foreground color +## The write-blue.ps1 PowerShell Script This PowerShell script writes text in a blue foreground color. @@ -32,4 +32,28 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes text in a blue foreground color +.DESCRIPTION + This PowerShell script writes text in a blue foreground color. +.PARAMETER text + Specifies the text to write +.EXAMPLE + PS> ./write-blue "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +if ($text -eq "" ) { $text = read-host "Enter the text to write" } + +write-host -foregroundColor blue "$text" + +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of write-blue.ps1* diff --git a/Docs/write-braille.md b/Docs/write-braille.md index 59138932..5644ee85 100644 --- a/Docs/write-braille.md +++ b/Docs/write-braille.md @@ -1,4 +1,4 @@ -## write-braille.ps1 - Writes text in Braille +## The write-braille.ps1 PowerShell Script This PowerShell script writes text in Braille. @@ -32,4 +32,372 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes text in Braille +.DESCRIPTION + This PowerShell script writes text in Braille. +.PARAMETER text + Specifies the text to write +.EXAMPLE + PS> ./write-braille "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +function BrailleA { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return "oo" } + 3 { return "oo" } + } +} + +function BrailleB { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return ".o" } + 3 { return "oo" } + } +} + +function BrailleC { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return "oo" } + 3 { return "oo" } + } +} + +function BrailleD { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return "o." } + 3 { return "oo" } + } +} + +function BrailleE { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return "o." } + 3 { return "oo" } + } +} + +function BrailleF { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return ".o" } + 3 { return "oo" } + } +} + +function BrailleG { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return ".." } + 3 { return "oo" } + } +} + +function BrailleH { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return ".." } + 3 { return "oo" } + } +} + +function BrailleI { param([int]$Row) + switch($Row) { + 1 { return "o." } + 2 { return ".o" } + 3 { return "oo" } + } +} + +function BrailleJ { param([int]$Row) + switch($Row) { + 1 { return "o." } + 2 { return ".." } + 3 { return "oo" } + } +} + +function BrailleK { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return "oo" } + 3 { return ".o" } + } +} + +function BrailleL { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return ".o" } + 3 { return ".o" } + } +} + +function BrailleM { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return "oo" } + 3 { return ".o" } + } +} + +function BrailleN { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return "o." } + 3 { return ".o" } + } +} + +function BrailleO { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return "o." } + 3 { return ".o" } + } +} + +function BrailleP { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return ".o" } + 3 { return ".o" } + } +} + +function BrailleQ { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return ".." } + 3 { return ".o" } + } +} + +function BrailleR { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return ".." } + 3 { return ".o" } + } +} + +function BrailleS { param([int]$Row) + switch($Row) { + 1 { return "o." } + 2 { return ".o" } + 3 { return ".o" } + } +} + +function BrailleT { param([int]$Row) + switch($Row) { + 1 { return "o." } + 2 { return ".." } + 3 { return ".o" } + } +} + +function BrailleU { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return "oo" } + 3 { return ".." } + } +} + +function BrailleV { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return ".o" } + 3 { return ".." } + } +} + +function BrailleW { param([int]$Row) + switch($Row) { + 1 { return "o." } + 2 { return ".." } + 3 { return "o." } + } +} + +function BrailleX { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return "oo" } + 3 { return ".." } + } +} + +function BrailleY { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return "o." } + 3 { return ".." } + } +} + +function BrailleZ { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return "o." } + 3 { return ".." } + } +} + +function Braille1 { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return "oo" } + 3 { return "oo" } + } +} + +function Braille2 { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return ".o" } + 3 { return "oo" } + } +} + +function Braille3 { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return "oo" } + 3 { return "oo" } + } +} + +function Braille4 { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return "o." } + 3 { return "oo" } + } +} + +function Braille5 { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return "o." } + 3 { return "oo" } + } +} + +function Braille6 { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return ".o" } + 3 { return "oo" } + } +} + +function Braille7 { param([int]$Row) + switch($Row) { + 1 { return ".." } + 2 { return ".." } + 3 { return "oo" } + } +} + +function Braille8 { param([int]$Row) + switch($Row) { + 1 { return ".o" } + 2 { return ".." } + 3 { return "oo" } + } +} + +function Braille9 { param([int]$Row) + switch($Row) { + 1 { return "o." } + 2 { return ".o" } + 3 { return "oo" } + } +} + +function Braille0 { param([int]$Row) + switch($Row) { + 1 { return "o." } + 2 { return ".." } + 3 { return "oo" } + } +} + +function BrailleChar { param([string]$Char, [int]$Row) + switch($Char) { + 'A' { return BrailleA $Row } + 'B' { return BrailleB $Row } + 'C' { return BrailleC $Row } + 'D' { return BrailleD $Row } + 'E' { return BrailleE $Row } + 'F' { return BrailleF $Row } + 'G' { return BrailleG $Row } + 'H' { return BrailleH $Row } + 'I' { return BrailleI $Row } + 'J' { return BrailleJ $Row } + 'K' { return BrailleK $Row } + 'L' { return BrailleL $Row } + 'M' { return BrailleM $Row } + 'N' { return BrailleN $Row } + 'O' { return BrailleO $Row } + 'P' { return BrailleP $Row } + 'Q' { return BrailleQ $Row } + 'R' { return BrailleR $Row } + 'S' { return BrailleS $Row } + 'T' { return BrailleT $Row } + 'U' { return BrailleU $Row } + 'V' { return BrailleV $Row } + 'W' { return BrailleW $Row } + 'X' { return BrailleX $Row } + 'Y' { return BrailleY $Row } + 'Z' { return BrailleZ $Row } + '1' { return Braille1 $Row } + '2' { return Braille2 $Row } + '3' { return Braille3 $Row } + '4' { return Braille4 $Row } + '5' { return Braille5 $Row } + '6' { return Braille6 $Row } + '7' { return Braille7 $Row } + '8' { return Braille8 $Row } + '9' { return Braille9 $Row } + '0' { return Braille0 $Row } + } + return " " +} + +try { + if ($text -eq "" ) { $text = read-host "Enter text to write" } + + [char[]]$ArrayOfChars = $text.ToUpper() + write-output "" + for ($Row = 1; $Row -lt 4; $Row++) { + $Line = "" + foreach($Char in $ArrayOfChars) { + $Line += BrailleChar $Char $Row + $Line += " " + } + write-output $Line + } + write-output "" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of write-braille.ps1* diff --git a/Docs/write-chart.md b/Docs/write-chart.md index c6c67365..1997d2b5 100644 --- a/Docs/write-chart.md +++ b/Docs/write-chart.md @@ -1,4 +1,6 @@ -## write-chart.ps1 - write-chart.ps1 +## The write-chart.ps1 PowerShell Script + +write-chart.ps1 ## Parameters @@ -10,4 +12,51 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Writes a chart +.DESCRIPTION + This PowerShell script writes a chart. +.EXAMPLE + PS> ./write-chart +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function WriteChartLine { param([string]$Text, [float]$Value, [float]$Max) + $Num = ($Value * 40.0) / $Max + while ($Num -ge 1.0) { + write-host -noNewLine "โ–ˆ" + $Num -= 1.0 + } + if ($Num -ge 0.875) { + write-host -noNewLine "โ–‰" + } elseif ($Num -ge 0.75) { + write-host -noNewLine "โ–Š" + } elseif ($Num -ge 0.625) { + write-host -noNewLine "โ–‹" + } elseif ($Num -ge 0.5) { + write-host -noNewLine "โ–Œ" + } elseif ($Num -ge 0.375) { + write-host -noNewLine "โ–" + } elseif ($Num -ge 0.25) { + write-host -noNewLine "โ–Ž" + } elseif ($Num -ge 0.125) { + write-host -noNewLine "โ–" + } + if ($Max -eq 100.0) { + write-host " $($Value)% $Text" + } else { + write-host " $Value / $Max $Text" + } +} + +"2021 Wins" +WriteChartLine "Markus" 40.5 100.0 +WriteChartLine "Andrea" 30.9 100.0 +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of write-chart.ps1* diff --git a/Docs/write-code.md b/Docs/write-code.md index 3f5cf0d2..ad825065 100644 --- a/Docs/write-code.md +++ b/Docs/write-code.md @@ -1,4 +1,4 @@ -## write-code.ps1 - Writes code +## The write-code.ps1 PowerShell Script This PowerShell script generates and writes PowerShell code on the console (for fun). @@ -41,4 +41,67 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes code +.DESCRIPTION + This PowerShell script generates and writes PowerShell code on the console (for fun). +.PARAMETER color + Specifies the color to use ("green" by default) +.PARAMETER speed + Specifies the speed in milliseconds per code line (500 by default) +.EXAMPLE + PS> ./write-code +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$color = "green", [int]$speed = 500) # milliseconds + +function GetRandomCodeLine { + $Generator = New-Object System.Random + $Num = [int]$Generator.next(0, 24) + switch($Num) { + 0 { return " `$count = 0" } + 1 { return " `$count++" } + 2 { return " exit 0 # success" } + 3 { return " `$Files = Get-ChildItem C:" } + 4 { return " Start-Sleep 1" } + 5 { return " `$Generator = New-Object System-Random" } + 6 { return "} else {" } + 7 { return "} catch {" } + 8 { return "} elseif (`$count -eq 0) {" } + 9 { return " Write-Host `"Hello World`" " } + 10 { return " while (`$true) {" } + 11 { return "# next part:" } + 12 { return " exit 1 # failed" } + 13 { return " return 1" } + 14 { return " return 0" } + 15 { return " Write-Progress `"Working...`" " } + 16 { return " [bool]`$KeepAlive = `$true" } + 17 { return "# Copyright ยฉ 2022 write-code.ps1. All Rights Reserved." } + 18 { return " for ([int]`$i = 0; `$i -lt 100; `$i++) {" } + 19 { return " `$StopWatch = [system.diagnostics.stopwatch]::startNew()" } + 20 { return " [int]`$Elapsed = `$StopWatch.Elapsed.TotalSeconds" } + 21 { return " if (`$count -eq 0) { `$count = Read-Host `"Enter number of iterations`" " } + 22 { return " } finally {" } + 23 { return " throw `"Can't open file`" " } + } +} + +try { + Write-Host -foreground $color "try {" + while ($true) { + Write-Host -foreground $color "$(GetRandomCodeLine)" + Start-Sleep -milliseconds $speed + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of write-code.ps1* diff --git a/Docs/write-date.md b/Docs/write-date.md index 83f79b61..53388232 100644 --- a/Docs/write-date.md +++ b/Docs/write-date.md @@ -1,4 +1,4 @@ -## write-date.ps1 - Writes the current date +## The write-date.ps1 PowerShell Script This PowerShell script determines and writes the current date. @@ -24,4 +24,29 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes the current date +.DESCRIPTION + This PowerShell script determines and writes the current date. +.EXAMPLE + PS> ./write-date + Sunday, October 17, 2021 +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + [system.threading.thread]::currentthread.currentculture = [system.globalization.cultureinfo]"en-US" + $CurrentDate = (Get-Date).ToShortDateString() + "๐Ÿ“…$CurrentDate" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of write-date.ps1* diff --git a/Docs/write-fractal.md b/Docs/write-fractal.md index 989ef603..9dda87e6 100644 --- a/Docs/write-fractal.md +++ b/Docs/write-fractal.md @@ -1,4 +1,6 @@ -## write-fractal.ps1 - write-fractal.ps1 +## The write-fractal.ps1 PowerShell Script + +write-fractal.ps1 ## Parameters @@ -10,4 +12,66 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Writes a fractal +.DESCRIPTION + This PowerShell script writes an animated Mandelbrot fractal. +.EXAMPLE + PS> ./write-fractal +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function CalculateFractal([float]$left, [float]$top, [float]$xside, [float]$yside, [float]$zoom) { + [int]$maxx = $rui.MaxWindowSize.Width + [int]$maxy = $rui.MaxWindowSize.Height + [float]$xscale = $xside / $maxx + [float]$yscale = $yside / $maxy + for ([int]$y = 0; $y -lt $maxy; $y++) { + for ([int]$x = 0; $x -lt $maxx; $x++) { + [float]$cx = $x * $xscale + $left + [float]$cy = $y * $yscale + $top + [float]$zx = 0 + [float]$zy = 0 + for ([int]$count = 0; ($zx * $zx + $zy * $zy -lt 4) -and ($count -lt $MAXCOUNT); $count++) { + [float]$tempx = $zx * $zx - $zy * $zy + $cx + $zy = $zoom * $zx * $zy + $cy + $zx = $tempx + } + $global:buf[$y * $maxx + $x] = $([char](65 + $count)) + } + } +} + +$MAXCOUNT = 30 +$ui = (Get-Host).ui +$rui = $ui.rawui +[float]$left = -1.75 +[float]$top = -0.25 +[float]$xside = 0.25 +[float]$yside = 0.45 +$buffer0 = "" +1..($rui.MaxWindowSize.Width * $rui.MaxWindowSize.Height) | ForEach-Object { $buffer0 += " " } +$global:buf = $buffer0.ToCharArray() + +while ($true) { + for ([float]$zoom = 4.0; $zoom -gt 1.1; $zoom -= 0.02) { + CalculateFractal $left $top $xside $yside $zoom + [console]::SetCursorPosition(0,0) + [string]$Screen = New-Object system.string($global:buf, 0, $global:buf.Length) + Write-Host -foreground green $Screen -noNewline + } + for ([float]$zoom = 1.1; $zoom -lt 4.0; $zoom += 0.02) { + CalculateFractal $left $top $xside $yside $zoom + [console]::SetCursorPosition(0,0) + [string]$Screen = New-Object system.string($global:buf, 0, $global:buf.Length) + Write-Host -foreground green $Screen -noNewline + } +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of write-fractal.ps1* diff --git a/Docs/write-green.md b/Docs/write-green.md index ad64f890..d503b128 100644 --- a/Docs/write-green.md +++ b/Docs/write-green.md @@ -1,4 +1,4 @@ -## write-green.ps1 - Writes text in a green foreground color +## The write-green.ps1 PowerShell Script This PowerShell script writes text in a green foreground color. @@ -32,4 +32,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes text in a green foreground color +.DESCRIPTION + This PowerShell script writes text in a green foreground color. +.PARAMETER text + Specifies the text to write +.EXAMPLE + PS> ./write-green "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +if ($text -eq "" ) { $text = read-host "Enter the text to write" } + +write-host -foregroundColor green "$text" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of write-green.ps1* diff --git a/Docs/write-joke.md b/Docs/write-joke.md index 5390dce8..7fb78f6b 100644 --- a/Docs/write-joke.md +++ b/Docs/write-joke.md @@ -1,4 +1,4 @@ -## write-joke.ps1 - Writes a random Juck Norris joke to the console +## The write-joke.ps1 PowerShell Script This PowerShell script writes a random Juck Norris joke to the console. @@ -24,4 +24,33 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes a random Juck Norris joke to the console +.DESCRIPTION + This PowerShell script writes a random Juck Norris joke to the console. +.EXAMPLE + PS> ./write-joke + When Chuck Norris does division, there are no remainders. ๐Ÿ˜‚ +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Table = import-csv "$PSScriptRoot/../Data/jokes.csv" + + $Generator = New-Object System.Random + $Index = [int]$Generator.next(0, $Table.Count - 1) + $Joke = $Table[$Index].Joke + + "$Joke ๐Ÿ˜‚" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of write-joke.ps1* diff --git a/Docs/write-lowercase.md b/Docs/write-lowercase.md index 4be4f3c1..b065c88a 100644 --- a/Docs/write-lowercase.md +++ b/Docs/write-lowercase.md @@ -1,4 +1,4 @@ -## write-lowercase.ps1 - Writes text in lowercase letters +## The write-lowercase.ps1 PowerShell Script This PowerShell script writes text in lowercase letters. @@ -32,4 +32,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes text in lowercase letters +.DESCRIPTION + This PowerShell script writes text in lowercase letters. +.PARAMETER text + Specifies the text to write +.EXAMPLE + PS> ./write-lowercase "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +if ($text -eq "" ) { $text = read-host "Enter the text to write" } + +write-output $text.ToLower() +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of write-lowercase.ps1* diff --git a/Docs/write-marquee.md b/Docs/write-marquee.md index acb0836a..2f7beeb1 100644 --- a/Docs/write-marquee.md +++ b/Docs/write-marquee.md @@ -1,4 +1,4 @@ -## write-marquee.ps1 - Writes text as marquee +## The write-marquee.ps1 PowerShell Script This PowerShell script writes the given text as marquee. @@ -41,4 +41,44 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes text as marquee +.DESCRIPTION + This PowerShell script writes the given text as marquee. +.PARAMETER text + Specifies the text to write +.PARAMETER speed + Specifies the marquee speed (60 ms per default) +.EXAMPLE + PS> ./write-marquee "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$Text = "PowerShell is powerful - fully control your computer! PowerShell is cross-platform - available for Linux, Mac OS and Windows! PowerShell is open-source and free - see the GitHub repository at github.com/PowerShell/PowerShell! PowerShell is easy to learn - see the tutorial for beginners at guru99.com/powershell-tutorial.html! Powershell is fully documented - see the official PowerShell documentation at docs.microsoft.com/en-us/powershell", [int]$Speed = 60) # 60 ms pause + +function StartMarquee { param([string]$Line) + "โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—" + "โ•‘ โ•‘" + "โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•" + $LinePos = $HOST.UI.RawUI.CursorPosition + $LinePos.X = 2 + $LinePos.Y -= 2 + foreach($Pos in 1 .. $($Line.Length - 80)) { + $HOST.UI.RawUI.CursorPosition = $LinePos + Write-Host -noNewLine "$($Line.Substring($Pos,80))" + Start-Sleep -milliseconds $Speed + } + " " + " " + " " +} + +StartMarquee " +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ $Text +++ " +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of write-marquee.ps1* diff --git a/Docs/write-matrix.md b/Docs/write-matrix.md index 56be8bdc..4dc1be0f 100644 --- a/Docs/write-matrix.md +++ b/Docs/write-matrix.md @@ -1,4 +1,6 @@ -## write-matrix.ps1 - write-matrix.ps1 +## The write-matrix.ps1 PowerShell Script + +write-matrix.ps1 ## Parameters @@ -10,4 +12,66 @@ WarningVariable, OutBuffer, PipelineVariable, and OutVariable. ``` +## Source Code +<# +.SYNOPSIS + Writes the matrix +.DESCRIPTION + This PowerShell script writes the animated Matrix. +.EXAMPLE + PS> ./write-fractal +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +function CalculateMatrix { param([int]$Pos, [char]$Letter) + [int]$maxx = $rui.MaxWindowSize.Width + [int]$maxy = $rui.MaxWindowSize.Height + [int]$y = 0 + for ([int]$x = 0; $x -lt $maxx; $x++) { + if ($x -eq $Pos) { + $global:buf[$y * $maxx + $x] = $Letter + } else { + $global:buf[$y * $maxx + $x] = [char]32 + } + } + for ([int]$y = ($maxy - 1); $y -gt 0; $y--) { + for ([int]$x = 0; $x -lt $maxx; $x++) { + $global:buf[$y * $maxx + $x] = $global:buf[($y - 1) * $maxx + $x] + } + } +} + +function NextLetter { + if ($global:index -eq 6) { $global:index = 0; $global:pos = [int]$global:generator.next(0, $rui.MaxWindowSize.Width) } + switch($global:index++) { + 0 { return 'X' } + 1 { return 'I' } + 2 { return 'R' } + 3 { return 'T' } + 4 { return 'A' } + 5 { return 'M' } + } +} + +$ui = (Get-Host).ui +$rui = $ui.rawui +$buffer0 = "" +1..($rui.MaxWindowSize.Width * $rui.MaxWindowSize.Height) | ForEach-Object { $buffer0 += " " } +$global:buf = $buffer0.ToCharArray() +$global:generator = New-Object System.Random +$global:pos = [int]$global:generator.next(0, $rui.MaxWindowSize.Width) +$global:index = 0 + +while ($true) { + $Letter = NextLetter + CalculateMatrix $global:pos $Letter + [console]::SetCursorPosition(0,0) + [string]$Screen = New-Object system.string($global:buf, 0, $global:buf.Length) + Write-Host -foreground green $Screen -noNewline +} +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of write-matrix.ps1* diff --git a/Docs/write-morse-code.md b/Docs/write-morse-code.md index 06496471..d24e944a 100644 --- a/Docs/write-morse-code.md +++ b/Docs/write-morse-code.md @@ -1,4 +1,4 @@ -## write-morse-code.ps1 - Writes text in Morse code +## The write-morse-code.ps1 PowerShell Script This PowerShell script writes text in Morse code. @@ -41,4 +41,98 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes text in Morse code +.DESCRIPTION + This PowerShell script writes text in Morse code. +.PARAMETER text + Specifies the text to write +.PARAMETER speed + Specifies the speed of one time unit (100 ms per default) +.EXAMPLE + PS> ./write-morse-code "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "", [int]$speed = 100) # one time unit in milliseconds + +function gap { param([int]$Length) + for ([int]$i = 1; $i -lt $Length; $i++) { + write-host " " -nonewline + } + start-sleep -milliseconds ($Length * $speed) +} + +function dot { + write-host "." -nonewline + start-sleep -milliseconds $speed # signal +} + +function dash { + write-host "_" -nonewline + start-sleep -milliseconds (3 * $speed) # signal +} + +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 } + 'C' { dash; gap 1; dot; gap 1; dash; gap 1; dot; gap 3 } + 'D' { dash; gap 1; dot; gap 1; dot; gap 3 } + 'E' { dot; gap 3 } + 'F' { dot; gap 1; dot; gap 1; dash; gap 1; dot; gap 3 } + 'G' { dash; gap 1; dash; gap 1; dot; gap 3 } + 'H' { dot; gap 1; dot; gap 1; dot; gap 1; dot; gap 3 } + 'I' { dot; gap 1; dot; gap 3 } + 'J' { dot; gap 1; dash; gap 1; dash; gap 1; dash; gap 3 } + 'K' { dash; gap 1; dot; gap 1; dash; gap 3 } + 'L' { dot; gap 1; dash; gap 1; dot; gap 1; dot; gap 3 } + 'M' { dash; gap 1; dash; gap 3 } + 'N' { dash; gap 1; dot; gap 3 } + 'O' { dash; gap 1; dash; gap 1; dash; gap 3 } + 'P' { dot; gap 1; dash; gap 1; dash; gap 1; dot; gap 3 } + 'Q' { dash; gap 1; dash; gap 1; dot; gap 1; dash; gap 3 } + 'R' { dot; gap 1; dash; gap 1; dot; gap 3 } + 'S' { dot; gap 1; dot; gap 1; dot; gap 3 } + 'T' { dash; gap 3 } + 'U' { dot; gap 1; dot; gap 1; dash; gap 3 } + 'V' { dot; gap 1; dot; gap 1; dot; gap 1; dash; gap 3 } + 'W' { dot; gap 1; dash; gap 1; dash; gap 3 } + 'X' { dash; gap 1; dot; gap 1; dot; gap 1; dash; gap 3 } + 'Y' { dash; gap 1; dot; gap 1; dash; gap 1; dash; gap 3 } + 'Z' { dash; gap 1; dash; gap 1; dot; gap 1; dot; gap 3 } + '1' { dot; gap 1; dash; gap 1; dash; gap 1; dash; gap 1; dash; gap 3 } + '2' { dot; gap 1; dot; gap 1; dash; gap 1; dash; gap 1; dash; gap 3 } + '3' { dot; gap 1; dot; gap 1; dot; gap 1; dash; gap 1; dash; gap 3 } + '4' { dot; gap 1; dot; gap 1; dot; gap 1; dot; gap 1; dash; gap 3 } + '5' { dot; gap 1; dot; gap 1; dot; gap 1; dot; gap 1; dot; gap 3 } + '6' { dash; gap 1; dot; gap 1; dot; gap 1; dot; gap 1; dot; gap 3 } + '7' { dash; gap 1; dash; gap 1; dot; gap 1; dot; gap 1; dot; gap 3 } + '8' { dash; gap 1; dash; gap 1; dash; gap 1; dot; gap 1; dot; gap 3 } + '9' { dash; gap 1; dash; gap 1; dash; gap 1; dash; gap 1; dot; gap 3 } + '0' { dash; gap 1; dash; gap 1; dash; gap 1; dash; gap 1; dash; gap 3 } + default { gap 7 } # medium gap (between words) + } +} + +try { + if ($text -eq "" ) { [string]$text = read-host "Enter text to write" } + + [char[]]$ArrayOfChars = $text.ToUpper() + foreach($Char in $ArrayOfChars) { + Char2MorseCode $Char + } + write-host "" + write-host "" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of write-morse-code.ps1* diff --git a/Docs/write-motd.md b/Docs/write-motd.md index 1f8aae9b..3694946b 100644 --- a/Docs/write-motd.md +++ b/Docs/write-motd.md @@ -1,4 +1,4 @@ -## write-motd.ps1 - Writes the message of the day +## The write-motd.ps1 PowerShell Script This PowerShell script writes the message of the day (MOTD). @@ -23,4 +23,113 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes the message of the day +.DESCRIPTION + This PowerShell script writes the message of the day (MOTD). +.EXAMPLE + PS> ./write-motd +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param () + +# Retrieve information: +[system.threading.thread]::currentThread.currentCulture = [system.globalization.cultureInfo]"en-US" +$dt = [datetime]::Now +$day = $dt.ToLongDateString().split(',')[1].trim() +if ($day.EndsWith('1')) { $day += 'st' } elseif ($day.EndsWith('2')) { $day += 'nd' } elseif ($day.EndsWith('3')) { $day += 'rd' } else { $day += 'th' } +$CurrentTime = "$day, $($dt.Year) $($dt.Hour):$($dt.Minute)" +$TimeZone = (Get-TimeZone).id + +$UserName = [Environment]::USERNAME +$ComputerName = [System.Net.Dns]::GetHostName().ToLower() +$OSName = "$((Get-WmiObject win32_operatingsystem).caption) Build: $([System.Environment]::OSVersion.Version.Build)" +$Kernel = "NT" # todo +$Kernel_Info = "" # todo + +$BootTime = Get-WinEvent -ProviderName eventlog | Where-Object {$_.Id -eq 6005} | Select-Object TimeCreated -First 1 +$TimeSpan = New-TimeSpan -Start $BootTime.TimeCreated.Date -End (Get-Date) +$Uptime = "$($TimeSpan.Days) days, $($TimeSpan.Hours) hours, $($TimeSpan.Minutes) minutes" +$PowerShellVersion = $PSVersionTable.PSVersion +$PowerShellEdition = $PSVersionTable.PSEdition + +$CPU_Info = $env:PROCESSOR_IDENTIFIER + ' Rev: ' + $env:PROCESSOR_REVISION +$NumberOfProcesses = (Get-Process).Count +$CurrentLoad = "{0}%" -f $(Get-WmiObject Win32_Processor | Measure-Object -Property LoadPercentage -Average | Select-Object -ExpandProperty Average) +# $Logical_Disk = Get-CimInstance -ClassName Win32_LogicalDisk | Where-Object -Property DeviceID -eq $OS.SystemDrive +# $Processor = Get-CimInstance -ClassName Win32_Processor +# $Memory_Size = "{0}mb/{1}mb Used" -f (([math]::round($ReturnedValues.Operating_System.TotalVisibleMemorySize / 1KB)) - ([math]::round($ReturnedValues.Operating_System.FreePhysicalMemory / 1KB))), ([math]::round($ReturnedValues.Operating_System.TotalVisibleMemorySize / 1KB)) +$DriveDetails = Get-PSDrive C +$DiskSize = "{0}GB free of {1}GB" -f (([math]::round($DriveDetails.Free / 1GB), ([math]::round(($DriveDetails.Used + $DriveDetails.Free) / 1GB)))) + +# Print results: +[Environment]::NewLine +Write-Host " ,.=:^!^!t3Z3z., " -ForegroundColor Red +Write-Host " :tt:::tt333EE3 " -ForegroundColor Red +Write-Host " Et:::ztt33EEE " -ForegroundColor Red -NoNewline +Write-Host " @Ee., .., " -ForegroundColor green -NoNewline +Write-Host " Time: " -ForegroundColor Red -NoNewline +Write-Host "$CurrentTime" -ForegroundColor Cyan +Write-Host " ;tt:::tt333EE7" -ForegroundColor Red -NoNewline +Write-Host " ;EEEEEEttttt33# " -ForegroundColor Green -NoNewline +Write-Host " Timezone: " -ForegroundColor Red -NoNewline +Write-Host "$TimeZone" -ForegroundColor Cyan +Write-Host " :Et:::zt333EEQ." -NoNewline -ForegroundColor Red +Write-Host " SEEEEEttttt33QL " -NoNewline -ForegroundColor Green +Write-Host " User: " -NoNewline -ForegroundColor Red +Write-Host "$UserName" -ForegroundColor Cyan +Write-Host " it::::tt333EEF" -NoNewline -ForegroundColor Red +Write-Host " @EEEEEEttttt33F " -NoNewline -ForegroundColor Green +Write-Host " Hostname: " -NoNewline -ForegroundColor Red +Write-Host "$ComputerName" -ForegroundColor Cyan +Write-Host " ;3=*^``````'*4EEV" -NoNewline -ForegroundColor Red +Write-Host " :EEEEEEttttt33@. " -NoNewline -ForegroundColor Green +Write-Host " OS: " -NoNewline -ForegroundColor Red +Write-Host "$OSName" -ForegroundColor Cyan +Write-Host " ,.=::::it=., " -NoNewline -ForegroundColor Cyan +Write-Host "``" -NoNewline -ForegroundColor Red +Write-Host " @EEEEEEtttz33QF " -NoNewline -ForegroundColor Green +Write-Host " Kernel: " -NoNewline -ForegroundColor Red +Write-Host "$Kernel " -NoNewline -ForegroundColor Cyan +Write-Host "$Kernel_Info" -ForegroundColor Cyan +Write-Host " ;::::::::zt33) " -NoNewline -ForegroundColor Cyan +Write-Host " '4EEEtttji3P* " -NoNewline -ForegroundColor Green +Write-Host " Uptime: " -NoNewline -ForegroundColor Red +Write-Host "$Uptime" -ForegroundColor Cyan +Write-Host " :t::::::::tt33." -NoNewline -ForegroundColor Cyan +Write-Host ":Z3z.. " -NoNewline -ForegroundColor Yellow +Write-Host " ````" -NoNewline -ForegroundColor Green +Write-Host " ,..g. " -NoNewline -ForegroundColor Yellow +Write-Host " PowerShell: " -NoNewline -ForegroundColor Red +Write-Host "$PowerShellVersion $PowerShellEdition" -ForegroundColor Cyan +Write-Host " i::::::::zt33F" -NoNewline -ForegroundColor Cyan +Write-Host " AEEEtttt::::ztF " -NoNewline -ForegroundColor Yellow +Write-Host " CPU: " -NoNewline -ForegroundColor Red +Write-Host "$CPU_Info" -ForegroundColor Cyan +Write-Host " ;:::::::::t33V" -NoNewline -ForegroundColor Cyan +Write-Host " ;EEEttttt::::t3 " -NoNewline -ForegroundColor Yellow +Write-Host " Processes: " -NoNewline -ForegroundColor Red +Write-Host "$NumberOfProcesses" -ForegroundColor Cyan +Write-Host " E::::::::zt33L" -NoNewline -ForegroundColor Cyan +Write-Host " @EEEtttt::::z3F " -NoNewline -ForegroundColor Yellow +Write-Host " Current Load: " -NoNewline -ForegroundColor Red +Write-Host "$CurrentLoad" -ForegroundColor Cyan +Write-Host " {3=*^``````'*4E3)" -NoNewline -ForegroundColor Cyan +Write-Host " ;EEEtttt:::::tZ`` " -NoNewline -ForegroundColor Yellow +Write-Host " Memory: " -NoNewline -ForegroundColor Red +Write-Host "$Memory_Size" -ForegroundColor Cyan +Write-Host " ``" -NoNewline -ForegroundColor Cyan +Write-Host " :EEEEtttt::::z7 " -NoNewline -ForegroundColor Yellow +Write-Host " System Volume: " -NoNewline -ForegroundColor Red +Write-Host "$DiskSize" -ForegroundColor Cyan +Write-Host " 'VEzjt:;;z>*`` " -ForegroundColor Yellow +[Environment]::NewLine +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of write-motd.ps1* diff --git a/Docs/write-quote.md b/Docs/write-quote.md index 258b59f9..405a2851 100644 --- a/Docs/write-quote.md +++ b/Docs/write-quote.md @@ -1,4 +1,4 @@ -## write-quote.ps1 - Writes a random quote to the console +## The write-quote.ps1 PowerShell Script This PowerShell script writes a random quote to the console. @@ -23,4 +23,38 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes a random quote to the console +.DESCRIPTION + This PowerShell script writes a random quote to the console. +.EXAMPLE + PS> ./write-quote +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + $Table = import-csv "$PSScriptRoot/../Data/quotes.csv" + + $Generator = New-Object System.Random + $Index = [int]$Generator.next(0, $Table.Count - 1) + $Quote = $Table[$Index].Quote + $Author = $Table[$Index].Author + + "" + write-host 'โ€œ'$Quote' โ€' + $Spaces = " " + $Spaces = $Spaces.Substring(0, $Quote.Length - $Author.Length) + "$Spaces $($Author.toUpper())" + + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of write-quote.ps1* diff --git a/Docs/write-red.md b/Docs/write-red.md index 42af628d..fa67254f 100644 --- a/Docs/write-red.md +++ b/Docs/write-red.md @@ -1,4 +1,4 @@ -## write-red.ps1 - Writes text in a red foreground color +## The write-red.ps1 PowerShell Script This PowerShell script writes text in a red foreground color. @@ -32,4 +32,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes text in a red foreground color +.DESCRIPTION + This PowerShell script writes text in a red foreground color. +.PARAMETER text + Specifies the text to write +.EXAMPLE + PS> ./write-red "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +if ($text -eq "" ) { $text = read-host "Enter the text to write" } + +write-host -foregroundcolor red "$text" +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of write-red.ps1* diff --git a/Docs/write-rot13.md b/Docs/write-rot13.md index c4f56dd8..007226e1 100644 --- a/Docs/write-rot13.md +++ b/Docs/write-rot13.md @@ -1,4 +1,4 @@ -## write-rot13.ps1 - Writes text encoded or decoded with ROT13 +## The write-rot13.ps1 PowerShell Script This PowerShell script writes text encoded or decoded with ROT13. @@ -32,4 +32,46 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes text encoded or decoded with ROT13 +.DESCRIPTION + This PowerShell script writes text encoded or decoded with ROT13. +.PARAMETER text + Specifies the text to write +.EXAMPLE + PS> ./write-rot13 "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +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); + } elseif ((([int] $_ -ge 110) -and ([int] $_ -le 122)) -or (([int] $_ -ge 78) -and ([int] $_ -le 90))) { + $Result += [char] ([int] $_ - 13); + } else { + $Result += $_ + } + } + return $Result +} + +try { + if ($text -eq "" ) { $text = read-host "Enter text to write" } + + $Result = ROT13 $text + write-output $Result + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of write-rot13.ps1* diff --git a/Docs/write-sine-curves.md b/Docs/write-sine-curves.md index 4f84e60c..f5bc694b 100644 --- a/Docs/write-sine-curves.md +++ b/Docs/write-sine-curves.md @@ -1,4 +1,4 @@ -## write-sine-curves.ps1 - Write sine curves +## The write-sine-curves.ps1 PowerShell Script This PowerShell script writes sine curves. @@ -23,4 +23,29 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Write sine curves +.DESCRIPTION + This PowerShell script writes sine curves. +.EXAMPLE + PS> ./write-sine-curves +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +0..1000 | foreach { + $Value = [int](40 * [math]::sin($_ / 10)) + if ($Value -gt 0) { + $Line = " "*60+"*"*$value + } else { + $Line = " "*(60-(-1*$value))+"*"*($value*-1) + } + Write-Host $Line + Start-Sleep -milliseconds 50 +} + *Generated by convert-ps2md.ps1 using the comment-based help of write-sine-curves.ps1* diff --git a/Docs/write-time.md b/Docs/write-time.md index a8471247..8d0224e9 100644 --- a/Docs/write-time.md +++ b/Docs/write-time.md @@ -1,4 +1,4 @@ -## write-time.ps1 - Writes the current time +## The write-time.ps1 PowerShell Script This PowerShell script determines and writes the current time. @@ -23,4 +23,28 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes the current time +.DESCRIPTION + This PowerShell script determines and writes the current time. +.EXAMPLE + PS> ./write-time +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +try { + [system.threading.thread]::currentThread.currentCulture = [system.globalization.cultureInfo]"en-US" + $CurrentTime = $((Get-Date).ToShortTimeString()) + "๐Ÿ•’$CurrentTime" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of write-time.ps1* diff --git a/Docs/write-typewriter.md b/Docs/write-typewriter.md index 8ad69805..7ba16d87 100644 --- a/Docs/write-typewriter.md +++ b/Docs/write-typewriter.md @@ -1,4 +1,4 @@ -## write-typewriter.ps1 - Writes text รก la typewriter +## The write-typewriter.ps1 PowerShell Script This PowerShell script writes the given text with the typewriter effect. @@ -50,4 +50,37 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes text รก la typewriter +.DESCRIPTION + This PowerShell script writes the given text with the typewriter effect. +.PARAMETER text + Specifies the text to write +.PARAMETER speed + Specifies the speed (250 ms by default) +.EXAMPLE + PS> ./write-typewriter "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "`nHello World`n-----------`n* PowerShell is powerful - fully control your computer`n* PowerShell is cross-platform - available for Linux, Mac OS and Windows`n* PowerShell is open-source and free`n* PowerShell is easy to learn`n* PowerShell is fully documented`n`nThanks for watching`nMarkus`n", [int]$speed = 200) # in milliseconds + +try { + $Random = New-Object System.Random + $text -split '' | ForEach-Object { + Write-Host -noNewline $_ + Start-Sleep -milliseconds $(1 + $Random.Next($speed)) + } + Write-Host "" + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of write-typewriter.ps1* diff --git a/Docs/write-uppercase.md b/Docs/write-uppercase.md index 422f16d5..6823e68c 100644 --- a/Docs/write-uppercase.md +++ b/Docs/write-uppercase.md @@ -1,4 +1,4 @@ -## write-uppercase.ps1 - Writes text in uppercase letters +## The write-uppercase.ps1 PowerShell Script This PowerShell script writes text in uppercase letters. @@ -32,4 +32,27 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes text in uppercase letters +.DESCRIPTION + This PowerShell script writes text in uppercase letters. +.PARAMETER text + Specifies the text to write +.EXAMPLE + PS> ./write-uppercase "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +if ($text -eq "" ) { $text = read-host "Enter the text to write" } + +write-output $text.ToUpper() +exit 0 # success + *Generated by convert-ps2md.ps1 using the comment-based help of write-uppercase.ps1* diff --git a/Docs/write-vertical.md b/Docs/write-vertical.md index 318df106..b531aa50 100644 --- a/Docs/write-vertical.md +++ b/Docs/write-vertical.md @@ -1,4 +1,4 @@ -## write-vertical.ps1 - Writes text in vertical direction +## The write-vertical.ps1 PowerShell Script This PowerShell script writes text in vertical direction. @@ -32,4 +32,35 @@ Author: Markus Fleschutz | License: CC0 ## Related Links https://github.com/fleschutz/PowerShell +## Source Code +<# +.SYNOPSIS + Writes text in vertical direction +.DESCRIPTION + This PowerShell script writes text in vertical direction. +.PARAMETER text + Specifies the text to write +.EXAMPLE + PS> ./write-vertical "Hello World" +.LINK + https://github.com/fleschutz/PowerShell +.NOTES + Author: Markus Fleschutz | License: CC0 +#> + +param([string]$text = "") + +try { + if ($text -eq "" ) { $text = read-host "Enter the text to write" } + + [char[]]$TextArray = $text + foreach($Char in $TextArray) { + write-output $Char + } + exit 0 # success +} catch { + "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" + exit 1 +} + *Generated by convert-ps2md.ps1 using the comment-based help of write-vertical.ps1* diff --git a/Scripts/convert-ps2md.ps1 b/Scripts/convert-ps2md.ps1 index beabf124..2a83087f 100755 --- a/Scripts/convert-ps2md.ps1 +++ b/Scripts/convert-ps2md.ps1 @@ -52,18 +52,20 @@ function GetRemark { param($Example) try { if ($filename -eq "") { $filename = read-host "Enter path to PowerShell script" } - $ScriptName = (get-item "$filename").Name + $ScriptName = (Get-Item "$filename").Name $full = Get-Help $filename -Full - "## $ScriptName - $($full.Synopsis)" + "## The $ScriptName PowerShell Script" $Description = ($full.description | Out-String).Trim() if ($Description -ne "") { "" "$Description" + } else { + "" + "$($full.Synopsis)" } - "" "## Parameters" "``````powershell" @@ -116,6 +118,12 @@ try { "$Links" } + "" + "## Source Code" + $Lines = Get-Content -path "$filename" + foreach($Line in $Lines) { + "$Line" + } "" "*Generated by convert-ps2md.ps1 using the comment-based help of $ScriptName*" } catch {