Update the manuals in Docs/

This commit is contained in:
Markus Fleschutz 2022-11-17 20:02:26 +01:00
parent 4dac9cf2b1
commit 7f79a2afbb
515 changed files with 20228 additions and 517 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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