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 ## Parameters
```powershell ```powershell
add-firewall-rules.ps1 [[-PathToExecutables] <String>] [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/add-firewall-rules.ps1 [[-PathToExecutables] <String>] [<CommonParameters>]
-PathToExecutables <String> -PathToExecutables <String>
Specifies the path to the executables Specifies the path to the executables

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the user's OneDrive fold
## Parameters ## Parameters
```powershell ```powershell
cd-onedrive.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-onedrive.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
cd-pics.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-pics.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 { 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)) { if (-not(Test-Path "$Path" -pathType container)) {
throw "Recycle bin folder at 📂$Path doesn't exist (yet)" 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 ## Parameters
```powershell ```powershell
cd-repos.ps1 [[-Subpath] <String>] [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-repos.ps1 [[-Subpath] <String>] [<CommonParameters>]
-Subpath <String> -Subpath <String>
Specifies an additional relative subpath (optional) Specifies an additional relative subpath (optional)
@ -61,7 +61,7 @@ try {
} elseif (Test-Path "$HOME/source/repos" -pathType Container) { # try Visual Studio default } elseif (Test-Path "$HOME/source/repos" -pathType Container) { # try Visual Studio default
$Path = "$HOME/source/repos/$Subpath" $Path = "$HOME/source/repos/$Subpath"
} else { } 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)) { if (-not(Test-Path "$Path" -pathType Container)) {
throw "The path to 📂$Path doesn't exist (yet)." 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 ## Parameters
```powershell ```powershell
cd-root.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-root.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

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

View File

@ -4,7 +4,7 @@ This PowerShell script changes the working directory to the PowerShell scripts f
## Parameters ## Parameters
```powershell ```powershell
cd-scripts.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-scripts.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
cd-ssh.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-ssh.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -41,13 +41,13 @@ https://github.com/fleschutz/PowerShell
#> #>
try { try {
$Path = Resolve-Path "$HOME/.ssh" $Path = Resolve-Path "~/.ssh"
if (-not(Test-Path "$Path" -pathType container)) { if (Test-Path "$Path" -pathType container) {
throw "SSH folder at 📂$Path doesn't exist (yet)" Set-Location "$Path"
"📂$Path"
exit 0 # success
} }
Set-Location "$Path" throw "User's SSH folder at 📂$Path doesn't exist (yet)"
"📂$Path"
exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1 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 ## Parameters
```powershell ```powershell
cd-up.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-up.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
cd-up2.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-up2.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
cd-up3.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-up3.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
cd-up4.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-up4.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
cd-users.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-users.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
cd-videos.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-videos.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
cd-windows.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/cd-windows.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
change-wallpaper.ps1 [[-Category] <String>] [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/change-wallpaper.ps1 [[-Category] <String>] [<CommonParameters>]
-Category <String> -Category <String>
Specifies the photo category (beach, city, ...) Specifies the photo category (beach, city, ...)

View File

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

View File

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

View File

@ -1,10 +1,10 @@
## The *check-bios.ps1* Script ## 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 ## Parameters
```powershell ```powershell
check-bios.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-bios.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,7 +14,7 @@ check-bios.ps1 [<CommonParameters>]
## Example ## Example
```powershell ```powershell
PS> ./check-bios 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 ```powershell
<# <#
.SYNOPSIS .SYNOPSIS
Checks BIOS details Checks the BIOS status
.DESCRIPTION .DESCRIPTION
This PowerShell script queries BIOS details and prints it. This PowerShell script queries the BIOS status and prints it.
.EXAMPLE .EXAMPLE
PS> ./check-bios 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 .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -41,16 +41,25 @@ https://github.com/fleschutz/PowerShell
#> #>
try { try {
Write-Progress "Querying BIOS details..."
if ($IsLinux) { 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 { } else {
Write-Progress "⏳ Querying BIOS..."
$BIOS = Get-CimInstance -ClassName Win32_BIOS $BIOS = Get-CimInstance -ClassName Win32_BIOS
$Manufacturer = $BIOS.Manufacturer $Model = $BIOS.Name.Trim()
$Model = $BIOS.Name $Manufacturer = $BIOS.Manufacturer.Trim()
$Serial = $BIOS.SerialNumber $Serial = $BIOS.SerialNumber.Trim()
$Version = $BIOS.Version $Version = $BIOS.Version.Trim()
"✅ BIOS $Model by $Manufacturer (S/N $Serial, version $Version)" Write-Progress -completed "."
Write-Host "✅ BIOS $Model by $Manufacturer (version $Version, S/N $Serial)"
} }
exit 0 # success exit 0 # success
} catch { } catch {

View File

@ -16,12 +16,12 @@ check-cpu.ps1
```powershell ```powershell
<# <#
.SYNOPSIS .SYNOPSIS
Queries and prints CPU details Checks the CPU status
.DESCRIPTION .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 .EXAMPLE
PS> ./check-cpu 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 .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -45,29 +45,54 @@ function GetCPUTemperatureInCelsius {
return $Temp; 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 { try {
Write-Progress "Querying CPU details ..." Write-Progress "⏳ Querying CPU details..."
$Status = "✅"
$Celsius = GetCPUTemperatureInCelsius $Celsius = GetCPUTemperatureInCelsius
if ($Celsius -eq 99999.9) { if ($Celsius -eq 99999.9) {
$Temp = "no temp" $Temp = "no temp"
} elseif ($Celsius -gt 50) { } elseif ($Celsius -gt 50) {
$Temp = "⚠️$($Celsius)°C" $Temp = "$($Celsius)°C"
$Status = "⚠"
} elseif ($Celsius -lt 0) { } elseif ($Celsius -lt 0) {
$Temp = "⚠️$($Celsius)°C" $Temp = "$($Celsius)°C"
$Status = "⚠"
} else { } else {
$Temp = "$($Celsius)°C" $Temp = "$($Celsius)°C"
} }
$Arch = GetProcessorArchitecture
if ($IsLinux) { if ($IsLinux) {
"✅ CPU has $Temp" $CPUName = "$Arch CPU"
$Arch = ""
$DeviceID = ""
$Speed = ""
$Socket = ""
} else { } else {
$Details = Get-WmiObject -Class Win32_Processor $Details = Get-WmiObject -Class Win32_Processor
$CPUName = $Details.Name.trim() $CPUName = $Details.Name.trim()
$DeviceID = $Details.DeviceID $Arch = "$Arch, "
$Speed = "$($Details.MaxClockSpeed)MHz" $DeviceID = "$($Details.DeviceID), "
$Socket = $Details.SocketDesignation $Speed = "$($Details.MaxClockSpeed)MHz, "
"✅ CPU $CPUName ($DeviceID, $Speed, socket $Socket, $Temp)" $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 exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ 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 ## Parameters
```powershell ```powershell
check-day.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-day.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

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

View File

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

View File

@ -4,7 +4,7 @@ This PowerShell script checks the time until Easter Sunday and replies by text-t
## Parameters ## Parameters
```powershell ```powershell
check-easter-sunday.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-easter-sunday.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
check-file-system.ps1 [[-Drive] <String>] [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-file-system.ps1 [[-Drive] <String>] [<CommonParameters>]
-Drive <String> -Drive <String>
Specifies the drive to check 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 ```powershell
<# <#
.SYNOPSIS .SYNOPSIS
Checks the GPU Checks the GPU status
.DESCRIPTION .DESCRIPTION
This PowerShell script queries GPU details and prints it. This PowerShell script queries the GPU status and prints it.
.EXAMPLE .EXAMPLE
PS> ./check-gpu PS> ./check-gpu
✅ NVIDIA Quadro P400 GPU (2GB RAM, 3840x2160 pixels, 32 bit, 59 Hz, driver 31.0.15.1740, status OK)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -52,8 +53,9 @@ try {
$RefreshRate = $Details.CurrentRefreshRate $RefreshRate = $Details.CurrentRefreshRate
$DriverVersion = $Details.DriverVersion $DriverVersion = $Details.DriverVersion
$Status = $Details.Status $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 { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1 exit 1

View File

@ -1,10 +1,10 @@
## The *check-health.ps1* Script ## 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 ## Parameters
```powershell ```powershell
check-health.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-health.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,6 +14,9 @@ check-health.ps1 [<CommonParameters>]
## Example ## Example
```powershell ```powershell
PS> ./check-health 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 .SYNOPSIS
Checks the system health Checks the system health
.DESCRIPTION .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 .EXAMPLE
PS> ./check-health 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 .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -43,22 +49,25 @@ https://github.com/fleschutz/PowerShell
& "$PSScriptRoot/check-cpu.ps1" & "$PSScriptRoot/check-cpu.ps1"
& "$PSScriptRoot/check-ram.ps1" & "$PSScriptRoot/check-ram.ps1"
& "$PSScriptRoot/check-gpu.ps1" & "$PSScriptRoot/check-gpu.ps1"
& "$PSScriptRoot/check-bios.ps1"
& "$PSScriptRoot/check-smart-devices.ps1" & "$PSScriptRoot/check-smart-devices.ps1"
& "$PSScriptRoot/check-drives.ps1" & "$PSScriptRoot/check-drives.ps1"
& "$PSScriptRoot/check-battery.ps1" & "$PSScriptRoot/check-battery.ps1"
" " " "
& "$PSScriptRoot/write-green.ps1" " S O F T W A R E" & "$PSScriptRoot/write-green.ps1" " S O F T W A R E"
& "$PSScriptRoot/check-bios.ps1"
& "$PSScriptRoot/check-os.ps1" & "$PSScriptRoot/check-os.ps1"
& "$PSScriptRoot/check-powershell.ps1" & "$PSScriptRoot/check-powershell.ps1"
& "$PSScriptRoot/check-apps.ps1" & "$PSScriptRoot/check-apps.ps1"
& "$PSScriptRoot/check-uptime.ps1" & "$PSScriptRoot/check-uptime.ps1"
& "$PSScriptRoot/check-time-zone.ps1" & "$PSScriptRoot/check-time-zone.ps1"
& "$PSScriptRoot/check-swap-space.ps1" & "$PSScriptRoot/check-swap-space.ps1"
& "$PSScriptRoot/check-dns.ps1"
& "$PSScriptRoot/check-ping.ps1"
& "$PSScriptRoot/check-vpn.ps1"
& "$PSScriptRoot/check-pending-reboot.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 exit 0 # success
``` ```

View File

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

View File

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

View File

@ -4,7 +4,7 @@ This PowerShell script queries the position of the International Space Station (
## Parameters ## Parameters
```powershell ```powershell
check-iss-position.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-iss-position.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
check-mac-address.ps1 [[-MAC] <String>] [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-mac-address.ps1 [[-MAC] <String>] [<CommonParameters>]
-MAC <String> -MAC <String>
Specifies the MAC address to check 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 ## Parameters
```powershell ```powershell
check-month.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-month.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
check-moon-phase.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-moon-phase.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
check-new-year.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-new-year.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -1,10 +1,10 @@
## The *check-os.ps1* Script ## 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 ## Parameters
```powershell ```powershell
check-os.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-os.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,6 +14,7 @@ check-os.ps1 [<CommonParameters>]
## Example ## Example
```powershell ```powershell
PS> ./check-os 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 ```powershell
<# <#
.SYNOPSIS .SYNOPSIS
Query OS details Checks the OS status
.DESCRIPTION .DESCRIPTION
This PowerShell script queries and lists operating system details. This PowerShell script queries the operating system status and prints it.
.EXAMPLE .EXAMPLE
PS> ./check-os 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 .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -40,10 +42,12 @@ https://github.com/fleschutz/PowerShell
try { try {
if ($IsLinux) { if ($IsLinux) {
"✅ $(uname -sr)" $Name = $PSVersionTable.OS
if ([System.Environment]::Is64BitOperatingSystem) { $Arch = "64-bit" } else { $Arch = "32-bit" }
Write-Host "✅ $Name $Arch"
} else { } else {
$OS = Get-WmiObject -class Win32_OperatingSystem $OS = Get-WmiObject -class Win32_OperatingSystem
$Name = $OS.Caption $Name = $OS.Caption -Replace "Microsoft Windows","Windows"
$Arch = $OS.OSArchitecture $Arch = $OS.OSArchitecture
$Version = $OS.Version $Version = $OS.Version
@ -52,7 +56,9 @@ try {
$BuildNo = $OSDetails.BuildNumber $BuildNo = $OSDetails.BuildNumber
$Serial = $OSDetails.SerialNumber $Serial = $OSDetails.SerialNumber
$InstallDate = $OSDetails.InstallDate $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 exit 0 # success
} catch { } catch {

View File

@ -4,7 +4,7 @@ This PowerShell script checks the inbox of Outlook for new/unread mails.
## Parameters ## Parameters
```powershell ```powershell
check-outlook.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-outlook.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 .SYNOPSIS
Check for pending reboots Check for pending reboots
.DESCRIPTION .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 .EXAMPLE
./check-pending-reboot.ps1 ./check-pending-reboot.ps1
.LINK .LINK
@ -36,47 +36,54 @@ function Test-RegistryValue { param([parameter(Mandatory=$true)][ValidateNotNull
} }
} }
$Reason = "" try {
$Reason = ""
if (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired") { if ($IsLinux) {
$Reason += ", found registry entry '...\WindowsUpdate\Auto Update\RebootRequired'" 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* *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 ## 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 ## Parameters
```powershell ```powershell
check-ping.ps1 [[-hosts] <String>] [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-ping.ps1 [[-hosts] <String>] [<CommonParameters>]
-hosts <String> -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 Required? false
Position? 1 Position? 1
@ -23,7 +23,7 @@ check-ping.ps1 [[-hosts] <String>] [<CommonParameters>]
## Example ## Example
```powershell ```powershell
PS> ./check-ping 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 .SYNOPSIS
Checks the ping latency Checks the ping latency
.DESCRIPTION .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 .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 .EXAMPLE
PS> ./check-ping PS> ./check-ping
✅ Ping is 25ms average, 13ms min, 109ms max. ✅ Ping latency is 13ms...109ms with 25ms average.
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .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") param([string]$hosts = "amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,google.com,live.com,twitter.com,youtube.com")
try { try {
Write-Progress "⏳ Pinging $hosts..." Write-Progress "⏳ Sending a ping to 9 popular hosts..."
$HostsArray = $hosts.Split(",") $HostsArray = $hosts.Split(",")
$Pings = Test-Connection -count 1 -computerName $HostsArray $Pings = Test-Connection -computerName $HostsArray -count 1
[int]$Min = 9999999 [int]$Min = 9999999
[int]$Max = [int]$Avg = 0 [int]$Max = [int]$Avg = 0
@ -67,7 +67,9 @@ try {
$Avg += $Latency $Avg += $Latency
} }
$Avg /= $Pings.count $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 exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -1,10 +1,10 @@
## The *check-powershell.ps1* Script ## 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 ## Parameters
```powershell ```powershell
check-powershell.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-powershell.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
@ -14,6 +14,7 @@ check-powershell.ps1 [<CommonParameters>]
## Example ## Example
```powershell ```powershell
PS> ./check-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 ```powershell
<# <#
.SYNOPSIS .SYNOPSIS
Query PowerShell details Check the PowerShell status
.DESCRIPTION .DESCRIPTION
This PowerShell script queries and lists details of PowerShell. This PowerShell script queries the PowerShell status and prints it.
.EXAMPLE .EXAMPLE
PS> ./check-powershell PS> ./check-powershell
✅ PowerShell Desktop edition 5.1.19041.2673 (10 modules, 1458 cmdlets, 172 aliases)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -44,10 +46,10 @@ try {
$NumModules = (Get-Module).Count $NumModules = (Get-Module).Count
$NumAliases = (Get-Alias).Count $NumAliases = (Get-Alias).Count
if ($IsLinux) { if ($IsLinux) {
"✅ PowerShell $Version ($Edition edition) with $NumModules modules and $NumAliases aliases" "✅ PowerShell $Edition edition $Version ($NumModules modules, $NumAliases aliases)"
} else { } else {
$NumCmdlets = (Get-Command -Command-Type cmdlet).Count $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 exit 0 # success
} catch { } 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 ```powershell
<# <#
.SYNOPSIS .SYNOPSIS
Checks the RAM Check the RAM status
.DESCRIPTION .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 .EXAMPLE
PS> ./check-ram PS> ./check-ram
✅ 16GB DDR4 RAM @ 3200MHz (1.2V) in P0 CHANNEL A/DIMM 0 by Samsung
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -35,7 +36,7 @@ function GetRAMType { param([int]$Type)
7 { return "VRAM" } 7 { return "VRAM" }
8 { return "SRAM" } 8 { return "SRAM" }
10 { return "ROM" } 10 { return "ROM" }
11 { return "Flash RAM" } 11 { return "Flash" }
12 { return "EEPROM" } 12 { return "EEPROM" }
13 { return "FEPROM" } 13 { return "FEPROM" }
14 { return "EPROM" } 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 { try {
if ($IsLinux) { if ($IsLinux) {
# TODO # TODO
} else { } else {
$Banks = Get-WmiObject -Class Win32_PhysicalMemory $Banks = Get-WmiObject -Class Win32_PhysicalMemory
foreach ($Bank in $Banks) { foreach ($Bank in $Banks) {
$Capacity = $Bank.Capacity / (1024 * 1024 * 1024) $Capacity = Bytes2String($Bank.Capacity)
$Type = GetRAMType $Bank.SMBIOSMemoryType $Type = GetRAMType $Bank.SMBIOSMemoryType
$Speed = $Bank.Speed $Speed = $Bank.Speed
[float]$Voltage = $Bank.ConfiguredVoltage / 1000.0 [float]$Voltage = $Bank.ConfiguredVoltage / 1000.0
$Manufacturer = $Bank.Manufacturer $Manufacturer = $Bank.Manufacturer
$Location = "$($Bank.BankLabel)/$($Bank.DeviceLocator)" $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 exit 0 # success

View File

@ -4,7 +4,7 @@ This PowerShell script verifies the integrity of a local Git repository.
## Parameters ## Parameters
```powershell ```powershell
check-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
-RepoDir <String> -RepoDir <String>
Specifies the path to the Git repository (current working dir by default) Specifies the path to the Git repository (current working dir by default)
@ -22,7 +22,7 @@ check-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
## Example ## Example
```powershell ```powershell
PS> ./check-repo PS> ./check-repo C:\MyRepo
``` ```
@ -36,13 +36,13 @@ https://github.com/fleschutz/PowerShell
```powershell ```powershell
<# <#
.SYNOPSIS .SYNOPSIS
Checks a Git repository Checks a repo
.DESCRIPTION .DESCRIPTION
This PowerShell script verifies the integrity of a local Git repository. This PowerShell script verifies the integrity of a local Git repository.
.PARAMETER RepoDir .PARAMETER RepoDir
Specifies the path to the Git repository (current working dir by default) Specifies the path to the Git repository (current working dir by default)
.EXAMPLE .EXAMPLE
PS> ./check-repo PS> ./check-repo C:\MyRepo
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -54,58 +54,51 @@ param([string]$RepoDir = "$PWD")
try { try {
$StopWatch = [system.diagnostics.stopwatch]::startNew() $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 & git --version
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } 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" $FullPath = Resolve-Path "$RepoDir"
if (!(Test-Path "$FullPath" -pathType Container)) { throw "Can't access folder: $FullPath" } if (!(Test-Path "$FullPath" -pathType Container)) { throw "Can't access folder: $FullPath" }
"$FullPath" "📂$FullPath"
Write-Host "⏳ (3/11) Searching for 📂.git... " -noNewline Write-Host "⏳ (3/10) Querying remote URL... " -noNewline
if (!(Test-Path "$FullPath/.git" -pathType container)) { throw "Can't access folder: $FullPath/.git" }
"OK"
Write-Host "⏳ (4/11) Query remote URL... " -noNewline
& git -C "$FullPath" remote get-url origin & git -C "$FullPath" remote get-url origin
if ($lastExitCode -ne "0") { throw "'git remote get-url origin' failed with exit code $lastExitCode" } 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 & git -C "$FullPath" branch --show-current
if ($lastExitCode -ne "0") { throw "'git branch --show-current' failed with exit code $lastExitCode" } 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 & git -C "$FullPath" fetch
if ($lastExitCode -ne "0") { throw "'git branch --show-current' failed with exit code $lastExitCode" } 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) $LatestTagCommitID = (git -C "$FullPath" rev-list --tags --max-count=1)
$LatestTagName = (git -C "$FullPath" describe --tags $LatestTagCommitID) $LatestTagName = (git -C "$FullPath" describe --tags $LatestTagCommitID)
Write-Host "$LatestTagName (commit $LatestTagCommitID)" Write-Host "$LatestTagName (commit $LatestTagCommitID)"
Write-Host "⏳ (8/11) Verify data integrity..." Write-Host "⏳ (7/10) Verifying data integrity..."
& git -C "$FullPath" fsck & git -C "$FullPath" fsck
if ($lastExitCode -ne "0") { throw "'git fsck' failed with exit code $lastExitCode" } 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 & git -C "$FullPath" maintenance run
if ($lastExitCode -ne "0") { throw "'git maintenance run' failed with exit code $lastExitCode" } 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 & git -C "$FullPath" submodule status
if ($lastExitCode -ne "0") { throw "'git submodule status' failed with exit code $lastExitCode" } if ($lastExitCode -ne "0") { throw "'git submodule status' failed with exit code $lastExitCode" }
" "
Write-Host "⏳ (11/11) Query repository status... " -noNewline Write-Host "⏳ (10/10) Checking repo status... " -noNewline
& git -C "$FullPath" status --short & git -C "$FullPath" status
if ($lastExitCode -ne "0") { throw "'git status --short' failed with exit code $lastExitCode" } if ($lastExitCode -ne "0") { throw "'git status --short' failed with exit code $lastExitCode" }
" "
$RepoDirName = (Get-Item "$FullPath").Name $RepoDirName = (Get-Item "$FullPath").Name
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
"✔️ checked 📂$RepoDirName repo in $Elapsed sec" "✔️ successfully checked repo 📂$RepoDirName in $Elapsed sec"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ 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 ## Parameters
```powershell ```powershell
check-santa.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-santa.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,

View File

@ -16,12 +16,12 @@ check-smart-devices.ps1
```powershell ```powershell
<# <#
.SYNOPSIS .SYNOPSIS
Checks SMART devices Checks the SMART device status
.DESCRIPTION .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 .EXAMPLE
PS> ./check-smart-devices 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 .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -45,18 +45,19 @@ function Bytes2String { param([int64]$Bytes)
} }
try { try {
Write-Progress "⏳ Step 1/3 - Searching for smartctl executable..." Write-Progress "⏳ (1/3) Searching for smartmontools..."
$Result = (smartctl --version) $Result = (smartctl --version)
if ($lastExitCode -ne "0") { throw "Can't execute 'smartctl' - make sure smartmontools are installed" } 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) { if ($IsLinux) {
$Devices = $(sudo smartctl --scan-open) $Devices = $(sudo smartctl --scan-open)
} else { } else {
$Devices = $(smartctl --scan-open) $Devices = $(smartctl --scan-open)
} }
foreach($Device in $Devices) { 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(" ") $Array = $Device.split(" ")
$Device = $Array[0] $Device = $Array[0]
if ("$Device" -eq "#") { if ("$Device" -eq "#") {
@ -81,7 +82,8 @@ try {
$PowerOn = $Details.power_cycle_count $PowerOn = $Details.power_cycle_count
$Hours = $Details.power_on_time.hours $Hours = $Details.power_on_time.hours
if ($Details.smart_status.passed) { $Status = "passed" } else { $Status = "FAILED" } 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 exit 0 # success
} catch { } catch {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@ This PowerShell script checks the current weather report.
## Parameters ## Parameters
```powershell ```powershell
check-weather.ps1 [[-location] <String>] [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-weather.ps1 [[-location] <String>] [<CommonParameters>]
-location <String> -location <String>
Specifies the location to use (determined automatically per default) 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 ## Parameters
```powershell ```powershell
check-week.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-week.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
check-wind.ps1 [[-location] <String>] [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-wind.ps1 [[-location] <String>] [<CommonParameters>]
-location <String> -location <String>
Specifies the location to use (determined automatically per default) 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 ## Parameters
```powershell ```powershell
check-windows-system-files.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-windows-system-files.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
check-xml-file.ps1 [[-file] <String>] [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/check-xml-file.ps1 [[-file] <String>] [<CommonParameters>]
-file <String> -file <String>
Specifies the path to the XML file to check Specifies the path to the XML file to check

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@ This PowerShell script closes the Google Chrome Web browser gracefully.
## Parameters ## Parameters
```powershell ```powershell
close-chrome.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-chrome.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-cortana.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-cortana.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-edge.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-edge.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-file-explorer.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-file-explorer.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-firefox.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-firefox.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-git-extensions.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-git-extensions.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-magnifier.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-magnifier.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-microsoft-paint.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-microsoft-paint.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-microsoft-store.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-microsoft-store.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-netflix.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-netflix.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-note-pad.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-note-pad.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-obs-studio.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-obs-studio.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-one-calendar.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-one-calendar.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-outlook.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-outlook.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```powershell
close-paint-three-d.ps1 [<CommonParameters>] /home/mf/Repos/PowerShell/Scripts/close-paint-three-d.ps1 [<CommonParameters>]
[<CommonParameters>] [<CommonParameters>]
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, 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 ## Parameters
```powershell ```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> -FullProgramName <String>
Specifies the full program name Specifies the full program name
@ -87,7 +87,7 @@ try {
foreach ($Process in $Processes) { foreach ($Process in $Processes) {
$Process.CloseMainWindow() | Out-Null $Process.CloseMainWindow() | Out-Null
} }
start-sleep -milliseconds 100 Start-Sleep -milliseconds 100
stop-process -name $ProgramName -force -errorAction 'silentlycontinue' stop-process -name $ProgramName -force -errorAction 'silentlycontinue'
} else { } else {
$Processes = get-process -name $ProgramAliasName -errorAction 'silentlycontinue' $Processes = get-process -name $ProgramAliasName -errorAction 'silentlycontinue'
@ -97,7 +97,7 @@ try {
foreach ($Process in $Processes) { foreach ($Process in $Processes) {
$_.CloseMainWindow() | Out-Null $_.CloseMainWindow() | Out-Null
} }
start-sleep -milliseconds 100 Start-Sleep -milliseconds 100
stop-process -name $ProgramName -force -errorAction 'silentlycontinue' stop-process -name $ProgramName -force -errorAction 'silentlycontinue'
} }
if ($($Processes.Count) -eq 1) { if ($($Processes.Count) -eq 1) {

View File

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