Update Markdown manuals

This commit is contained in:
Markus Fleschutz 2023-05-26 12:20:18 +02:00
parent e4b9649681
commit 1cd755a378
520 changed files with 4337 additions and 1569 deletions

View File

@ -4,7 +4,7 @@ This PowerShell script adds firewall rules for the given executable. Administrat
## Parameters
```powershell
add-firewall-rules.ps1 [[-PathToExecutables] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/add-firewall-rules.ps1 [[-PathToExecutables] <String>] [<CommonParameters>]
-PathToExecutables <String>
Specifies the path to the executables

View File

@ -1,10 +1,10 @@
## The *add-memo.ps1* Script
This PowerShell script adds the given memo text to $HOME/Memos.csv.
This PowerShell script saves the given memo text to Memos.csv in your home folder.
## Parameters
```powershell
add-memo.ps1 [[-text] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/add-memo.ps1 [[-text] <String>] [<CommonParameters>]
-text <String>
Specifies the text to memorize
@ -23,7 +23,7 @@ add-memo.ps1 [[-text] <String>] [<CommonParameters>]
## Example
```powershell
PS> ./add-memo "Buy apples"
✔️ added to 📄/home/markus/Memos.csv
✔️ saved to 📄/home/markus/Memos.csv
```
@ -39,12 +39,12 @@ https://github.com/fleschutz/PowerShell
.SYNOPSIS
Adds a memo text
.DESCRIPTION
This PowerShell script adds the given memo text to $HOME/Memos.csv.
This PowerShell script saves the given memo text to Memos.csv in your home folder.
.PARAMETER text
Specifies the text to memorize
.EXAMPLE
PS> ./add-memo "Buy apples"
✔️ added to 📄/home/markus/Memos.csv
✔️ saved to 📄/home/markus/Memos.csv
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -54,19 +54,18 @@ https://github.com/fleschutz/PowerShell
param([string]$text = "")
try {
if ($text -eq "" ) { $text = read-host "Enter the memo text to add" }
if ($text -eq "" ) { $text = Read-Host "Enter the text to memorize" }
$Path = "$HOME/Memos.csv"
$Time = get-date -format "yyyy-MM-ddTHH:mm:ssZ" -asUTC
$User = $(whoami)
$Line = "$Time,$User,$text"
$Path = "~/Memos.csv"
$Time = Get-Date -format FileDateTimeUniversal
$Line = "$Time,$text"
if (-not(test-path "$Path" -pathType leaf)) {
write-output "Time,User,text" > "$Path"
if (-not(Test-Path "$Path" -pathType leaf)) {
Write-Output "TIME,TEXT" > "$Path"
}
write-output $Line >> "$Path"
Write-Output $Line >> "$Path"
"✔️ added to 📄$Path"
"✔️ saved to 📄$Path"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -4,7 +4,7 @@ This PowerShell script handles and escalates the given alert message.
## Parameters
```powershell
alert.ps1 [[-Message] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/alert.ps1 [[-Message] <String>] [<CommonParameters>]
-Message <String>
Specifies the alert message

View File

@ -1,10 +1,10 @@
## The *build-repo.ps1* Script
This PowerShell script supports building with cmake, configure, autogen, Imakefile and Makefile.
This PowerShell script builds a repository by supporting: cmake, configure, autogen, Imakefile, and Makefile.
## Parameters
```powershell
build-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/build-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
-RepoDir <String>
Specifies the path to the Git repository
@ -36,9 +36,9 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Builds a Git repository
Builds a repository
.DESCRIPTION
This PowerShell script supports building with cmake, configure, autogen, Imakefile and Makefile.
This PowerShell script builds a repository by supporting: cmake, configure, autogen, Imakefile, and Makefile.
.PARAMETER RepoDir
Specifies the path to the Git repository
.EXAMPLE
@ -51,14 +51,14 @@ https://github.com/fleschutz/PowerShell
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)) {
function BuildInDir { param($Path)
$DirName = (Get-Item "$Path").Name
if (Test-Path "$Path/CMakeLists.txt" -pathType leaf) {
"⏳ Building repo 📂$DirName using CMakeLists.txt into subfolder _My_Build ..."
if (-not(Test-Path "$Path/_My_Build/" -pathType container)) {
& mkdir "$Path/_My_Build/"
}
set-location "$Path/_My_Build/"
Set-Location "$Path/_My_Build/"
& cmake ..
if ($lastExitCode -ne "0") { throw "Executing 'cmake ..' has failed" }
@ -69,9 +69,9 @@ function MakeDir { param($Path)
& 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/"
} elseif (Test-Path "$Path/configure" -pathType leaf) {
"⏳ Building repo 📂$DirName using 'configure'..."
Set-Location "$Path/"
& ./configure
#if ($lastExitCode -ne "0") { throw "Script 'configure' exited with error code $lastExitCode" }
@ -82,9 +82,9 @@ function MakeDir { param($Path)
& 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/"
} elseif (Test-Path "$Path/autogen.sh" -pathType leaf) {
"⏳ Building repo 📂$DirName using 'autogen.sh'..."
Set-Location "$Path/"
& ./autogen.sh
if ($lastExitCode -ne "0") { throw "Script 'autogen.sh' exited with error code $lastExitCode" }
@ -92,9 +92,9 @@ function MakeDir { param($Path)
& 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"
} elseif (Test-Path "$Path/build.gradle" -pathType leaf) {
"⏳ Building repo 📂$DirName using build.gradle..."
Set-Location "$Path"
& gradle build
if ($lastExitCode -ne "0") { throw "'gradle build' has failed" }
@ -102,9 +102,9 @@ function MakeDir { param($Path)
& 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/"
} elseif (Test-Path "$Path/Imakefile" -pathType leaf) {
"⏳ Building repo 📂$DirName using Imakefile..."
Set-Location "$RepoDir/"
& xmkmf
if ($lastExitCode -ne "0") { throw "Executing 'xmkmf' has failed" }
@ -112,16 +112,23 @@ function MakeDir { param($Path)
& 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"
} elseif (Test-Path "$Path/Makefile" -pathType leaf) {
"⏳ Building repo 📂$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/"
} elseif (Test-Path "$Path/makefile" -pathType leaf) {
"⏳ Building repo 📂$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 repo 📂$DirName using 'compile.sh'..."
Set-Location "$Path/"
& ./compile.sh
if ($lastExitCode -ne "0") { throw "Script 'compile.sh' exited with error code $lastExitCode" }
@ -129,18 +136,18 @@ function MakeDir { param($Path)
& 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/"
} elseif (Test-Path "$Path/attower/src/build/DevBuild/build.bat" -pathType leaf) {
"⏳ Building repo 📂$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"
} elseif (Test-Path "$Path/$DirName" -pathType container) {
" No make rule found, trying subfolder 📂$($DirName)..."
BuildInDir "$Path/$DirName"
} else {
write-warning "Sorry, no make rule applies to: 📂$DirName"
Write-Warning "Sorry, no make rule applies to: 📂$DirName"
exit 0 # success
}
}
@ -148,15 +155,15 @@ function MakeDir { param($Path)
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
$RepoDirName = (get-item "$RepoDir").Name
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"
$PreviousPath = Get-Location
BuildInDir "$RepoDir"
Set-Location "$PreviousPath"
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ built Git repository 📂$RepoDirName in $Elapsed sec"
"✔️ built repo 📂$RepoDirName in $Elapsed sec"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -4,7 +4,7 @@ This PowerShell script builds all Git repositories in a folder.
## Parameters
```powershell
build-repos.ps1 [[-ParentDir] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/build-repos.ps1 [[-ParentDir] <String>] [<CommonParameters>]
-ParentDir <String>
Specifies the path to the parent folder

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the user's autostart fol
## Parameters
```powershell
cd-autostart.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-autostart.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

57
Docs/cd-crashdumps.md Normal file
View File

@ -0,0 +1,57 @@
## The *cd-crashdumps.ps1* Script
This PowerShell script changes the working directory to the crash dumps directory (Windows only).
## Parameters
```powershell
/home/mf/Repos/PowerShell/Scripts/cd-crashdumps.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
## Example
```powershell
PS> ./cd-crashdumps
📂C:\Users\Markus\AppData\Local\CrashDumps
```
## Notes
Author: Markus Fleschutz | License: CC0
## Related Links
https://github.com/fleschutz/PowerShell
## Source Code
```powershell
<#
.SYNOPSIS
Change to the crash dumps folder
.DESCRIPTION
This PowerShell script changes the working directory to the crash dumps directory (Windows only).
.EXAMPLE
PS> ./cd-crashdumps
📂C:\Users\Markus\AppData\Local\CrashDumps
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
[string]$Path = Resolve-Path -Path "~"
if (!(Test-Path $Path)) { throw "Home directory at $Path doesn't exist (yet)" }
$Path += "\AppData\Local\CrashDumps"
if (!(Test-Path $Path)) { throw "Crashdumps 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-crashdumps.ps1*

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the user's desktop folde
## Parameters
```powershell
cd-desktop.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-desktop.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -42,16 +42,16 @@ https://github.com/fleschutz/PowerShell
try {
if ($IsLinux) {
$Path = Resolve-Path "$HOME/Desktop"
$Path = Resolve-Path "~/Desktop"
} else {
$Path = [Environment]::GetFolderPath('DesktopDirectory')
}
if (-not(Test-Path "$Path" -pathType container)) {
throw "Desktop folder at 📂$Path doesn't exist (yet)"
if (Test-Path "$Path" -pathType container) {
Set-Location "$Path"
"📂$Path"
exit 0 # success
}
Set-Location "$Path"
"📂$Path"
exit 0 # success
throw "User's desktop folder at 📂$Path doesn't exist (yet)"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the documents folder.
## Parameters
```powershell
cd-docs.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-docs.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the user's downloads fol
## Parameters
```powershell
cd-downloads.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-downloads.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -42,16 +42,16 @@ https://github.com/fleschutz/PowerShell
try {
if ($IsLinux) {
$Path = Resolve-Path "$HOME/Downloads"
$Path = Resolve-Path "~/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)"
if (Test-Path "$Path" -pathType container) {
Set-Location "$Path"
"📂$Path"
exit 0 # success
}
Set-Location "$Path"
"📂$Path"
exit 0 # success
throw "User's downloads folder at 📂$Path doesn't exist (yet)"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the user's Dropbox folde
## Parameters
```powershell
cd-dropbox.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-dropbox.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the fonts folder.
## Parameters
```powershell
cd-fonts.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-fonts.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the user's home director
## Parameters
```powershell
cd-home.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-home.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -28,7 +28,7 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Sets the working directory to the user's home directory
Sets the working directory to the user's home folder
.DESCRIPTION
This PowerShell script changes the working directory to the user's home directory.
.EXAMPLE
@ -41,13 +41,13 @@ https://github.com/fleschutz/PowerShell
#>
try {
$Path = Resolve-Path "$HOME"
if (-not(Test-Path "$Path" -pathType container)) {
throw "Home directory at 📂$Path doesn't exist (yet)"
$Path = Resolve-Path -Path "~"
if (Test-Path "$Path" -pathType container) {
Set-Location "$Path"
"📂$Path"
exit 0 # success
}
Set-Location "$Path"
"📂$Path"
exit 0 # success
throw "User's home folder at 📂$Path doesn't exist (yet)"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the user's music folder.
## Parameters
```powershell
cd-music.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-music.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -42,16 +42,16 @@ https://github.com/fleschutz/PowerShell
try {
if ($IsLinux) {
$Path = Resolve-Path "$HOME/Music"
$Path = Resolve-Path "~/Music"
} else {
$Path = [Environment]::GetFolderPath('MyMusic')
}
if (-not(Test-Path "$Path" -pathType container)) {
throw "Music folder at 📂$Path doesn't exist (yet)"
if (Test-Path "$Path" -pathType container) {
Set-Location "$Path"
"📂$Path"
exit 0 # success
}
Set-Location "$Path"
"📂$Path"
exit 0 # success
throw "User's music folder at 📂$Path doesn't exist (yet)"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the user's OneDrive fold
## Parameters
```powershell
cd-onedrive.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-onedrive.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the user's pictures fold
## Parameters
```powershell
cd-pics.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-pics.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

61
Docs/cd-public.md Normal file
View File

@ -0,0 +1,61 @@
## The *cd-public.ps1* Script
This PowerShell script changes the working directory to the Public folder.
## Parameters
```powershell
/home/mf/Repos/PowerShell/Scripts/cd-public.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
## Example
```powershell
PS> ./cd-public
📂C:\Users\Public
```
## Notes
Author: Markus Fleschutz | License: CC0
## Related Links
https://github.com/fleschutz/PowerShell
## Source Code
```powershell
<#
.SYNOPSIS
Sets the working directory to the Public folder
.DESCRIPTION
This PowerShell script changes the working directory to the Public folder.
.EXAMPLE
PS> ./cd-public
📂C:\Users\Public
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
if ($IsLinux) {
$Path = Resolve-Path "~/Public"
} else {
$Path = Resolve-Path "~/../Public"
}
if (Test-Path "$Path" -pathType container) {
Set-Location "$Path"
"📂$Path"
exit 0 # success
}
throw "Public folder at 📂$Path doesn't exist (yet)"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
```
*Generated by convert-ps2md.ps1 using the comment-based help of cd-public.ps1*

View File

@ -35,7 +35,11 @@ function GetCurrentUserSID { [CmdletBinding()] param()
try {
$Path = 'C:\$Recycle.Bin\' + "$(GetCurrentUserSID)"
if ($IsLinux) {
$Path = "$HOME/.local/share/Trash/"
} else {
$Path = "C:\$Recycle.Bin\" + "$(GetCurrentUserSID)"
}
if (-not(Test-Path "$Path" -pathType container)) {
throw "Recycle bin folder at 📂$Path doesn't exist (yet)"
}

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the user's Git repositor
## Parameters
```powershell
cd-repos.ps1 [[-Subpath] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-repos.ps1 [[-Subpath] <String>] [<CommonParameters>]
-Subpath <String>
Specifies an additional relative subpath (optional)
@ -61,7 +61,7 @@ try {
} elseif (Test-Path "$HOME/source/repos" -pathType Container) { # try Visual Studio default
$Path = "$HOME/source/repos/$Subpath"
} else {
throw "The folder for Git repositories at 📂$HOME/Reposh doesn't exist (yet)."
throw "The folder for Git repositories in your home directory doesn't exist (yet)."
}
if (-not(Test-Path "$Path" -pathType Container)) {
throw "The path to 📂$Path doesn't exist (yet)."

View File

@ -4,7 +4,7 @@ This PowerShell script changes the current working directory to the root directo
## Parameters
```powershell
cd-root.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-root.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -1,29 +1,17 @@
## The *cd-screenshots.ps1* Script
This PowerShell script changes the working directory to the user's screenshots folder.
cd-screenshots.ps1
## Parameters
```powershell
cd-screenshots.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
## Example
```powershell
PS> ./cd-screenshots
📂C:\Users\Markus\Pictures\Screenshots
```
## Notes
Author: Markus Fleschutz | License: CC0
## Related Links
https://github.com/fleschutz/PowerShell
## Source Code
```powershell
<#
@ -40,16 +28,21 @@ https://github.com/fleschutz/PowerShell
Author: Markus Fleschutz | License: CC0
#>
function GetScreenshotsFolder {
if ($IsLinux) {
$Path = "$HOME/Pictures"
if (-not(Test-Path "$Path" -pathType container)) { throw "Pictures folder at $Path doesn't exist (yet)" }
if (Test-Path "$Path/Screenshots" -pathType container) { $Path = "$Path/Screenshots" }
} else {
$Path = [Environment]::GetFolderPath('MyPictures')
if (-not(Test-Path "$Path" -pathType container)) { throw "Pictures folder at $Path doesn't exist (yet)" }
if (Test-Path "$Path\Screenshots" -pathType container) { $Path = "$Path\Screenshots" }
}
return $Path
}
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)"
}
$Path = GetScreenshotsFolder
Set-Location "$Path"
"📂$Path"
exit 0 # success

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the PowerShell scripts f
## Parameters
```powershell
cd-scripts.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-scripts.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the user's SSH folder.
## Parameters
```powershell
cd-ssh.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-ssh.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -41,13 +41,13 @@ https://github.com/fleschutz/PowerShell
#>
try {
$Path = Resolve-Path "$HOME/.ssh"
if (-not(Test-Path "$Path" -pathType container)) {
throw "SSH folder at 📂$Path doesn't exist (yet)"
$Path = Resolve-Path "~/.ssh"
if (Test-Path "$Path" -pathType container) {
Set-Location "$Path"
"📂$Path"
exit 0 # success
}
Set-Location "$Path"
"📂$Path"
exit 0 # success
throw "User's SSH folder at 📂$Path doesn't exist (yet)"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

61
Docs/cd-templates.md Normal file
View File

@ -0,0 +1,61 @@
## The *cd-templates.ps1* Script
This PowerShell script changes the working directory to the templates folder.
## Parameters
```powershell
/home/mf/Repos/PowerShell/Scripts/cd-templates.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
## Example
```powershell
PS> ./cd-templates
📂/home/Markus/Templates
```
## Notes
Author: Markus Fleschutz | License: CC0
## Related Links
https://github.com/fleschutz/PowerShell
## Source Code
```powershell
<#
.SYNOPSIS
Sets the working directory to the templates folder
.DESCRIPTION
This PowerShell script changes the working directory to the templates folder.
.EXAMPLE
PS> ./cd-templates
📂/home/Markus/Templates
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
if ($IsLinux) {
$Path = Resolve-Path "~/Templates"
} else {
$Path = [Environment]::GetFolderPath('Templates')
}
if (Test-Path "$Path" -pathType container) {
Set-Location "$Path"
"📂$Path"
exit 0 # success
}
throw "Templates folder at 📂$Path doesn't exist (yet)"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
```
*Generated by convert-ps2md.ps1 using the comment-based help of cd-templates.ps1*

55
Docs/cd-trash.md Normal file
View File

@ -0,0 +1,55 @@
## The *cd-trash.ps1* Script
cd-trash.ps1
## Parameters
```powershell
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
## Source Code
```powershell
<#
.SYNOPSIS
Sets the working directory to the user's trash folder
.DESCRIPTION
This PowerShell script changes the working directory to the user's trash folder.
.EXAMPLE
PS> ./cd-trash
📂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 {
if ($IsLinux) {
$Path = "$HOME/.local/share/Trash/"
} else {
$Path = "C:\$Recycle.Bin\" + "$(GetCurrentUserSID)"
}
if (-not(Test-Path "$Path" -pathType container)) {
throw "Trash 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-trash.ps1*

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to one directory level up.
## Parameters
```powershell
cd-up.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-up.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to two directory level up.
## Parameters
```powershell
cd-up2.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-up2.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to three directory levels u
## Parameters
```powershell
cd-up3.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-up3.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to four directory levels up
## Parameters
```powershell
cd-up4.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-up4.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the users directory.
## Parameters
```powershell
cd-users.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-users.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the user's videos folder
## Parameters
```powershell
cd-videos.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-videos.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the Windows directory.
## Parameters
```powershell
cd-windows.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/cd-windows.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script downloads a random photo from Unsplash and sets it as des
## Parameters
```powershell
change-wallpaper.ps1 [[-Category] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/change-wallpaper.ps1 [[-Category] <String>] [<CommonParameters>]
-Category <String>
Specifies the photo category (beach, city, ...)

View File

@ -1,10 +1,10 @@
## The *check-apps.ps1* Script
This PowerShell script queries application details and list it.
This PowerShell script queries the application status and prints it.
## Parameters
```powershell
check-apps.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-apps.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,6 +14,7 @@ check-apps.ps1 [<CommonParameters>]
## Example
```powershell
PS> ./check-apps
✅ 119 apps installed, 11 upgrades available
```
@ -27,11 +28,12 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Query application details
Query the app status
.DESCRIPTION
This PowerShell script queries application details and list it.
This PowerShell script queries the application status and prints it.
.EXAMPLE
PS> ./check-apps
✅ 119 apps installed, 11 upgrades available
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -42,10 +44,19 @@ try {
if ($IsLinux) {
# TODO
} else {
Write-Progress "Querying installed apps and available updates..."
$NumAppsInstalled = (Get-AppxPackage).Count
$NumUpdates = (winget upgrade).Count - 5
"✅ $NumAppsInstalled apps installed, $NumUpdates updates available"
Write-Progress "⏳ Querying installed apps and updates..."
$Apps = Get-AppxPackage
$Status = "✅ $($Apps.Count) apps installed"
[int]$NumNonOk = 0
foreach($App in $Apps) { if ($App.Status -ne "Ok") { $NumNonOk++ } }
if ($NumNonOk -gt 0) { $Status += ", $NumNonOk non-ok" }
[int]$NumErrors = (Get-AppxLastError)
if ($NumErrors -gt 0) { $Status += ", $NumErrors errors" }
$NumUpdates = (winget upgrade --include-unknown).Count - 5
Write-Progress -Completed "."
Write-Host "$Status, $NumUpdates upgrades available"
}
exit 0 # success
} catch {

View File

@ -1,10 +1,10 @@
## The *check-battery.ps1* Script
This PowerShell script checks and prints the battery status.
This PowerShell script queries the status of the system battery and prints it.
## Parameters
```powershell
check-battery.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-battery.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,6 +14,7 @@ check-battery.ps1 [<CommonParameters>]
## Example
```powershell
PS> ./check-battery
✅ 21% battery life, 54 min remaining
```
@ -27,11 +28,12 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Checks the battery status
Checks the battery
.DESCRIPTION
This PowerShell script checks and prints the battery status.
This PowerShell script queries the status of the system battery and prints it.
.EXAMPLE
PS> ./check-battery
✅ 21% battery life, 54 min remaining
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -40,23 +42,34 @@ https://github.com/fleschutz/PowerShell
try {
if ($IsLinux) {
# TODO
$Reply = "✅ AC powered" # TODO, just guessing :-)
} else {
Add-Type -Assembly System.Windows.Forms
$Details = [System.Windows.Forms.SystemInformation]::PowerStatus
if ($Details.BatteryChargeStatus -eq "NoSystemBattery") {
$BatteryStatus = "No battery"
} else {
[int]$Percent = 100*$Details.BatteryLifePercent
[int]$Remaining = $Details.BatteryLifeRemaining / 60
$BatteryStatus = "Battery $Percent%, $Remaining min left"
}
[int]$Percent = 100 * $Details.BatteryLifePercent
[int]$Remaining = $Details.BatteryLifeRemaining / 60
switch ($Details.PowerLineStatus) {
"Online" { $PowerStatus = "plugged in to AC power" }
"Offline" { $PowerStatus = "disconnected from AC power" }
"Online" {
if ($Details.BatteryChargeStatus -eq "NoSystemBattery") {
$Reply = "✅ AC powered"
} elseif ($Percent -eq 100) {
$Reply = "✅ Battery $Percent% full"
} else {
$Reply = "✅ Battery $Percent%, charging..."
}
}
"Offline" {
if ($Percent -eq 100) {
$Reply = "✅ $Percent% full battery, $Remaining min remaining"
} elseif ($Remaining -gt 30) {
$Reply = "✅ $Percent% battery life, $Remaining min remaining"
} else {
$Reply = "⚠️ $Percent% battery life, only $Remaining min remaining"
}
}
}
"✅ $BatteryStatus, $PowerStatus"
}
Write-Host $Reply
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,10 +1,10 @@
## The *check-bios.ps1* Script
This PowerShell script queries BIOS details and prints it.
This PowerShell script queries the BIOS status and prints it.
## Parameters
```powershell
check-bios.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-bios.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,7 +14,7 @@ check-bios.ps1 [<CommonParameters>]
## Example
```powershell
PS> ./check-bios
✅ BIOS V1.10 by INSYDE Corp. (S/N NXA82EV0EBB07600, version ACRSYS - 2)
✅ BIOS F6 by American Megatrends Inc. (version ALASKA - 1072009, S/N NXA82EV0EBB0760)
```
@ -28,12 +28,12 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Checks BIOS details
Checks the BIOS status
.DESCRIPTION
This PowerShell script queries BIOS details and prints it.
This PowerShell script queries the BIOS status and prints it.
.EXAMPLE
PS> ./check-bios
✅ BIOS V1.10 by INSYDE Corp. (S/N NXA82EV0EBB07600, version ACRSYS - 2)
✅ BIOS F6 by American Megatrends Inc. (version ALASKA - 1072009, S/N NXA82EV0EBB0760)
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -41,16 +41,25 @@ https://github.com/fleschutz/PowerShell
#>
try {
Write-Progress "Querying BIOS details..."
if ($IsLinux) {
# TODO
Write-Progress "⏳ Querying BIOS..."
$Model = (sudo dmidecode -s system-product-name)
if ("$Model" -ne "") {
$Manufacturer = (sudo dmidecode -s system-manufacturer)
$Version = (sudo dmidecode -s bios-version)
$RelDate = (sudo dmidecode -s bios-release-date)
Write-Host "✅ BIOS $Model by $Manufacturer ($Version release of $RelDate)"
}
Write-Progress -completed "."
} else {
Write-Progress "⏳ Querying BIOS..."
$BIOS = Get-CimInstance -ClassName Win32_BIOS
$Manufacturer = $BIOS.Manufacturer
$Model = $BIOS.Name
$Serial = $BIOS.SerialNumber
$Version = $BIOS.Version
"✅ BIOS $Model by $Manufacturer (S/N $Serial, version $Version)"
$Model = $BIOS.Name.Trim()
$Manufacturer = $BIOS.Manufacturer.Trim()
$Serial = $BIOS.SerialNumber.Trim()
$Version = $BIOS.Version.Trim()
Write-Progress -completed "."
Write-Host "✅ BIOS $Model by $Manufacturer (version $Version, S/N $Serial)"
}
exit 0 # success
} catch {

View File

@ -16,12 +16,12 @@ check-cpu.ps1
```powershell
<#
.SYNOPSIS
Queries and prints CPU details
Checks the CPU status
.DESCRIPTION
This PowerShell script queries CPU details (name, type, speed, temperature, etc.) and prints it.
This PowerShell script queries the CPU status and prints it (name, type, speed, temperature, etc).
.EXAMPLE
PS> ./check-cpu
CPU AMD Ryzen 5 5500U with Radeon Graphics (CPU0, 2100MHz, 31.3°C)
✅ AMD Ryzen 5 5500U with Radeon Graphics (CPU0, 2100MHz, 31.3°C)
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -45,29 +45,54 @@ function GetCPUTemperatureInCelsius {
return $Temp;
}
function GetProcessorArchitecture {
if ("$env:PROCESSOR_ARCHITECTURE" -ne "") { return "$env:PROCESSOR_ARCHITECTURE" }
if ($IsLinux) {
$Name = $PSVersionTable.OS
if ($Name -like "*-generic *") {
if ([System.Environment]::Is64BitOperatingSystem) { return "x64" } else { return "x86" }
} elseif ($Name -like "*-raspi *") {
if ([System.Environment]::Is64BitOperatingSystem) { return "ARM64" } else { return "ARM32" }
} else {
return ""
}
}
}
try {
Write-Progress "Querying CPU details ..."
Write-Progress "⏳ Querying CPU details..."
$Status = "✅"
$Celsius = GetCPUTemperatureInCelsius
if ($Celsius -eq 99999.9) {
$Temp = "no temp"
} elseif ($Celsius -gt 50) {
$Temp = "⚠️$($Celsius)°C"
$Temp = "$($Celsius)°C"
$Status = "⚠"
} elseif ($Celsius -lt 0) {
$Temp = "⚠️$($Celsius)°C"
$Temp = "$($Celsius)°C"
$Status = "⚠"
} else {
$Temp = "$($Celsius)°C"
}
$Arch = GetProcessorArchitecture
if ($IsLinux) {
"✅ CPU has $Temp"
$CPUName = "$Arch CPU"
$Arch = ""
$DeviceID = ""
$Speed = ""
$Socket = ""
} else {
$Details = Get-WmiObject -Class Win32_Processor
$CPUName = $Details.Name.trim()
$DeviceID = $Details.DeviceID
$Speed = "$($Details.MaxClockSpeed)MHz"
$Socket = $Details.SocketDesignation
"✅ CPU $CPUName ($DeviceID, $Speed, socket $Socket, $Temp)"
$Arch = "$Arch, "
$DeviceID = "$($Details.DeviceID), "
$Speed = "$($Details.MaxClockSpeed)MHz, "
$Socket = "$($Details.SocketDesignation) socket, "
}
$Cores = [System.Environment]::ProcessorCount
Write-Progress -completed "done."
Write-Host "$Status $CPUName ($($Arch)$Cores cores, $($DeviceID)$($Speed)$($Socket)$Temp)"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -4,7 +4,7 @@ This PowerShell script determines and speaks the current day by text-to-speech (
## Parameters
```powershell
check-day.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-day.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -1,10 +1,10 @@
## The *check-dns.ps1* Script
This PowerShell script measures and prints the DNS resolution speed by using 200 frequently used domain names.
This PowerShell script measures and prints the DNS resolution speed by using 200 popular domains.
## Parameters
```powershell
check-dns.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-dns.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,6 +14,7 @@ check-dns.ps1 [<CommonParameters>]
## Example
```powershell
PS> ./check-dns
✅ DNS resolves 156.5 domains per second
```
@ -27,11 +28,12 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Checks the DNS resolution
Check DNS resolution
.DESCRIPTION
This PowerShell script measures and prints the DNS resolution speed by using 200 frequently used domain names.
This PowerShell script measures and prints the DNS resolution speed by using 200 popular domains.
.EXAMPLE
PS> ./check-dns
✅ DNS resolves 156.5 domains per second
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -39,26 +41,26 @@ https://github.com/fleschutz/PowerShell
#>
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 "⏳ Resolving 200 popular domain names..."
$table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv"
$numRows = $table.Length
Write-Progress "⏳ Step 2/2 - Resolving $NumRows domains..."
$StopWatch = [system.diagnostics.stopwatch]::startNew()
$stopWatch = [system.diagnostics.stopwatch]::startNew()
if ($IsLinux) {
foreach($Row in $Table){$nop=dig $Row.Domain +short}
foreach($row in $table){$nop=dig $row.Domain +short}
} else {
foreach($Row in $Table){$nop=Resolve-DNSName $Row.Domain}
foreach($row in $table){$nop=Resolve-DNSName $row.Domain}
}
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
[float]$Elapsed = $StopWatch.Elapsed.TotalSeconds
$Average = [math]::round($NumRows / $Elapsed, 1)
if ($Average -gt 10.0) {
"✅ DNS resolves $Average domains per second"
$average = [math]::round($numRows / $elapsed, 1)
if ($average -lt 10.0) {
"⚠️ DNS resolves $average domains per second only!"
} else {
"⚠️ DNS resolves only $Average domains per second!"
"✅ DNS resolves $average domains per second"
}
Write-Progress -completed "."
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -4,7 +4,7 @@ This PowerShell script checks a drive for free space left (20 GB by default).
## Parameters
```powershell
check-drive-space.ps1 [[-Drive] <String>] [[-MinLevel] <Int32>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-drive-space.ps1 [[-Drive] <String>] [[-MinLevel] <Int32>] [<CommonParameters>]
-Drive <String>
Specifies the drive to check

View File

@ -4,7 +4,7 @@ This PowerShell script checks all drives for free space left.
## Parameters
```powershell
check-drives.ps1 [[-MinLevel] <Int32>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-drives.ps1 [[-MinLevel] <Int32>] [<CommonParameters>]
-MinLevel <Int32>
Specifies the minimum warning level (10 GB by default)
@ -23,6 +23,7 @@ check-drives.ps1 [[-MinLevel] <Int32>] [<CommonParameters>]
## Example
```powershell
PS> ./check-drives
✅ C drive uses 87GB of 249GB
```
@ -43,6 +44,7 @@ https://github.com/fleschutz/PowerShell
Specifies the minimum warning level (10 GB by default)
.EXAMPLE
PS> ./check-drives
✅ C drive uses 87GB of 249GB
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -68,7 +70,9 @@ function Bytes2String { param([int64]$Bytes)
}
try {
$Drives = Get-PSDrive -PSProvider FileSystem
Write-Progress "⏳ Querying drives..."
$Drives = Get-PSDrive -PSProvider FileSystem
Write-Progress -completed "done."
foreach($Drive in $Drives) {
$ID = $Drive.Name
$Details = (Get-PSDrive $ID)
@ -77,13 +81,15 @@ try {
[int64]$Total = ($Used + $Free)
if ($Total -eq 0) {
"✅ Drive $ID is empty"
Write-Host "✅ $ID drive is empty"
} elseif ($Free -eq 0) {
Write-Host "⚠️ $ID drive with $(Bytes2String $Total) is full!"
} elseif ($Free -lt $MinLevel) {
"⚠️ Drive $ID has only $(Bytes2String $Free) of $(Bytes2String $Total) left to use!"
Write-Host "⚠️ $ID drive with $(Bytes2String $Total) is nearly full ($(Bytes2String $Free) free)!"
} elseif ($Used -lt $Free) {
"✅ Drive $ID uses $(Bytes2String $Used) of $(Bytes2String $Total)"
Write-Host "✅ $ID drive uses $(Bytes2String $Used) of $(Bytes2String $Total)"
} else {
"✅ Drive $ID has $(Bytes2String $Free) free of $(Bytes2String $Total)"
Write-Host "✅ $ID drive has $(Bytes2String $Free) of $(Bytes2String $Total) free"
}
}
exit 0 # success

View File

@ -4,7 +4,7 @@ This PowerShell script checks the time until Easter Sunday and replies by text-t
## Parameters
```powershell
check-easter-sunday.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-easter-sunday.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script checks the file system of a drive. It needs admin rights.
## Parameters
```powershell
check-file-system.ps1 [[-Drive] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-file-system.ps1 [[-Drive] <String>] [<CommonParameters>]
-Drive <String>
Specifies the drive to check

167
Docs/check-file.md Normal file
View File

@ -0,0 +1,167 @@
## The *check-file.ps1* Script
This PowerShell script determines and prints the file type of the given file.
## Parameters
```powershell
/home/mf/Repos/PowerShell/Scripts/check-file.ps1 [[-Path] <String>] [<CommonParameters>]
-Path <String>
Specifies the path to the file
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
## Example
```powershell
PS> ./check-file C:\my.exe
```
## Notes
Author: Markus Fleschutz | License: CC0
## Related Links
https://github.com/fleschutz/PowerShell
## Source Code
```powershell
<#
.SYNOPSIS
Checks a file
.DESCRIPTION
This PowerShell script determines and prints the file type of the given file.
.PARAMETER Path
Specifies the path to the file
.EXAMPLE
PS> ./check-file C:\my.exe
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$Path = "")
function Check-Header { param( $path )
$path = Resolve-Path $path
# Hexidecimal signatures for expected files
$known = @'
"Extension","Header"
"3gp","66 74 79 70 33 67"
"7z","37 7A BC AF 27 1C"
"8sv","38 53 56 58"
"8svx","46 4F 52 4D nn nn nn nn"
"acbm","46 4F 52 4D nn nn nn nn"
"aif","41 49 46 46"
"aiff","46 4F 52 4D nn nn nn nn"
"anbm","46 4F 52 4D nn nn nn nn"
"anim","46 4F 52 4D nn nn nn nn "
"asf","30 26 B2 75 8E 66 CF 11"
"avi","52 49 46 46 nn nn nn nn "
"bac","42 41 43 4B 4D 49 4B 45"
"bpg","42 50 47 FB"
"cab","4D 53 43 46"
"cin","80 2A 5F D7"
"class","CA FE BA BE"
"cmus","46 4F 52 4D nn nn nn nn"
"cr2","49 49 2A 00 10 00 00 00"
"crx","43 72 32 34"
"cwk","05 07 00 00 42 4F 42 4F"
"cwk","06 07 E1 00 42 4F 42 4F"
"dat","50 4D 4F 43 43 4D 4F 43"
"DBA","BE BA FE CA"
"DBA","00 01 42 44"
"dex","64 65 78 0A 30 33 35 00"
"djvu","41 54 26 54 46 4F 52 4D nn nn nn nn 44 4A 56"
"dmg","78 01 73 0D 62 62 60"
"doc","D0 CF 11 E0 A1 B1 1A E1"
"dpx","53 44 50 58"
"exr","76 2F 31 01"
"fax","46 41 58 58"
"faxx","46 4F 52 4D nn nn nn nn"
"fh8","41 47 44 33"
"fits","53 49 4D 50 4C 45 20 20"
"flac","66 4C 61 43"
"flif","46 4C 49 46"
"ftxt","46 4F 52 4D nn nn nn nn"
"gif","47 49 46 38 37 61"
"ico","00 00 01 00"
"idx","49 4E 44 58"
"iff","41 43 42 4D"
"iff","41 4E 42 4D"
"iff","41 4E 49 4D"
"iff","46 4F 52 4D nn nn nn nn"
"ilbm","46 4F 52 4D nn nn nn nn"
"iso","43 44 30 30 31"
"jpg","FF D8 FF DB"
"lbm","49 4C 42 4D"
"lz","4C 5A 49 50"
"lz4","04 22 4D 18"
"mid","4D 54 68 64"
"mkv","1A 45 DF A3"
"MLV","4D 4C 56 49"
"mus","43 4D 55 53"
"nes","4E 45 53 1A"
"ods","50 4B 05 06"
"ogg","4F 67 67 53"
"PDB","00 00 00 00 00 00 00 00"
"pdf","25 50 44 46"
"png","89 50 4E 47 0D 0A 1A 0A"
"ps","25 21 50 53"
"psd","38 42 50 53"
"rar","52 61 72 21 1A 07 00"
"rar","52 61 72 21 1A 07 01 00"
"smu","53 4D 55 53"
"smus","46 4F 52 4D nn nn nn nn"
"stg","4D 49 4C 20"
"tar","75 73 74 61 72 00 30 30"
"TDA","00 01 44 54"
"tif","49 49 2A 00"
"toast","45 52 02 00 00 00"
"tox","74 6F 78 33"
"txt","46 54 58 54"
"vsdx","50 4B 07 08"
"wav","52 49 46 46 nn nn nn nn"
"wma","A6 D9 00 AA 00 62 CE 6C"
"xar","78 61 72 21"
"yuv","59 55 56 4E"
"yuvn","46 4F 52 4D nn nn nn nn"
"zip","50 4B 03 04"
"epub","50 4B 03 04 0A 00 02 00"
'@ | ConvertFrom-Csv | sort {$_.header.length} -Descending
$known | % {$_.header = $_.header -replace '\s'}
try {
# Get content of each file (up to 4 bytes) for analysis
$HeaderAsHexString = New-Object System.Text.StringBuilder
[Byte[]](Get-Content -Path $path -TotalCount 4 -Encoding Byte -ea Stop) | % {
if (("{0:X}" -f $_).length -eq 1) {
$null = $HeaderAsHexString.Append('0{0:X}' -f $_)
} else {
$null = $HeaderAsHexString.Append('{0:X}' -f $_)
}
}
# Validate file header
# might change .startswith() to -match.
# might remove 'select -f 1' to get all possible matching extensions, or just somehow make it a better match.
$known | ? {$_.header.startswith($HeaderAsHexString.ToString())} | select -f 1 | % {$_.extension}
} catch {}
}
Check-Header $Path
```
*Generated by convert-ps2md.ps1 using the comment-based help of check-file.ps1*

62
Docs/check-firewall.md Normal file
View File

@ -0,0 +1,62 @@
## The *check-firewall.ps1* Script
This PowerShell script queries the status of the firewall and prints it.
## Parameters
```powershell
/home/mf/Repos/PowerShell/Scripts/check-firewall.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
## Example
```powershell
PS> ./check-firewall
✅ Firewall enabled
```
## Notes
Author: Markus Fleschutz | License: CC0
## Related Links
https://github.com/fleschutz/PowerShell
## Source Code
```powershell
<#
.SYNOPSIS
Checks the firewall status
.DESCRIPTION
This PowerShell script queries the status of the firewall and prints it.
.EXAMPLE
PS> ./check-firewall
✅ Firewall enabled
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
if ($IsLinux) {
Write-Host "✅ Firewall " -noNewline
& sudo ufw status
} else {
$enabled = (gp 'HKLM:\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile').EnableFirewall
if ($enabled) {
Write-Host "✅ Firewall enabled"
} else {
Write-Host "⚠️ Firewall disabled"
}
}
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-firewall.ps1*

View File

@ -16,11 +16,12 @@ check-gpu.ps1
```powershell
<#
.SYNOPSIS
Checks the GPU
Checks the GPU status
.DESCRIPTION
This PowerShell script queries GPU details and prints it.
This PowerShell script queries the GPU status and prints it.
.EXAMPLE
PS> ./check-gpu
✅ NVIDIA Quadro P400 GPU (2GB RAM, 3840x2160 pixels, 32 bit, 59 Hz, driver 31.0.15.1740, status OK)
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -52,8 +53,9 @@ try {
$RefreshRate = $Details.CurrentRefreshRate
$DriverVersion = $Details.DriverVersion
$Status = $Details.Status
"✅ GPU $($Model) ($(Bytes2String $RAMSize) RAM, $($ResWidth)x$($ResHeight) pixels, $BitsPerPixel bit, $RefreshRate Hz, driver $DriverVersion, status $Status)"
Write-Host "✅ $Model GPU ($(Bytes2String $RAMSize) RAM, $($ResWidth)x$($ResHeight) pixels, $BitsPerPixel bit, $RefreshRate Hz, driver $DriverVersion, status $Status)"
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1

View File

@ -1,10 +1,10 @@
## The *check-health.ps1* Script
This PowerShell script checks some health parameter of the local computer.
This PowerShell script checks and prints the system health of the local computer.
## Parameters
```powershell
check-health.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-health.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,6 +14,9 @@ check-health.ps1 [<CommonParameters>]
## Example
```powershell
PS> ./check-health
H A R D W A R E
✅ Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz (CPU0, 2701MHz, socket U3E1, 30.1°C)
...
```
@ -29,9 +32,12 @@ https://github.com/fleschutz/PowerShell
.SYNOPSIS
Checks the system health
.DESCRIPTION
This PowerShell script checks some health parameter of the local computer.
This PowerShell script checks and prints the system health of the local computer.
.EXAMPLE
PS> ./check-health
H A R D W A R E
✅ Intel(R) Core(TM) i5-6400 CPU @ 2.70GHz (CPU0, 2701MHz, socket U3E1, 30.1°C)
...
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -43,22 +49,25 @@ https://github.com/fleschutz/PowerShell
& "$PSScriptRoot/check-cpu.ps1"
& "$PSScriptRoot/check-ram.ps1"
& "$PSScriptRoot/check-gpu.ps1"
& "$PSScriptRoot/check-bios.ps1"
& "$PSScriptRoot/check-smart-devices.ps1"
& "$PSScriptRoot/check-drives.ps1"
& "$PSScriptRoot/check-battery.ps1"
" "
& "$PSScriptRoot/write-green.ps1" " S O F T W A R E"
& "$PSScriptRoot/check-bios.ps1"
& "$PSScriptRoot/check-os.ps1"
& "$PSScriptRoot/check-powershell.ps1"
& "$PSScriptRoot/check-apps.ps1"
& "$PSScriptRoot/check-uptime.ps1"
& "$PSScriptRoot/check-time-zone.ps1"
& "$PSScriptRoot/check-swap-space.ps1"
& "$PSScriptRoot/check-dns.ps1"
& "$PSScriptRoot/check-ping.ps1"
& "$PSScriptRoot/check-vpn.ps1"
& "$PSScriptRoot/check-pending-reboot.ps1"
" "
& "$PSScriptRoot/write-green.ps1" " N E T W O R K"
& "$PSScriptRoot/check-firewall"
& "$PSScriptRoot/check-ping.ps1"
& "$PSScriptRoot/check-dns.ps1"
& "$PSScriptRoot/check-vpn.ps1"
exit 0 # success
```

View File

@ -4,7 +4,7 @@ This PowerShell script checks the time until Indepence Day and replies by text-t
## Parameters
```powershell
check-independence-day.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-independence-day.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script checks the given IPv4 address for validity.
## Parameters
```powershell
check-ipv4-address.ps1 [[-Address] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-ipv4-address.ps1 [[-Address] <String>] [<CommonParameters>]
-Address <String>
Specifies the IPv4 address to check

View File

@ -4,7 +4,7 @@ This PowerShell script checks the given IPv6 address for validity
## Parameters
```powershell
check-ipv6-address.ps1 [[-Address] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-ipv6-address.ps1 [[-Address] <String>] [<CommonParameters>]
-Address <String>
Specifies the IPv6 address to check

View File

@ -4,7 +4,7 @@ This PowerShell script queries the position of the International Space Station (
## Parameters
```powershell
check-iss-position.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-iss-position.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -5,7 +5,7 @@ Supported MAC address formats are: 00:00:00:00:00:00 or 00-00-00-00-00-00 or 000
## Parameters
```powershell
check-mac-address.ps1 [[-MAC] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-mac-address.ps1 [[-MAC] <String>] [<CommonParameters>]
-MAC <String>
Specifies the MAC address to check

View File

@ -4,7 +4,7 @@ This PowerShell script determines and speaks the current month name by text-to-s
## Parameters
```powershell
check-month.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-month.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script determines the Moon phase and answers by text-to-speech (
## Parameters
```powershell
check-moon-phase.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-moon-phase.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script checks the time until New Year and replies by text-to-spe
## Parameters
```powershell
check-new-year.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-new-year.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -1,10 +1,10 @@
## The *check-os.ps1* Script
This PowerShell script queries and lists operating system details.
This PowerShell script queries the operating system status and prints it.
## Parameters
```powershell
check-os.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-os.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,6 +14,7 @@ check-os.ps1 [<CommonParameters>]
## Example
```powershell
PS> ./check-os
✅ Windows 10 Pro 64-bit (v10.0.19045, since 6/22/2021, S/N 00123-45678-15135-AAOEM, P/K AB123-CD456-EF789-GH000-WFR6P)
```
@ -27,11 +28,12 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Query OS details
Checks the OS status
.DESCRIPTION
This PowerShell script queries and lists operating system details.
This PowerShell script queries the operating system status and prints it.
.EXAMPLE
PS> ./check-os
✅ Windows 10 Pro 64-bit (v10.0.19045, since 6/22/2021, S/N 00123-45678-15135-AAOEM, P/K AB123-CD456-EF789-GH000-WFR6P)
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -40,10 +42,12 @@ https://github.com/fleschutz/PowerShell
try {
if ($IsLinux) {
"✅ $(uname -sr)"
$Name = $PSVersionTable.OS
if ([System.Environment]::Is64BitOperatingSystem) { $Arch = "64-bit" } else { $Arch = "32-bit" }
Write-Host "✅ $Name $Arch"
} else {
$OS = Get-WmiObject -class Win32_OperatingSystem
$Name = $OS.Caption
$Name = $OS.Caption -Replace "Microsoft Windows","Windows"
$Arch = $OS.OSArchitecture
$Version = $OS.Version
@ -52,7 +56,9 @@ try {
$BuildNo = $OSDetails.BuildNumber
$Serial = $OSDetails.SerialNumber
$InstallDate = $OSDetails.InstallDate
"✅ $($Name) ($Arch, v$Version, S/N $Serial) installed on $($InstallDate.ToShortDateString())"
$ProductKey = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" -Name BackupProductKeyDefault).BackupProductKeyDefault
Write-Host "✅ $Name $Arch (v$Version, since $($InstallDate.ToShortDateString()), S/N $Serial, P/K $ProductKey)"
}
exit 0 # success
} catch {

View File

@ -4,7 +4,7 @@ This PowerShell script checks the inbox of Outlook for new/unread mails.
## Parameters
```powershell
check-outlook.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-outlook.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

91
Docs/check-password.md Normal file
View File

@ -0,0 +1,91 @@
## The *check-password.ps1* Script
This PowerShell script checks the security status of the given password by haveibeenpwned.com
## Parameters
```powershell
/home/mf/Repos/PowerShell/Scripts/check-password.ps1 [[-password] <String>] [<CommonParameters>]
-password <String>
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
## Example
```powershell
PS> ./check-password qwerty
⚠️ Bad password, it's already listed in 10584568 known security breaches!
```
## Notes
Author: Markus Fleschutz | License: CC0
## Related Links
https://github.com/fleschutz/PowerShell
## Source Code
```powershell
<#
.SYNOPSIS
Checks a password
.DESCRIPTION
This PowerShell script checks the security status of the given password by haveibeenpwned.com
.EXAMPLE
PS> ./check-password qwerty
⚠️ Bad password, it's already listed in 10584568 known security breaches!
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$password = "")
function CalculateHashSHA1 ([string]$string) {
$sha1 = New-Object System.Security.Cryptography.SHA1CryptoServiceProvider
$encoder = New-Object System.Text.UTF8Encoding
$bytes = $encoder.GetBytes($string)
$hash = ($sha1.ComputeHash($bytes) | % { $_.ToString("X2") }) -join ''
return $hash
}
function Get-PasswordPwnCount { [CmdletBinding()] param([string]$pass)
$hash = CalculateHashSHA1 $pass
try {
$uri = "https://api.pwnedpasswords.com/range/$($hash.Substring(0,5))"
$list = -split (Invoke-RestMethod $uri -Verbose:($PSBoundParameters['Verbose'] -eq $true) -ErrorAction Stop) # split into separate strings
$pwn = $list | Select-String $hash.Substring(5,35) # grep
if ($pwn) { $count = [int] ($pwn.ToString().Split(':')[1]) } else { $count = 0 }
return $count
}
catch {
Write-Error "Error Calling HIBP API"
return $null
}
}
try {
if ($password -eq "") { $password = Read-Host "Enter the password" }
$NumBreaches = Get-PasswordPwnCount $password
if ($NumBreaches -eq 0) {
"👍 Password seems good, it's not listed in any known security breach (as of today)"
} else {
"⚠️ Bad password, it's listed already in $NumBreaches known security breaches!"
}
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-password.ps1*

View File

@ -18,7 +18,7 @@ check-pending-reboot.ps1
.SYNOPSIS
Check for pending reboots
.DESCRIPTION
This PowerShell script checks different registry keys and values to determine if a reboot is pending.
This PowerShell script queries pending reboots and prints it.
.EXAMPLE
./check-pending-reboot.ps1
.LINK
@ -36,47 +36,54 @@ function Test-RegistryValue { param([parameter(Mandatory=$true)][ValidateNotNull
}
}
$Reason = ""
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired") {
$Reason += ", found registry entry '...\WindowsUpdate\Auto Update\RebootRequired'"
try {
$Reason = ""
if ($IsLinux) {
if (Test-Path "/var/run/reboot-required") {
$Reason = "found /var/run/reboot-required"
}
} else {
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired") {
$Reason += ", '...\WindowsUpdate\Auto Update\RebootRequired'"
}
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\PostRebootReporting") {
$Reason += ", '...\WindowsUpdate\Auto Update\PostRebootReporting'"
}
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending") {
$Reason += ", '...\Component Based Servicing\RebootPending'"
}
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\ServerManager\CurrentRebootAttempts") {
$Reason += ", '...\ServerManager\CurrentRebootAttempts'"
}
if (Test-RegistryValue -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing" -Value "RebootInProgress") {
$Reason += ", '...\CurrentVersion\Component Based Servicing' with 'RebootInProgress'"
}
if (Test-RegistryValue -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing" -Value "PackagesPending") {
$Reason += ", '...\CurrentVersion\Component Based Servicing' with 'PackagesPending'"
}
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Value "PendingFileRenameOperations2") {
$Reason += ", '...\CurrentControlSet\Control\Session Manager' with 'PendingFileRenameOperations2'"
}
if (Test-RegistryValue -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" -Value "DVDRebootSignal") {
$Reason += ", '...\Windows\CurrentVersion\RunOnce' with 'DVDRebootSignal'"
}
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "JoinDomain") {
$Reason += ", '...\CurrentControlSet\Services\Netlogon' with 'JoinDomain'"
}
if (Test-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Netlogon" -Value "AvoidSpnSet") {
$Reason += ", '...\CurrentControlSet\Services\Netlogon' with 'AvoidSpnSet'"
}
}
if ($Reason -ne "") {
Write-Host "⚠️ Pending reboot (found $($Reason.substring(2)) in registry)"
} else {
Write-Host "✅ No pending reboot"
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
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,13 +1,13 @@
## The *check-ping.ps1* Script
This PowerShell script checks the ping latency from the local computer to some Internet hosts.
This PowerShell script checks the ping latency from the local computer to 9 popular hosts.
## Parameters
```powershell
check-ping.ps1 [[-hosts] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-ping.ps1 [[-hosts] <String>] [<CommonParameters>]
-hosts <String>
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)
Specifies the hosts to check, seperated by commata (default is: amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com)
Required? false
Position? 1
@ -23,7 +23,7 @@ check-ping.ps1 [[-hosts] <String>] [<CommonParameters>]
## Example
```powershell
PS> ./check-ping
✅ Ping is 25ms average, 13ms min, 109ms max.
✅ Ping latency is 13ms...109ms with 25ms average.
```
@ -39,12 +39,12 @@ https://github.com/fleschutz/PowerShell
.SYNOPSIS
Checks the ping latency
.DESCRIPTION
This PowerShell script checks the ping latency from the local computer to some Internet hosts.
This PowerShell script checks the ping latency from the local computer to 9 popular 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)
Specifies the hosts to check, seperated by commata (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.
✅ Ping latency is 13ms...109ms with 25ms average.
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -54,9 +54,9 @@ https://github.com/fleschutz/PowerShell
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..."
Write-Progress "⏳ Sending a ping to 9 popular hosts..."
$HostsArray = $hosts.Split(",")
$Pings = Test-Connection -count 1 -computerName $HostsArray
$Pings = Test-Connection -computerName $HostsArray -count 1
[int]$Min = 9999999
[int]$Max = [int]$Avg = 0
@ -67,7 +67,9 @@ try {
$Avg += $Latency
}
$Avg /= $Pings.count
"✅ Ping is $($Avg)ms average, $($Min)ms min, $($Max)ms max"
Write-Progress -Completed "."
Write-Host "✅ Ping latency is $($Min)ms...$($Max)ms with $($Avg)ms average"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,10 +1,10 @@
## The *check-powershell.ps1* Script
This PowerShell script queries and lists details of PowerShell.
This PowerShell script queries the PowerShell status and prints it.
## Parameters
```powershell
check-powershell.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-powershell.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,6 +14,7 @@ check-powershell.ps1 [<CommonParameters>]
## Example
```powershell
PS> ./check-powershell
✅ PowerShell Desktop edition 5.1.19041.2673 (10 modules, 1458 cmdlets, 172 aliases)
```
@ -27,11 +28,12 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Query PowerShell details
Check the PowerShell status
.DESCRIPTION
This PowerShell script queries and lists details of PowerShell.
This PowerShell script queries the PowerShell status and prints it.
.EXAMPLE
PS> ./check-powershell
✅ PowerShell Desktop edition 5.1.19041.2673 (10 modules, 1458 cmdlets, 172 aliases)
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -44,10 +46,10 @@ try {
$NumModules = (Get-Module).Count
$NumAliases = (Get-Alias).Count
if ($IsLinux) {
"✅ PowerShell $Version ($Edition edition) with $NumModules modules and $NumAliases aliases"
"✅ PowerShell $Edition edition $Version ($NumModules modules, $NumAliases aliases)"
} else {
$NumCmdlets = (Get-Command -Command-Type cmdlet).Count
"✅ PowerShell $Version ($Edition edition) with $NumModules modules, $NumCmdlets cmdlets and $NumAliases aliases"
"✅ PowerShell $Edition edition $Version ($NumModules modules, $NumCmdlets cmdlets, $NumAliases aliases)"
}
exit 0 # success
} catch {

73
Docs/check-ps1-file.md Normal file
View File

@ -0,0 +1,73 @@
## The *check-ps1-file.ps1* Script
This PowerShell script checks the given PowerShell file(s) for validity.
## Parameters
```powershell
/home/mf/Repos/PowerShell/Scripts/check-ps1-file.ps1 [[-filePattern] <String>] [<CommonParameters>]
-filePattern <String>
Specifies the file pattern to the PowerShell file(s)
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
```
## Example
```powershell
PS> ./check-ps1-file *.ps1
✔️ Valid PowerShell in myfile.ps1
```
## Notes
Author: Markus Fleschutz | License: CC0
## Related Links
https://github.com/fleschutz/PowerShell
## Source Code
```powershell
<#
.SYNOPSIS
Checks PowerShell file(s) for validity
.DESCRIPTION
This PowerShell script checks the given PowerShell file(s) for validity.
.PARAMETER filePattern
Specifies the file pattern to the PowerShell file(s)
.EXAMPLE
PS> ./check-ps1-file *.ps1
✔️ Valid PowerShell in myfile.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$filePattern = "")
try {
if ($filePattern -eq "" ) { $path = Read-Host "Enter the file pattern to the PowerShell file(s)" }
$files = Get-ChildItem $filePattern
foreach ($file in $files) {
$syntaxError = @()
[void][System.Management.Automation.Language.Parser]::ParseFile($file, [ref]$null, [ref]$syntaxError)
if ("$syntaxError" -ne "") { throw "$syntaxError" }
$basename = (Get-Item "$file").Basename
"✔️ Valid PowerShell in $basename"
}
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-ps1-file.ps1*

View File

@ -16,11 +16,12 @@ check-ram.ps1
```powershell
<#
.SYNOPSIS
Checks the RAM
Check the RAM status
.DESCRIPTION
This PowerShell script queries and prints details of the installed RAM.
This PowerShell script queries the status of the installed RAM and prints it.
.EXAMPLE
PS> ./check-ram
✅ 16GB DDR4 RAM @ 3200MHz (1.2V) in P0 CHANNEL A/DIMM 0 by Samsung
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -35,7 +36,7 @@ function GetRAMType { param([int]$Type)
7 { return "VRAM" }
8 { return "SRAM" }
10 { return "ROM" }
11 { return "Flash RAM" }
11 { return "Flash" }
12 { return "EEPROM" }
13 { return "FEPROM" }
14 { return "EPROM" }
@ -56,19 +57,35 @@ function GetRAMType { param([int]$Type)
}
}
function Bytes2String { param([int64]$Bytes)
if ($Bytes -lt 1024) { return "$Bytes bytes" }
$Bytes /= 1024
if ($Bytes -lt 1024) { return "$($Bytes)KB" }
$Bytes /= 1024
if ($Bytes -lt 1024) { return "$($Bytes)MB" }
$Bytes /= 1024
if ($Bytes -lt 1024) { return "$($Bytes)GB" }
$Bytes /= 1024
if ($Bytes -lt 1024) { return "$($Bytes)TB" }
$Bytes /= 1024
if ($Bytes -lt 1024) { return "$($Bytes)PB" }
$Bytes /= 1024
if ($Bytes -lt 1024) { return "$($Bytes)EB" }
}
try {
if ($IsLinux) {
# TODO
} else {
$Banks = Get-WmiObject -Class Win32_PhysicalMemory
foreach ($Bank in $Banks) {
$Capacity = $Bank.Capacity / (1024 * 1024 * 1024)
$Capacity = Bytes2String($Bank.Capacity)
$Type = GetRAMType $Bank.SMBIOSMemoryType
$Speed = $Bank.Speed
[float]$Voltage = $Bank.ConfiguredVoltage / 1000.0
$Manufacturer = $Bank.Manufacturer
$Location = "$($Bank.BankLabel)/$($Bank.DeviceLocator)"
"✅ $($Capacity)GB $($Type) at $($Location) ($($Speed)MHz, $($Voltage)V by $Manufacturer)"
Write-Host "✅ $Capacity $Type @ $($Speed)MHz ($($Voltage)V) in $Location by $Manufacturer"
}
}
exit 0 # success

View File

@ -4,7 +4,7 @@ This PowerShell script verifies the integrity of a local Git repository.
## Parameters
```powershell
check-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
-RepoDir <String>
Specifies the path to the Git repository (current working dir by default)
@ -22,7 +22,7 @@ check-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
## Example
```powershell
PS> ./check-repo
PS> ./check-repo C:\MyRepo
```
@ -36,13 +36,13 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Checks a Git repository
Checks a repo
.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
PS> ./check-repo C:\MyRepo
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -54,58 +54,51 @@ param([string]$RepoDir = "$PWD")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
Write-Host "⏳ (1/11) Searching for Git executable... " -noNewline
Write-Host "⏳ (1/10) 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
Write-Host "⏳ (2/10) Checking repository... " -noNewline
$FullPath = Resolve-Path "$RepoDir"
if (!(Test-Path "$FullPath" -pathType Container)) { throw "Can't access folder: $FullPath" }
"$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
Write-Host "⏳ (3/10) Querying 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
Write-Host "⏳ (4/10) Querying 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
Write-Host "⏳ (5/10) Fetching updates..."
& 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
Write-Host "⏳ (6/10) Querying 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..."
Write-Host "⏳ (7/10) Verifying 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..."
Write-Host "⏳ (8/10) Running 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
Write-Host "⏳ (9/10) Checking submodule status..."
& 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
Write-Host "⏳ (10/10) Checking repo status... " -noNewline
& git -C "$FullPath" status
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"
"✔️ successfully checked repo 📂$RepoDirName in $Elapsed sec"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -4,7 +4,7 @@ This PowerShell script checks the time until Saint Nicholas Day and replies by t
## Parameters
```powershell
check-santa.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-santa.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -16,12 +16,12 @@ check-smart-devices.ps1
```powershell
<#
.SYNOPSIS
Checks SMART devices
Checks the SMART device status
.DESCRIPTION
This PowerShell script queries S.M.A.R.T. HDD/SSD device details and prints it.
This PowerShell script queries the status of the SSD/HDD devices (supporting S.M.A.R.T.) and prints it.
.EXAMPLE
PS> ./check-smart-devices
✅ 1TB Samsung SSD 970 EVO via NVMe: 37°C, 2388 hours, 289x on, v2B2QEXE7, selftest passed
✅ 1TB Samsung SSD 970 EVO via NVMe (2388 hours, 289x on, v2B2QEXE7, 37°C, selftest passed)
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -45,18 +45,19 @@ function Bytes2String { param([int64]$Bytes)
}
try {
Write-Progress "⏳ Step 1/3 - Searching for smartctl executable..."
Write-Progress "⏳ (1/3) Searching for smartmontools..."
$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..."
Write-Progress "⏳ (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..."
Write-Progress "⏳ (3/3) Querying S.M.A.R.T devices..."
$Array = $Device.split(" ")
$Device = $Array[0]
if ("$Device" -eq "#") {
@ -81,7 +82,8 @@ try {
$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"
Write-Progress -completed " "
Write-Host "✅ $($Capacity)$ModelName via $Protocol ($Hours hours, $($PowerOn)x on, v$($Firmware), $($Temp)°C, selftest $Status)"
}
exit 0 # success
} catch {

View File

@ -4,7 +4,7 @@ This PowerShell script checks the given subnet mask for validity.
## Parameters
```powershell
check-subnet-mask.ps1 [[-address] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-subnet-mask.ps1 [[-address] <String>] [<CommonParameters>]
-address <String>
Specifies the subnet mask to check

View File

@ -1,10 +1,10 @@
## The *check-swap-space.ps1* Script
This PowerShell script checks the free swap space.
This PowerShell script queries the status of the swap space and prints it.
## Parameters
```powershell
check-swap-space.ps1 [[-MinLevel] <Int32>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-swap-space.ps1 [[-MinLevel] <Int32>] [<CommonParameters>]
-MinLevel <Int32>
Specifies the minimum level (10 GB by default)
@ -23,7 +23,7 @@ check-swap-space.ps1 [[-MinLevel] <Int32>] [<CommonParameters>]
## Example
```powershell
PS> ./check-swap-space
✅ Swap space uses 63 GB of 1856 GB.
✅ Swap space uses 63GB of 1856GB
```
@ -37,14 +37,14 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Checks the swap space
Checks the swap space status
.DESCRIPTION
This PowerShell script checks the free swap space.
This PowerShell script queries the status of the swap space and prints it.
.PARAMETER MinLevel
Specifies the minimum level (10 GB by default)
.EXAMPLE
PS> ./check-swap-space
✅ Swap space uses 63 GB of 1856 GB.
✅ Swap space uses 63GB of 1856GB
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -81,16 +81,19 @@ try {
}
}
if ($Total -eq 0) {
"⚠️ No swap space configured!"
$Reply = "⚠️ No swap space configured!"
} elseif ($Free -eq 0) {
$Reply = "⚠️ Swap space of $(MB2String $Total) is full!"
} elseif ($Free -lt $MinLevel) {
"⚠️ Only $(MB2String $Free) of $(MB2String $Total) swap space left to use!"
$Reply = "⚠️ Swap space of $(MB2String $Total) is nearly full ($(MB2String $Free) free)!"
} elseif ($Used -eq 0) {
"✅ Swap space with $(MB2String $Total) reserved"
$Reply = "✅ Swap space with $(MB2String $Total) reserved"
} elseif ($Used -lt $Free) {
"✅ Swap space uses $(MB2String $Used) of $(MB2String $Total)"
$Reply = "✅ Swap space uses $(MB2String $Used) of $(MB2String $Total)"
} else {
"✅ Swap space has $(MB2String $Free) of $(MB2String $Total) left to use"
$Reply = "✅ Swap space has $(MB2String $Free) of $(MB2String $Total) free"
}
Write-Host $Reply
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -5,7 +5,7 @@ It returns the number of broken symlinks as exit value.
## Parameters
```powershell
check-symlinks.ps1 [[-Folder] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-symlinks.ps1 [[-Folder] <String>] [<CommonParameters>]
-Folder <String>
Specifies the path to the folder
@ -69,7 +69,7 @@ try {
$item = Get-Item $path -ErrorAction Ignore
if (!$item) {
$NumBroken++
"Broken symlink #$($NumBroken): $Symlink ⭢ $Target"
"Symlink $Symlink to: $Target seems broken (#$NumBroken)"
}
}
$NumTotal++
@ -77,13 +77,11 @@ try {
[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"
"✔️ found no symlink at 📂$FullPath in $Elapsed sec."
} elseif ($NumBroken -eq 1) {
"✔️ found $NumBroken broken symlink out of $NumTotal at 📂$FullPath in $Elapsed sec"
"✔️ found $NumBroken broken symlink at 📂$FullPath in $Elapsed sec."
} else {
"✔️ found $NumBroken broken symlinks out of $NumTotal at 📂$FullPath in $Elapsed sec"
"✔️ found $NumBroken broken symlinks at 📂$FullPath in $Elapsed sec."
}
exit $NumBroken
} catch {

View File

@ -1,10 +1,10 @@
## The *check-time-zone.ps1* Script
This PowerShell script determines and prints the current time zone.
This PowerShell script queries the time zone and prints it.
## Parameters
```powershell
check-time-zone.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-time-zone.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,6 +14,7 @@ check-time-zone.ps1 [<CommonParameters>]
## Example
```powershell
PS> ./check-time-zone
✅ 11:13 AM (UTC + 01:00:00 W. Europe Standard Time + 01:00:00 daylight saving time)
```
@ -27,11 +28,12 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Checks the time zone setting
Checks the time zone
.DESCRIPTION
This PowerShell script determines and prints the current time zone.
This PowerShell script queries the time zone and prints it.
.EXAMPLE
PS> ./check-time-zone
✅ 11:13 AM (UTC + 01:00:00 W. Europe Standard Time + 01:00:00 daylight saving time)
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -42,8 +44,8 @@ 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)."
if ($TZ.SupportsDaylightSavingTime) { $DST="+ 01:00:00 daylight saving time" } else { $DST="" }
Write-Host "✅ $Time (UTC + $($TZ.BaseUtcOffset) $($TZ.Id) $DST)"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,10 +1,10 @@
## The *check-uptime.ps1* Script
This PowerShell script queries and prints the uptime.
This PowerShell script queries the computer's uptime and prints it.
## Parameters
```powershell
check-uptime.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-uptime.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -27,9 +27,9 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Check uptime
Checks the uptime
.DESCRIPTION
This PowerShell script queries and prints the uptime.
This PowerShell script queries the computer's uptime and prints it.
.EXAMPLE
PS> ./check-uptime
.LINK
@ -40,32 +40,33 @@ https://github.com/fleschutz/PowerShell
try {
if ($IsLinux) {
$Uptime = (get-uptime)
$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)
}
$Reply = "✅ Up for "
$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, "
}
$Hours = $Uptime.Hours
if ($Hours -eq "1") {
$Reply += "1 hour, "
} elseif ($Hours -ne "0") {
$Reply += "$Hours hours, "
}
$Minutes = $Uptime.Minutes
if ($Minutes -eq "1") {
$Reply += "1 minute"
} else {
$Reply += "$Minutes minutes"
}
"✅ $Reply."
Write-Host $Reply
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,10 +1,10 @@
## The *check-vpn.ps1* Script
This PowerShell script queries and prints the status of any VPN connection.
This PowerShell script queries the status of the VPN connections and prints it.
## Parameters
```powershell
check-vpn.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-vpn.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,6 +14,7 @@ check-vpn.ps1 [<CommonParameters>]
## Example
```powershell
PS> ./check-vpn
✅ Disconnected VPN 'NASA L2TP'
```
@ -27,11 +28,12 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Checks the VPN connection
Checks the VPN status
.DESCRIPTION
This PowerShell script queries and prints the status of any VPN connection.
This PowerShell script queries the status of the VPN connections and prints it.
.EXAMPLE
PS> ./check-vpn
✅ Disconnected VPN 'NASA L2TP'
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -43,13 +45,13 @@ try {
if ($IsLinux) {
# TODO
} else {
$Connections = (Get-VPNConnection)
$Connections = Get-VPNConnection
foreach($Connection in $Connections) {
"✅ VPN '$($Connection.Name)' is $($Connection.ConnectionStatus)"
"✅ $($Connection.ConnectionStatus) VPN '$($Connection.Name)'"
$NoVPN = $false
}
}
if ($NoVPN) { "⚠️ No VPN connection" }
if ($NoVPN) { "⚠️ No VPN" }
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -4,7 +4,7 @@ This PowerShell script checks the current weather report.
## Parameters
```powershell
check-weather.ps1 [[-location] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-weather.ps1 [[-location] <String>] [<CommonParameters>]
-location <String>
Specifies the location to use (determined automatically per default)

View File

@ -4,7 +4,7 @@ This PowerShell script determines and speaks the current week number by text-to-
## Parameters
```powershell
check-week.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-week.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script determines the current wind conditions and replies by tex
## Parameters
```powershell
check-wind.ps1 [[-location] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-wind.ps1 [[-location] <String>] [<CommonParameters>]
-location <String>
Specifies the location to use (determined automatically per default)

View File

@ -4,7 +4,7 @@ This PowerShell script checks the validity of the Windows system files. It requi
## Parameters
```powershell
check-windows-system-files.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-windows-system-files.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script checks the given XML file for validity.
## Parameters
```powershell
check-xml-file.ps1 [[-file] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/check-xml-file.ps1 [[-file] <String>] [<CommonParameters>]
-file <String>
Specifies the path to the XML file to check

View File

@ -1,14 +1,14 @@
## The *clean-repo.ps1* Script
This PowerShell script deletes all untracked files and folders in a Git repository (including submodules).
This PowerShell script deletes all untracked files and folders in a local Git repository (including submodules).
NOTE: To be used with care! This cannot be undone!
## Parameters
```powershell
clean-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/clean-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
-RepoDir <String>
Specifies the path to the Git repository
Specifies the file path to the local Git repository
Required? false
Position? 1
@ -37,12 +37,12 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Clean a repository
Cleans a repo
.DESCRIPTION
This PowerShell script deletes all untracked files and folders in a Git repository (including submodules).
This PowerShell script deletes all untracked files and folders in a local Git repository (including submodules).
NOTE: To be used with care! This cannot be undone!
.PARAMETER RepoDir
Specifies the path to the Git repository
Specifies the file path to the local Git repository
.EXAMPLE
PS> ./clean-repo C:\MyRepo
.LINK
@ -56,28 +56,28 @@ param([string]$RepoDir = "$PWD")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
Write-Host "⏳ (1/4) Searching for Git executable... " -noNewline
Write-Host "⏳ (1/4) Searching for Git executable... " -noNewline
& git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
$RepoDirName = (Get-Item "$RepoDir").Name
"⏳ (2/4) Checking Git repository 📂$RepoDirName..."
"⏳ (2/4) Checking repository... 📂$RepoDir"
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access folder '$RepoDir' - maybe a typo or missing folder permissions?" }
$RepoDirName = (Get-Item "$RepoDir").Name
"⏳ (3/4) Removing untracked files in repository..."
"⏳ (3/4) Removing repo's untracked files..."
& 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..."
Write-Warning "'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..."
"⏳ (4/4) Removing submodules' untracked files..."
& 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 Git repository 📂$RepoDirName in $Elapsed sec"
"✔️ cleaned repo 📂$RepoDirName in $Elapsed sec"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -4,7 +4,7 @@ This PowerShell script cleans all Git repositories in a folder from untracked fi
## Parameters
```powershell
clean-repos.ps1 [[-ParentDir] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/clean-repos.ps1 [[-ParentDir] <String>] [<CommonParameters>]
-ParentDir <String>
Specifies the path to the parent folder

View File

@ -4,7 +4,7 @@ This PowerShell script clears the DNS client cache of the local computer.
## Parameters
```powershell
clear-dns-cache.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/clear-dns-cache.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -5,7 +5,7 @@ IMPORTANT NOTE: this cannot be undo!
## Parameters
```powershell
clear-recycle-bin.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/clear-recycle-bin.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -1,12 +1,13 @@
## The *clone-repos.ps1* Script
This PowerShell script clones well-known Git repositories into a folder.
This PowerShell script clones popular Git repositories into a target directory.
## Parameters
```powershell
clone-repos.ps1 [[-FolderPath] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/clone-repos.ps1 [[-TargetDir] <String>] [<CommonParameters>]
-FolderPath <String>
-TargetDir <String>
Specifies the file path to the target directory (current working directory by default)
Required? false
Position? 1
@ -35,11 +36,11 @@ https://github.com/fleschutz/PowerShell
```powershell
<#
.SYNOPSIS
Clones Git repositories
Clones popular repos
.DESCRIPTION
This PowerShell script clones well-known Git repositories into a folder.
.PARAMETER folder
Specifies the target folder (default is current working directory)
This PowerShell script clones popular Git repositories into a target directory.
.PARAMETER targetDir
Specifies the file path to the target directory (current working directory by default)
.EXAMPLE
PS> ./clone-repos C:\Repos
.LINK
@ -48,58 +49,53 @@ https://github.com/fleschutz/PowerShell
Author: Markus Fleschutz | License: CC0
#>
param([string]$FolderPath = "$PWD")
param([string]$TargetDir = "$PWD")
try {
$StopWatch = [system.diagnostics.stopwatch]::startNew()
Write-Host "⏳ (1) Searching for Git executable... " -noNewline
Write-Host "⏳ (1) Searching for Git executable... " -noNewline
& git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
Write-Host "⏳ (2) Loading database table from Data/git-repos.csv... " -noNewline
$Table = Import-CSV "$PSScriptRoot/../Data/git-repos.csv"
Write-Host "⏳ (2) Loading Data/popular-git-repos.csv... " -noNewline
$Table = Import-CSV "$PSScriptRoot/../Data/popular-git-repos.csv"
$NumEntries = $Table.count
Write-Host "$NumEntries entries found"
Write-Host "$NumEntries Git repos listed"
$ParentFolderName = (Get-Item "$FolderPath").Name
"⏳ (3) Checking target folder 📂$ParentFolderName..."
if (-not(Test-Path "$FolderPath" -pathType container)) { throw "Can't access directory: $FolderPath" }
$TargetDirName = (Get-Item "$TargetDir").Name
Write-Host "⏳ (3) Checking target folder... 📂$TargetDirName"
if (-not(Test-Path "$TargetDir" -pathType container)) { throw "Can't access directory: $TargetDir" }
[int]$Step = 3
[int]$Cloned = 0
[int]$Skipped = 0
foreach($Row in $Table) {
[string]$Group = $Row.GROUP
[string]$FolderName = $Row.FOLDERNAME
[string]$Category = $Row.CATEGORY
[string]$Branch = $Row.BRANCH
[string]$Full = $Row.FULL
[string]$URL = $Row.URL
$Step++
if (Test-Path "$FolderPath/$FolderName" -pathType container) {
"⏳ ($Step/$($NumEntries + 4)) Skipping 📂$($FolderName), it exists already..."
if (Test-Path "$TargetDir/$FolderName" -pathType container) {
"⏳ ($Step/$($NumEntries + 4)) Skipping existing 📂$FolderName ($Category)..."
$Skipped++
continue
}
if ($Full -eq "yes") {
"⏳ ($Step/$($NumEntries + 4)) Cloning into 📂$($FolderName) ($Branch branch with full history)..."
& git clone --branch "$Branch" --recurse-submodules "$URL" "$FolderPath/$FolderName"
"⏳ ($Step/$($NumEntries + 4)) Cloning into 📂$FolderName ($Category) - $Branch branch with full history..."
& git clone --branch "$Branch" --recurse-submodules "$URL" "$TargetDir/$FolderName"
if ($lastExitCode -ne "0") { throw "'git clone --branch $Branch $URL' failed with exit code $lastExitCode" }
} else {
"⏳ ($Step/$($NumEntries + 4)) Cloning $Branch branch into 📂$FolderName..."
& git clone --branch "$Branch" --single-branch --recurse-submodules "$URL" "$FolderPath/$FolderName"
"⏳ ($Step/$($NumEntries + 4)) Cloning into 📂$FolderName ($Category) - $Branch branch only..."
& git clone --branch "$Branch" --single-branch --recurse-submodules "$URL" "$TargetDir/$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) {
"✔️ 1 Git repository cloned into 📂$ParentFolderName in $Elapsed sec ($Skipped skipped)."
} else {
"✔️ $Cloned Git repos cloned into 📂$ParentFolderName in $Elapsed sec ($Skipped skipped)."
}
"✔️ cloned $Cloned of $NumEntries Git repos into folder 📂$TargetDirName in $Elapsed sec"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -4,7 +4,7 @@ This PowerShell script closes the calculator application gracefully.
## Parameters
```powershell
close-calculator.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-calculator.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -38,11 +38,7 @@ https://github.com/fleschutz/PowerShell
Author: Markus Fleschutz | License: CC0
#>
TaskKill /im Calculator.exe /f /t
if ($lastExitCode -ne "0") {
& "$PSScriptRoot/speak-english.ps1" "Sorry, calculator isn't running."
exit 1
}
Stop-Process -name "CalculatorApp"
exit 0 # success
```

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Google Chrome Web browser gracefully.
## Parameters
```powershell
close-chrome.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-chrome.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes Microsoft's Cortana application gracefully.
## Parameters
```powershell
close-cortana.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-cortana.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Microsoft Edge Web browser gracefully.
## Parameters
```powershell
close-edge.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-edge.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Microsoft File Explorer application gracefully
## Parameters
```powershell
close-file-explorer.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-file-explorer.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Mozilla Firefox Web browser gracefully.
## Parameters
```powershell
close-firefox.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-firefox.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Git Extensions application gracefully.
## Parameters
```powershell
close-git-extensions.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-git-extensions.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Windows Screen Magnifier application gracefull
## Parameters
```powershell
close-magnifier.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-magnifier.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Microsoft Paint application gracefully.
## Parameters
```powershell
close-microsoft-paint.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-microsoft-paint.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Microsoft Store application gracefully.
## Parameters
```powershell
close-microsoft-store.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-microsoft-store.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Netflix application gracefully.
## Parameters
```powershell
close-netflix.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-netflix.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Notepad application gracefully.
## Parameters
```powershell
close-note-pad.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-note-pad.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the OBS Studio application gracefully.
## Parameters
```powershell
close-obs-studio.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-obs-studio.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the OneCalendar application gracefully.
## Parameters
```powershell
close-one-calendar.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-one-calendar.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Microsoft Outlook email application gracefully
## Parameters
```powershell
close-outlook.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-outlook.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Paint 3D application gracefully.
## Parameters
```powershell
close-paint-three-d.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-paint-three-d.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -4,7 +4,7 @@ This PowerShell script closes a program's processes gracefully.
## Parameters
```powershell
close-program.ps1 [[-FullProgramName] <String>] [[-ProgramName] <String>] [[-ProgramAliasName] <String>] [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-program.ps1 [[-FullProgramName] <String>] [[-ProgramName] <String>] [[-ProgramAliasName] <String>] [<CommonParameters>]
-FullProgramName <String>
Specifies the full program name
@ -87,7 +87,7 @@ try {
foreach ($Process in $Processes) {
$Process.CloseMainWindow() | Out-Null
}
start-sleep -milliseconds 100
Start-Sleep -milliseconds 100
stop-process -name $ProgramName -force -errorAction 'silentlycontinue'
} else {
$Processes = get-process -name $ProgramAliasName -errorAction 'silentlycontinue'
@ -97,7 +97,7 @@ try {
foreach ($Process in $Processes) {
$_.CloseMainWindow() | Out-Null
}
start-sleep -milliseconds 100
Start-Sleep -milliseconds 100
stop-process -name $ProgramName -force -errorAction 'silentlycontinue'
}
if ($($Processes.Count) -eq 1) {

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Serenade.ai application gracefully.
## Parameters
```powershell
close-serenade.ps1 [<CommonParameters>]
/home/mf/Repos/PowerShell/Scripts/close-serenade.ps1 [<CommonParameters>]
[<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

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