mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-28 10:53:32 +01:00
Update the manual pages
This commit is contained in:
parent
7ed57228ac
commit
7e379a79ba
85
Docs/Windefender.md
Normal file
85
Docs/Windefender.md
Normal file
@ -0,0 +1,85 @@
|
||||
*Windefender.ps1*
|
||||
================
|
||||
|
||||
This script can enable disable and show windows defender real time monitoring!
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./Windefender.ps1 [<CommonParameters>]
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./Windefender.ps1
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Dark Master | License: CC0-1,0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/pakoti/Awesome_Sysadmin
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Windows defender in powershell
|
||||
.DESCRIPTION
|
||||
This script can enable disable and show windows defender real time monitoring!
|
||||
.EXAMPLE
|
||||
PS> ./Windefender.ps1
|
||||
.LINK
|
||||
https://github.com/pakoti/Awesome_Sysadmin
|
||||
.NOTES
|
||||
Author: Dark Master | License: CC0-1,0
|
||||
#>
|
||||
|
||||
|
||||
|
||||
$defender = Get-MpPreference
|
||||
|
||||
$userInput = Read-Host "Enter an option:
|
||||
[1] Disable real time monitoring
|
||||
[2] Enable real time monitoring
|
||||
[3] Check status
|
||||
"
|
||||
|
||||
switch($userInput) {
|
||||
1 {
|
||||
$defender.DisableRealtimeMonitoring = $true
|
||||
$defender | Set-MpPreference
|
||||
Write-Host "Real-time monitoring of Windows Defender has been disabled."
|
||||
break
|
||||
}
|
||||
2 {
|
||||
$defender.DisableRealtimeMonitoring = $false
|
||||
$defender | Set-MpPreference
|
||||
Write-Host "Real-time monitoring of Windows Defender has been enabled."
|
||||
break
|
||||
}
|
||||
3 {
|
||||
if($defender.DisableRealtimeMonitoring) {
|
||||
Write-Host "Real-time monitoring of Windows Defender is currently disabled."
|
||||
} else {
|
||||
Write-Host "Real-time monitoring of Windows Defender is currently enabled."
|
||||
}
|
||||
break
|
||||
}
|
||||
default {
|
||||
Write-Host "Invalid option selected."
|
||||
break
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of Windefender.ps1 as of 10/19/2023 08:11:43)*
|
@ -113,4 +113,4 @@ try {
|
||||
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of add-firewall-rules.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of add-firewall-rules.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -79,4 +79,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of add-memo.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of add-memo.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -71,4 +71,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of alert.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of alert.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -1,15 +1,15 @@
|
||||
*build-repo.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script builds a repository by supporting: cmake, configure, autogen, Imakefile, and Makefile.
|
||||
This PowerShell script builds a Git repository by supporting build systems such as: autogen, cmake, configure, Gradle, Imakefile, Makefile, and Meson.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./build-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
|
||||
PS> ./build-repo.ps1 [[-path] <String>] [<CommonParameters>]
|
||||
|
||||
-RepoDir <String>
|
||||
Specifies the path to the Git repository
|
||||
-path <String>
|
||||
Specifies the path to the Git repository (current working dir by default)
|
||||
|
||||
Required? false
|
||||
Position? 1
|
||||
@ -25,7 +25,10 @@ PS> ./build-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./build-repo.ps1 C:\MyRepo
|
||||
PS> ./build-repo.ps1 C:\Repos\ninja
|
||||
⏳ Building 📂ninja using CMakeLists.txt into 📂ninja/_My_Build...
|
||||
...
|
||||
✔️ Built 📂ninja in 47 sec
|
||||
|
||||
```
|
||||
|
||||
@ -44,27 +47,30 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Builds a repository
|
||||
.DESCRIPTION
|
||||
This PowerShell script builds a repository by supporting: cmake, configure, autogen, Imakefile, and Makefile.
|
||||
.PARAMETER RepoDir
|
||||
Specifies the path to the Git repository
|
||||
This PowerShell script builds a Git repository by supporting build systems such as: autogen, cmake, configure, Gradle, Imakefile, Makefile, and Meson.
|
||||
.PARAMETER path
|
||||
Specifies the path to the Git repository (current working dir by default)
|
||||
.EXAMPLE
|
||||
PS> ./build-repo.ps1 C:\MyRepo
|
||||
PS> ./build-repo.ps1 C:\Repos\ninja
|
||||
⏳ Building 📂ninja using CMakeLists.txt into 📂ninja/_My_Build...
|
||||
...
|
||||
✔️ Built 📂ninja in 47 sec
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$RepoDir = "$PWD")
|
||||
param([string]$path = "$PWD")
|
||||
|
||||
function BuildInDir { param($Path)
|
||||
$DirName = (Get-Item "$Path").Name
|
||||
if (Test-Path "$Path/CMakeLists.txt" -pathType leaf) {
|
||||
"⏳ Building repo 📂$DirName using CMakeLists.txt into subfolder _My_Build ..."
|
||||
if (-not(Test-Path "$Path/_My_Build/" -pathType container)) {
|
||||
& mkdir "$Path/_My_Build/"
|
||||
function BuildInDir([string]$path) {
|
||||
$dirName = (Get-Item "$path").Name
|
||||
if (Test-Path "$path/CMakeLists.txt" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using CMake into 📂$dirName/_My_Build..."
|
||||
if (-not(Test-Path "$path/_My_Build/" -pathType container)) {
|
||||
& mkdir "$path/_My_Build/"
|
||||
}
|
||||
Set-Location "$Path/_My_Build/"
|
||||
Set-Location "$path/_My_Build/"
|
||||
|
||||
& cmake ..
|
||||
if ($lastExitCode -ne "0") { throw "Executing 'cmake ..' has failed" }
|
||||
@ -75,9 +81,9 @@ function BuildInDir { param($Path)
|
||||
& make test
|
||||
if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" }
|
||||
|
||||
} elseif (Test-Path "$Path/configure" -pathType leaf) {
|
||||
"⏳ Building repo 📂$DirName using 'configure'..."
|
||||
Set-Location "$Path/"
|
||||
} elseif (Test-Path "$path/configure" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using 'configure'..."
|
||||
Set-Location "$path/"
|
||||
|
||||
& ./configure
|
||||
#if ($lastExitCode -ne "0") { throw "Script 'configure' exited with error code $lastExitCode" }
|
||||
@ -88,9 +94,9 @@ function BuildInDir { param($Path)
|
||||
& make test
|
||||
if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" }
|
||||
|
||||
} elseif (Test-Path "$Path/autogen.sh" -pathType leaf) {
|
||||
"⏳ Building repo 📂$DirName using 'autogen.sh'..."
|
||||
Set-Location "$Path/"
|
||||
} elseif (Test-Path "$path/autogen.sh" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using 'autogen.sh'..."
|
||||
Set-Location "$path/"
|
||||
|
||||
& ./autogen.sh
|
||||
if ($lastExitCode -ne "0") { throw "Script 'autogen.sh' exited with error code $lastExitCode" }
|
||||
@ -98,9 +104,9 @@ function BuildInDir { param($Path)
|
||||
& make -j4
|
||||
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
||||
|
||||
} elseif (Test-Path "$Path/build.gradle" -pathType leaf) {
|
||||
"⏳ Building repo 📂$DirName using build.gradle..."
|
||||
Set-Location "$Path"
|
||||
} elseif (Test-Path "$path/build.gradle" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using Gradle..."
|
||||
Set-Location "$path"
|
||||
|
||||
& gradle build
|
||||
if ($lastExitCode -ne "0") { throw "'gradle build' has failed" }
|
||||
@ -108,9 +114,15 @@ function BuildInDir { param($Path)
|
||||
& gradle test
|
||||
if ($lastExitCode -ne "0") { throw "'gradle test' has failed" }
|
||||
|
||||
} elseif (Test-Path "$Path/Imakefile" -pathType leaf) {
|
||||
"⏳ Building repo 📂$DirName using Imakefile..."
|
||||
Set-Location "$RepoDir/"
|
||||
} elseif (Test-Path "$path/meson.build" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using Meson..."
|
||||
Set-Location "$path"
|
||||
& meson . build --prefix=/usr/local
|
||||
if ($lastExitCode -ne "0") { throw "'meson . build' has failed" }
|
||||
|
||||
} elseif (Test-Path "$path/Imakefile" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using Imakefile..."
|
||||
Set-Location "$path/"
|
||||
|
||||
& xmkmf
|
||||
if ($lastExitCode -ne "0") { throw "Executing 'xmkmf' has failed" }
|
||||
@ -118,23 +130,23 @@ function BuildInDir { param($Path)
|
||||
& make -j4
|
||||
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
||||
|
||||
} elseif (Test-Path "$Path/Makefile" -pathType leaf) {
|
||||
"⏳ Building repo 📂$DirName using Makefile..."
|
||||
Set-Location "$Path"
|
||||
} elseif (Test-Path "$path/Makefile" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using Makefile..."
|
||||
Set-Location "$path"
|
||||
|
||||
& make -j4
|
||||
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
||||
|
||||
} elseif (Test-Path "$Path/makefile" -pathType leaf) {
|
||||
"⏳ Building repo 📂$DirName using makefile..."
|
||||
Set-Location "$Path"
|
||||
} elseif (Test-Path "$path/makefile" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using makefile..."
|
||||
Set-Location "$path"
|
||||
|
||||
& make -j4
|
||||
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
||||
|
||||
} elseif (Test-Path "$Path/compile.sh" -pathType leaf) {
|
||||
"⏳ Building repo 📂$DirName using 'compile.sh'..."
|
||||
Set-Location "$Path/"
|
||||
} elseif (Test-Path "$path/compile.sh" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using 'compile.sh'..."
|
||||
Set-Location "$path/"
|
||||
|
||||
& ./compile.sh
|
||||
if ($lastExitCode -ne "0") { throw "Script 'compile.sh' exited with error code $lastExitCode" }
|
||||
@ -142,34 +154,34 @@ function BuildInDir { param($Path)
|
||||
& make -j4
|
||||
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
|
||||
|
||||
} elseif (Test-Path "$Path/attower/src/build/DevBuild/build.bat" -pathType leaf) {
|
||||
"⏳ Building repo 📂$DirName using build.bat ..."
|
||||
Set-Location "$Path/attower/src/build/DevBuild/"
|
||||
} elseif (Test-Path "$path/attower/src/build/DevBuild/build.bat" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using build.bat ..."
|
||||
Set-Location "$path/attower/src/build/DevBuild/"
|
||||
|
||||
& ./build.bat build-all-release
|
||||
if ($lastExitCode -ne "0") { throw "Script 'build.bat' exited with error code $lastExitCode" }
|
||||
|
||||
} elseif (Test-Path "$Path/$DirName" -pathType container) {
|
||||
"⏳ No make rule found, trying subfolder 📂$($DirName)..."
|
||||
BuildInDir "$Path/$DirName"
|
||||
} elseif (Test-Path "$path/$dirName" -pathType container) {
|
||||
"⏳ No make rule found, trying subfolder 📂$($dirName)..."
|
||||
BuildInDir "$path/$dirName"
|
||||
} else {
|
||||
Write-Warning "Sorry, no make rule applies to: 📂$DirName"
|
||||
Write-Warning "Sorry, no make rule applies to: 📂$dirName"
|
||||
exit 0 # success
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
if (-not(Test-Path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" }
|
||||
$RepoDirName = (Get-Item "$RepoDir").Name
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Can't access directory: $path" }
|
||||
|
||||
$PreviousPath = Get-Location
|
||||
BuildInDir "$RepoDir"
|
||||
Set-Location "$PreviousPath"
|
||||
$previousPath = Get-Location
|
||||
BuildInDir "$path"
|
||||
Set-Location "$previousPath"
|
||||
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ built repo 📂$RepoDirName in $Elapsed sec"
|
||||
$repoDirName = (Get-Item "$path").Name
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✔️ Built 📂$repoDirName in $elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -177,4 +189,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of build-repo.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of build-repo.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -82,4 +82,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of build-repos.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of build-repos.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-autostart.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-autostart.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
*cd-crashdumps.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script changes the working directory to the crash dumps directory (Windows only).
|
||||
This PowerShell script changes the working directory to the crash dumps directory (Windows only). Whenever a software crashes and crash dumps are enabled(!) a crash dump file is written. This file helps to identify the reason for the crash.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -36,7 +36,7 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Change to the crash dumps folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the crash dumps directory (Windows only).
|
||||
This PowerShell script changes the working directory to the crash dumps directory (Windows only). Whenever a software crashes and crash dumps are enabled(!) a crash dump file is written. This file helps to identify the reason for the crash.
|
||||
.EXAMPLE
|
||||
PS> ./cd-crashdumps
|
||||
📂C:\Users\Markus\AppData\Local\CrashDumps
|
||||
@ -47,12 +47,15 @@ Script Content
|
||||
#>
|
||||
|
||||
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)" }
|
||||
if ($IsLinux) { throw "Sorry, Windows only" }
|
||||
|
||||
[string]$path = Resolve-Path -Path "~"
|
||||
if (!(Test-Path "$path" -pathType container)) { throw "Home directory at $path doesn't exist (yet)" }
|
||||
|
||||
$path += "\AppData\Local\CrashDumps"
|
||||
if (!(Test-Path "$path" -pathType container)) { throw "Crashdumps directory at $path doesn't exist (yet)" }
|
||||
Set-Location "$Path"
|
||||
"📂$Path"
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -60,4 +63,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-crashdumps.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-crashdumps.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -64,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-desktop.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-desktop.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -64,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-docs.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-docs.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -64,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-downloads.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-downloads.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-dropbox.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-dropbox.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -64,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-etc.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-etc.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-fonts.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-fonts.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-home.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-home.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -48,4 +48,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-logs.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-logs.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -64,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-music.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-music.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-onedrive.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-onedrive.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -62,4 +62,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-pics.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-pics.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -62,4 +62,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-public.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-public.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -53,4 +53,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-recycle-bin.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-recycle-bin.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -80,4 +80,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-repos.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-repos.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -57,4 +57,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-root.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-root.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -55,4 +55,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-screenshots.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-screenshots.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-scripts.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-scripts.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-ssh.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-ssh.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -50,4 +50,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-temp.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-temp.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -62,4 +62,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-templates.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-templates.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -53,4 +53,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-trash.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-trash.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up2.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up2.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up3.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up3.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up4.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up4.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-users.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-users.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -62,4 +62,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-videos.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-videos.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-windows.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-windows.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -79,4 +79,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of change-wallpaper.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of change-wallpaper.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
70
Docs/check-admin.md
Normal file
70
Docs/check-admin.md
Normal file
@ -0,0 +1,70 @@
|
||||
*check-admin.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script checks if the user has administrator rights.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./check-admin.ps1 [<CommonParameters>]
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-admin.ps1
|
||||
✅ Yes
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Check for admin rights
|
||||
.DESCRIPTION
|
||||
This PowerShell script checks if the user has administrator rights.
|
||||
.EXAMPLE
|
||||
PS> ./check-admin.ps1
|
||||
✅ Yes
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
# todo
|
||||
} else {
|
||||
$user = [Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$principal = (New-Object Security.Principal.WindowsPrincipal $user)
|
||||
if ($principal.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) {
|
||||
"✅ Yes"
|
||||
} elseif ($principal.IsInRole([Security.Principal.WindowsBuiltinRole]::Guest)) {
|
||||
"⚠️ No, guest rights only"
|
||||
} else {
|
||||
"⚠️ No, normal user rights only"
|
||||
}
|
||||
}
|
||||
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-admin.ps1 as of 10/19/2023 08:11:35)*
|
@ -75,4 +75,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-apps.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-apps.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -76,4 +76,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-bios.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-bios.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -21,31 +21,31 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Checks the CPU status
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries the CPU status and prints it (name, type, speed, temperature, etc).
|
||||
This PowerShell script queries the CPU status (name, type, speed, temperature, etc) and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-cpu.ps1
|
||||
✅ AMD Ryzen 5 5500U with Radeon Graphics (CPU0, 2100MHz, 31.3°C)
|
||||
✅ Intel(R) Core(TM) i9-10900X CPU @ 3.70GHz (AMD64, 20 cores, CPU0, 3696MHz, CPU0 socket, 31.3°C)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
function GetCPUTemperatureInCelsius {
|
||||
$Temp = 99999.9 # unsupported
|
||||
function GetProcessorTemperature {
|
||||
$temp = 99999.9 # unsupported
|
||||
if ($IsLinux) {
|
||||
if (Test-Path "/sys/class/thermal/thermal_zone0/temp" -pathType leaf) {
|
||||
[int]$IntTemp = Get-Content "/sys/class/thermal/thermal_zone0/temp"
|
||||
$Temp = [math]::round($IntTemp / 1000.0, 1)
|
||||
$temp = [math]::round($IntTemp / 1000.0, 1)
|
||||
}
|
||||
} else {
|
||||
$Objects = Get-WmiObject -Query "SELECT * FROM Win32_PerfFormattedData_Counters_ThermalZoneInformation" -Namespace "root/CIMV2"
|
||||
foreach ($Obj in $Objects) {
|
||||
$HiPrec = $Obj.HighPrecisionTemperature
|
||||
$Temp = [math]::round($HiPrec / 100.0, 1)
|
||||
$objects = Get-WmiObject -Query "SELECT * FROM Win32_PerfFormattedData_Counters_ThermalZoneInformation" -Namespace "root/CIMV2"
|
||||
foreach ($object in $objects) {
|
||||
$highPrec = $object.HighPrecisionTemperature
|
||||
$temp = [math]::round($highPrec / 100.0, 1)
|
||||
}
|
||||
}
|
||||
return $Temp;
|
||||
return $temp
|
||||
}
|
||||
|
||||
function GetProcessorArchitecture {
|
||||
@ -63,39 +63,39 @@ function GetProcessorArchitecture {
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Progress "⏳ Querying CPU details..."
|
||||
$Status = "✅"
|
||||
$Celsius = GetCPUTemperatureInCelsius
|
||||
if ($Celsius -eq 99999.9) {
|
||||
$Temp = "no temp"
|
||||
} elseif ($Celsius -gt 50) {
|
||||
$Temp = "$($Celsius)°C"
|
||||
$Status = "⚠️"
|
||||
} elseif ($Celsius -lt 0) {
|
||||
$Temp = "$($Celsius)°C"
|
||||
$Status = "⚠️"
|
||||
Write-Progress "⏳ Querying CPU status... "
|
||||
$status = "✅"
|
||||
$celsius = GetProcessorTemperature
|
||||
if ($celsius -eq 99999.9) {
|
||||
$temp = "no temp"
|
||||
} elseif ($celsius -gt 50) {
|
||||
$temp = "$($celsius)°C"
|
||||
$status = "⚠️"
|
||||
} elseif ($celsius -lt 0) {
|
||||
$temp = "$($celsius)°C"
|
||||
$status = "⚠️"
|
||||
} else {
|
||||
$Temp = "$($Celsius)°C"
|
||||
$temp = "$($celsius)°C"
|
||||
}
|
||||
|
||||
$Arch = GetProcessorArchitecture
|
||||
$arch = GetProcessorArchitecture
|
||||
if ($IsLinux) {
|
||||
$CPUName = "$Arch CPU"
|
||||
$Arch = ""
|
||||
$DeviceID = ""
|
||||
$Speed = ""
|
||||
$Socket = ""
|
||||
$cpuName = "$arch CPU"
|
||||
$arch = ""
|
||||
$deviceID = ""
|
||||
$speed = ""
|
||||
$socket = ""
|
||||
} else {
|
||||
$Details = Get-WmiObject -Class Win32_Processor
|
||||
$CPUName = $Details.Name.trim()
|
||||
$Arch = "$Arch, "
|
||||
$DeviceID = "$($Details.DeviceID), "
|
||||
$Speed = "$($Details.MaxClockSpeed)MHz, "
|
||||
$Socket = "$($Details.SocketDesignation) socket, "
|
||||
$details = Get-WmiObject -Class Win32_Processor
|
||||
$cpuName = $details.Name.trim()
|
||||
$arch = "$arch, "
|
||||
$deviceID = "$($details.DeviceID), "
|
||||
$speed = "$($details.MaxClockSpeed)MHz, "
|
||||
$socket = "$($details.SocketDesignation) socket, "
|
||||
}
|
||||
$Cores = [System.Environment]::ProcessorCount
|
||||
Write-Progress -completed "done."
|
||||
Write-Host "$Status $CPUName ($($Arch)$Cores cores, $($DeviceID)$($Speed)$($Socket)$Temp)"
|
||||
$cores = [System.Environment]::ProcessorCount
|
||||
Write-Progress -completed " "
|
||||
Write-Host "$status $cpuName ($($arch)$cores cores, $($deviceID)$($speed)$($socket)$temp)"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -103,4 +103,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-cpu.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-cpu.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -57,4 +57,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-day.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-day.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -47,9 +47,9 @@ Script Content
|
||||
#>
|
||||
|
||||
try {
|
||||
Write-Progress "⏳ Measuring DNS resolution..."
|
||||
$table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv"
|
||||
$numRows = $table.Length
|
||||
Write-Progress "⏳ Resolving $numRows domain names..."
|
||||
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
if ($IsLinux) {
|
||||
@ -57,13 +57,14 @@ try {
|
||||
} else {
|
||||
foreach($row in $table){$nop=Resolve-DNSName $row.Domain}
|
||||
}
|
||||
Write-Progress -completed "."
|
||||
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
|
||||
Write-Progress -completed " "
|
||||
$average = [math]::round($numRows / $elapsed, 1)
|
||||
if ($average -lt 10.0) {
|
||||
Write-Output "⚠️ DNS resolves $average domains per second only"
|
||||
Write-Host "⚠️ DNS resolves $average domains per second only"
|
||||
} else {
|
||||
Write-Output "✅ DNS resolves $average domains per second"
|
||||
Write-Host "✅ DNS resolves $average domains per second"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
@ -72,4 +73,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-dns.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-dns.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -91,4 +91,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-drive-space.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-drive-space.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -26,8 +26,8 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-drives.ps1
|
||||
✅ Drive C: uses 49% of 1TB, 512GB free
|
||||
✅ Drive D: uses 84% of 4TB, 641GB free
|
||||
✅ Drive C: uses 49%, 512GB free of 1TB
|
||||
✅ Drive D: uses 84%, 641GB free of 4TB
|
||||
|
||||
```
|
||||
|
||||
@ -51,8 +51,8 @@ Script Content
|
||||
Specifies the minimum warning level (10 GB by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-drives.ps1
|
||||
✅ Drive C: uses 49% of 1TB, 512GB free
|
||||
✅ Drive D: uses 84% of 4TB, 641GB free
|
||||
✅ Drive C: uses 49%, 512GB free of 1TB
|
||||
✅ Drive D: uses 84%, 641GB free of 4TB
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -95,7 +95,7 @@ try {
|
||||
Write-Host "⚠️ Drive $name with $(Bytes2String $total) is nearly full, $(Bytes2String $free) free"
|
||||
} else {
|
||||
[int]$percent = ($used * 100) / $total
|
||||
Write-Host "✅ Drive $name uses $percent% of $(Bytes2String $total), $(Bytes2String $free) free"
|
||||
Write-Host "✅ Drive $name uses $percent%, $(Bytes2String $free) free of $(Bytes2String $total)"
|
||||
}
|
||||
}
|
||||
exit 0 # success
|
||||
@ -105,4 +105,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-drives.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-drives.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -63,4 +63,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-dusk.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-dusk.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -61,4 +61,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-easter-sunday.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-easter-sunday.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -75,4 +75,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-file-system.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-file-system.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -170,4 +170,4 @@ function Check-Header { param( $path )
|
||||
Check-Header $Path
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-file.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-file.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-firewall.ps1 as of 09/20/2023 17:04:37)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-firewall.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -24,7 +24,7 @@ Script Content
|
||||
This PowerShell script queries the GPU status and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-gpu.ps1
|
||||
✅ NVIDIA Quadro P400 GPU (2GB RAM, 3840x2160 pixels, 32 bit, 59 Hz, driver 31.0.15.1740, status OK)
|
||||
✅ NVIDIA Quadro P400 GPU (2GB RAM, 3840x2160 pixels, 32-bit, 59Hz, driver 31.0.15.1740, status OK)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -56,7 +56,7 @@ try {
|
||||
$RefreshRate = $Details.CurrentRefreshRate
|
||||
$DriverVersion = $Details.DriverVersion
|
||||
$Status = $Details.Status
|
||||
Write-Host "✅ $Model GPU ($(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 {
|
||||
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-gpu.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-gpu.ps1 as of 10/19/2023 08:11:35)*
|
||||
|
@ -63,4 +63,4 @@ Script Content
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-hardware.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-hardware.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -58,4 +58,4 @@ Script Content
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-health.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-health.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -61,4 +61,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-independence-day.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-independence-day.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -84,4 +84,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ipv4-address.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ipv4-address.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -98,4 +98,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ipv6-address.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ipv6-address.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -55,4 +55,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-iss-position.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-iss-position.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -87,4 +87,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-mac-address.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-mac-address.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-midnight.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-midnight.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -57,4 +57,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-month.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-month.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -76,4 +76,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-moon-phase.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-moon-phase.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -64,4 +64,4 @@ Script Content
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-network.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-network.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-new-year.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-new-year.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -59,4 +59,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-noon.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-noon.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -73,4 +73,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-os.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-os.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-outlook.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-outlook.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -94,4 +94,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-password.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-password.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -92,4 +92,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-pending-reboot.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-pending-reboot.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -62,28 +62,26 @@ param([string]$hosts = "bing.com,cnn.com,dropbox.com,github.com,google.com,ibm.c
|
||||
try {
|
||||
$hostsArray = $hosts.Split(",")
|
||||
$parallelTasks = $hostsArray | foreach {
|
||||
(New-Object Net.NetworkInformation.Ping).SendPingAsync($_, 500)
|
||||
(New-Object Net.NetworkInformation.Ping).SendPingAsync($_,750)
|
||||
}
|
||||
[int]$min = 9999999
|
||||
[int]$max = [int]$avg = [int]$successCount = [int]$lossCount = 0
|
||||
[int]$totalCount = $hostsArray.Count
|
||||
[int]$max = [int]$avg = [int]$success = 0
|
||||
[int]$total = $hostsArray.Count
|
||||
[Threading.Tasks.Task]::WaitAll($parallelTasks)
|
||||
foreach($ping in $parallelTasks.Result) {
|
||||
if ($ping.Status -eq "Success") {
|
||||
[int]$latency = $ping.RoundtripTime
|
||||
if ($latency -lt $min) { $min = $latency }
|
||||
if ($latency -gt $max) { $max = $latency }
|
||||
$avg += $latency
|
||||
$successCount++
|
||||
} else {
|
||||
$lossCount++
|
||||
}
|
||||
if ($ping.Status -ne "Success") { continue }
|
||||
$success++
|
||||
[int]$latency = $ping.RoundtripTime
|
||||
$avg += $latency
|
||||
if ($latency -lt $min) { $min = $latency }
|
||||
if ($latency -gt $max) { $max = $latency }
|
||||
}
|
||||
if ($successCount -ne 0) {
|
||||
$avg /= $successCount
|
||||
Write-Host "✅ Online with $($avg)ms latency average ($($min)ms...$($max)ms, $lossCount/$totalCount ping loss)"
|
||||
[int]$loss = $total - $success
|
||||
if ($success -ne 0) {
|
||||
$avg /= $success
|
||||
Write-Host "✅ Online with $($avg)ms latency average ($($min)ms...$($max)ms, $loss/$total ping loss)"
|
||||
} else {
|
||||
Write-Host "⚠️ Offline ($lossCount/$totalCount ping loss)"
|
||||
Write-Host "⚠️ Offline ($loss/$total ping loss)"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
@ -92,4 +90,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ping.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ping.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -17,7 +17,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-power.ps1
|
||||
⚠️ Battery at 9% (54 min remaining) with power scheme: HP Optimized
|
||||
⚠️ Battery at 9% · 54 min remaining · power scheme 'HP Optimized'
|
||||
|
||||
```
|
||||
|
||||
@ -39,7 +39,7 @@ Script Content
|
||||
This PowerShell script queries the power status and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-power.ps1
|
||||
⚠️ Battery at 9% (54 min remaining) with power scheme: HP Optimized
|
||||
⚠️ Battery at 9% · 54 min remaining · power scheme 'HP Optimized'
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -48,41 +48,43 @@ Script Content
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$Reply = "✅ AC powered" # TODO, just guessing :-)
|
||||
$reply = "✅ AC powered" # TODO, just guessing :-)
|
||||
} else {
|
||||
Add-Type -Assembly System.Windows.Forms
|
||||
$Details = [System.Windows.Forms.SystemInformation]::PowerStatus
|
||||
[int]$Percent = 100 * $Details.BatteryLifePercent
|
||||
[int]$Remaining = $Details.BatteryLifeRemaining / 60
|
||||
if ($Details.PowerLineStatus -eq "Online") {
|
||||
if ($Details.BatteryChargeStatus -eq "NoSystemBattery") {
|
||||
$Reply = "✅ AC powered"
|
||||
} elseif ($Percent -ge 95) {
|
||||
$Reply = "✅ Battery fully charged ($Percent%)"
|
||||
$details = [System.Windows.Forms.SystemInformation]::PowerStatus
|
||||
[int]$percent = 100 * $details.BatteryLifePercent
|
||||
[int]$remaining = $details.BatteryLifeRemaining / 60
|
||||
if ($details.PowerLineStatus -eq "Online") {
|
||||
if ($details.BatteryChargeStatus -eq "NoSystemBattery") {
|
||||
$reply = "✅ AC powered"
|
||||
} elseif ($percent -ge 95) {
|
||||
$reply = "✅ Battery $percent% fully charged"
|
||||
} else {
|
||||
$Reply = "✅ Battery charging... ($Percent%)"
|
||||
$reply = "✅ Battery charging... ($percent%)"
|
||||
}
|
||||
} else { # must be offline
|
||||
if ($Remaining -eq 0) {
|
||||
$Reply = "✅ Battery at $Percent%"
|
||||
} elseif ($Remaining -le 5) {
|
||||
$Reply = "⚠️ Battery at $Percent%, ONLY $Remaining MIN remaining"
|
||||
} elseif ($Remaining -le 30) {
|
||||
$Reply = "⚠️ Battery at $Percent%, only $Remaining min remaining"
|
||||
} elseif ($Percent -lt 10) {
|
||||
$Reply = "⚠️ Battery at $Percent% with $Remaining min remaining"
|
||||
} elseif ($Percent -ge 80) {
|
||||
$Reply = "✅ Battery $Percent% full with $Remaining min remaining"
|
||||
if (($remaining -eq 0) -and ($percent -ge 60)) {
|
||||
$reply = "✅ Battery $percent% full"
|
||||
} elseif ($remaining -eq 0) {
|
||||
$reply = "✅ Battery at $percent%"
|
||||
} elseif ($remaining -le 5) {
|
||||
$reply = "⚠️ Battery at $percent% · ONLY $($remaining)min remaining"
|
||||
} elseif ($remaining -le 30) {
|
||||
$reply = "⚠️ Battery at $percent% · only $($remaining)min remaining"
|
||||
} elseif ($percent -lt 10) {
|
||||
$reply = "⚠️ Battery at $percent% · $($remaining)min remaining"
|
||||
} elseif ($percent -ge 60) {
|
||||
$reply = "✅ Battery $percent% full · $($remaining)min remaining"
|
||||
} else {
|
||||
$Reply = "✅ Battery at $Percent% with $Remaining min remaining"
|
||||
$reply = "✅ Battery at $percent% · $($remaining)min remaining"
|
||||
}
|
||||
}
|
||||
$PowerScheme = (powercfg /getactivescheme)
|
||||
$PowerScheme = $PowerScheme -Replace "^(.*) \(",""
|
||||
$PowerScheme = $PowerScheme -Replace "\)$",""
|
||||
$Reply += ", power scheme is '$PowerScheme'"
|
||||
$powerScheme = (powercfg /getactivescheme)
|
||||
$powerScheme = $powerScheme -Replace "^(.*) \(",""
|
||||
$powerScheme = $powerScheme -Replace "\)$",""
|
||||
$reply += " · power scheme '$powerScheme'"
|
||||
}
|
||||
Write-Output $Reply
|
||||
Write-Output $reply
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -90,4 +92,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-power.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-power.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -64,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-powershell.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-powershell.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -76,4 +76,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ps1-file.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ps1-file.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -98,4 +98,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ram.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ram.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -128,4 +128,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-repo.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-repo.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -56,4 +56,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-santa.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-santa.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -95,4 +95,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-smart-devices.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-smart-devices.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
*check-software.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script queries the software details of the local computer and prints it.
|
||||
This PowerShell script queries the software status of the local computer and prints it.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -42,7 +42,7 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Checks the software
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries the software details of the local computer and prints it.
|
||||
This PowerShell script queries the software status of the local computer and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-software.ps1
|
||||
|
||||
@ -60,13 +60,13 @@ Script Content
|
||||
& "$PSScriptRoot/write-green.ps1" " S O F T W A R E"
|
||||
& "$PSScriptRoot/check-bios.ps1"
|
||||
& "$PSScriptRoot/check-os.ps1"
|
||||
& "$PSScriptRoot/check-uptime.ps1"
|
||||
& "$PSScriptRoot/check-apps.ps1"
|
||||
& "$PSScriptRoot/check-powershell.ps1"
|
||||
& "$PSScriptRoot/check-uptime.ps1"
|
||||
& "$PSScriptRoot/check-time-zone.ps1"
|
||||
& "$PSScriptRoot/check-swap-space.ps1"
|
||||
& "$PSScriptRoot/check-pending-reboot.ps1"
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-software.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-software.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -84,4 +84,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-subnet-mask.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-subnet-mask.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
*check-swap-space.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script queries the status of the swap space and prints it.
|
||||
This PowerShell script queries the current status of the swap space and prints it.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -26,7 +26,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-swap-space.ps1
|
||||
✅ Swap space uses 42% of 1GB, 748MB free
|
||||
✅ Swap space uses 42%, 748MB free of 1GB
|
||||
|
||||
```
|
||||
|
||||
@ -43,14 +43,14 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks the swap space status
|
||||
Checks the swap space
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries the status of the swap space and prints it.
|
||||
This PowerShell script queries the current status of the swap space and prints it.
|
||||
.PARAMETER minLevel
|
||||
Specifies the minimum level in GB (10 GB by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-swap-space.ps1
|
||||
✅ Swap space uses 42% of 1GB, 748MB free
|
||||
✅ Swap space uses 42%, 748MB free of 1GB
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -96,7 +96,7 @@ try {
|
||||
Write-Output "✅ Swap space of $(MB2String $Total) reserved"
|
||||
} else {
|
||||
[int]$Percent = ($Used * 100) / $Total
|
||||
Write-Output "✅ Swap space uses $Percent% of $(MB2String $Total), $(MB2String $Free) free"
|
||||
Write-Output "✅ Swap space uses $Percent%, $(MB2String $Free) free of $(MB2String $Total)"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
@ -105,4 +105,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-swap-space.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-swap-space.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -100,4 +100,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-symlinks.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-symlinks.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-time-zone.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-time-zone.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -1,34 +1,19 @@
|
||||
*check-uptime.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script queries the computer's uptime and prints it.
|
||||
check-uptime.ps1
|
||||
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./check-uptime.ps1 [<CommonParameters>]
|
||||
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-uptime.ps1
|
||||
✅ Up for 2 days, 20 hours, 10 minutes
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
@ -36,7 +21,7 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Checks the uptime
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries the computer's uptime and prints it.
|
||||
This PowerShell script queries the computer's uptime (time between now and last boot up time) and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-uptime.ps1
|
||||
✅ Up for 2 days, 20 hours, 10 minutes
|
||||
@ -46,35 +31,29 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
function TimeSpan2String([TimeSpan]$uptime)
|
||||
{
|
||||
[int]$days = $uptime.Days
|
||||
[int]$hours = $days * 24 + $uptime.Hours
|
||||
if ($days -gt 2) {
|
||||
return "$days days"
|
||||
} elseif ($hours -gt 1) {
|
||||
return "$hours hours"
|
||||
} else {
|
||||
return "$($uptime.Minutes)min"
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$Uptime = (Get-Uptime)
|
||||
$uptime = (Get-Uptime)
|
||||
Write-Host "✅ Up for $(TimeSpan2String $uptime)"
|
||||
} else {
|
||||
$BootTime = Get-WinEvent -ProviderName eventlog | Where-Object {$_.Id -eq 6005} | Select-Object TimeCreated -First 1
|
||||
$Uptime = New-TimeSpan -Start $BootTime.TimeCreated.Date -End (Get-Date)
|
||||
[system.threading.thread]::currentthread.currentculture = [system.globalization.cultureinfo]"en-US"
|
||||
$lastBootTime = (Get-CimInstance Win32_OperatingSystem).LastBootUpTime
|
||||
$uptime = New-TimeSpan -Start $lastBootTime -End (Get-Date)
|
||||
Write-Host "✅ Up for $(TimeSpan2String $uptime) since $($lastBootTime.ToShortDateString())"
|
||||
}
|
||||
$Reply = "✅ Up for "
|
||||
$Days = $Uptime.Days
|
||||
if ($Days -eq "1") {
|
||||
$Reply += "1 day, "
|
||||
} elseif ($Days -ne "0") {
|
||||
$Reply += "$Days days, "
|
||||
}
|
||||
|
||||
$Hours = $Uptime.Hours
|
||||
if ($Hours -eq "1") {
|
||||
$Reply += "1 hour, "
|
||||
} elseif ($Hours -ne "0") {
|
||||
$Reply += "$Hours hours, "
|
||||
}
|
||||
|
||||
$Minutes = $Uptime.Minutes
|
||||
if ($Minutes -eq "1") {
|
||||
$Reply += "1 minute"
|
||||
} else {
|
||||
$Reply += "$Minutes minutes"
|
||||
}
|
||||
Write-Host $Reply
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -82,4 +61,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-uptime.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-uptime.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-vpn.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-vpn.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -81,4 +81,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-weather.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-weather.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -54,4 +54,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-week.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-week.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -72,4 +72,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-wind.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-wind.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-windows-system-files.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-windows-system-files.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -88,4 +88,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-xml-file.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-xml-file.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -101,4 +101,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clean-repo.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clean-repo.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -6,10 +6,10 @@ This PowerShell script cleans all Git repositories in a folder from untracked fi
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./clean-repos.ps1 [[-ParentDir] <String>] [<CommonParameters>]
|
||||
PS> ./clean-repos.ps1 [[-parentDir] <String>] [<CommonParameters>]
|
||||
|
||||
-ParentDir <String>
|
||||
Specifies the path to the parent folder
|
||||
-parentDir <String>
|
||||
Specifies the path to the parent folder (current working dir by default)
|
||||
|
||||
Required? false
|
||||
Position? 1
|
||||
@ -25,7 +25,11 @@ PS> ./clean-repos.ps1 [[-ParentDir] <String>] [<CommonParameters>]
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./clean-repos C:\MyRepos
|
||||
PS> ./clean-repos.ps1 C:\MyRepos
|
||||
⏳ (1) Searching for Git executable... git version 2.40.1
|
||||
⏳ (2) Checking parent folder 📂Repos... 28 subfolders found
|
||||
⏳ (3/30) Cleaning 📂base256unicode...
|
||||
...
|
||||
|
||||
```
|
||||
|
||||
@ -45,46 +49,50 @@ Script Content
|
||||
Cleans all Git repositories in a folder from untracked files
|
||||
.DESCRIPTION
|
||||
This PowerShell script cleans all Git repositories in a folder from untracked files (including submodules).
|
||||
.PARAMETER ParentDir
|
||||
Specifies the path to the parent folder
|
||||
.PARAMETER parentDir
|
||||
Specifies the path to the parent folder (current working dir by default)
|
||||
.EXAMPLE
|
||||
PS> ./clean-repos C:\MyRepos
|
||||
PS> ./clean-repos.ps1 C:\MyRepos
|
||||
⏳ (1) Searching for Git executable... git version 2.40.1
|
||||
⏳ (2) Checking parent folder 📂Repos... 28 subfolders found
|
||||
⏳ (3/30) Cleaning 📂base256unicode...
|
||||
...
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$ParentDir = "$PWD")
|
||||
param([string]$parentDir = "$PWD")
|
||||
|
||||
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
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
|
||||
$ParentDirName = (Get-Item "$ParentDir").Name
|
||||
Write-Host "⏳ (2) Checking parent folder 📂$ParentDirName... " -noNewline
|
||||
$parentDirName = (Get-Item "$ParentDir").Name
|
||||
Write-Host "⏳ (2) Checking parent folder 📂$parentDirName... " -noNewline
|
||||
if (-not(Test-Path "$ParentDir" -pathType container)) { throw "Can't access folder: $ParentDir" }
|
||||
$Folders = (Get-ChildItem "$ParentDir" -attributes Directory)
|
||||
$NumFolders = $Folders.Count
|
||||
Write-Host "$NumFolders subfolders found"
|
||||
$folders = (Get-ChildItem "$ParentDir" -attributes Directory)
|
||||
$numFolders = $folders.Count
|
||||
Write-Host "$numFolders subfolders found"
|
||||
|
||||
[int]$Step = 2
|
||||
foreach ($Folder in $Folders) {
|
||||
$FolderName = (Get-Item "$Folder").Name
|
||||
foreach ($folder in $folders) {
|
||||
$FolderName = (Get-Item "$folder").Name
|
||||
$Step++
|
||||
"⏳ ($Step/$($NumFolders + 2)) Cleaning 📂$FolderName..."
|
||||
"⏳ ($Step/$($numFolders + 2)) Cleaning 📂$FolderName..."
|
||||
|
||||
& git -C "$Folder" clean -xfd -f # force + recurse into dirs + don't use the standard ignore rules
|
||||
& git -C "$folder" clean -xfd -f # force + recurse into dirs + don't use the standard ignore rules
|
||||
if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' failed with exit code $lastExitCode" }
|
||||
|
||||
& git -C "$Folder" submodule foreach --recursive git clean -xfd -f
|
||||
& git -C "$folder" submodule foreach --recursive git clean -xfd -f
|
||||
if ($lastExitCode -ne "0") { throw "'git clean -xfd -f' in submodules failed with exit code $lastExitCode" }
|
||||
}
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ cleaned $NumFolders Git repositories at 📂$ParentDirName in $Elapsed sec."
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✔️ Cleaned $numFolders Git repos under 📂$parentDirName in $elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -92,4 +100,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clean-repos.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clean-repos.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clear-dns-cache.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clear-dns-cache.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clear-recycle-bin.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clear-recycle-bin.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -119,4 +119,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clone-repos.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clone-repos.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -48,4 +48,4 @@ Stop-Process -name "CalculatorApp"
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-calculator.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-calculator.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -48,4 +48,4 @@ Script Content
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-chrome.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-chrome.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -48,4 +48,4 @@ Script Content
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-cortana.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-cortana.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -52,4 +52,4 @@ if ($lastExitCode -ne "0") {
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-edge.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-edge.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -48,4 +48,4 @@ Script Content
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-file-explorer.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-file-explorer.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -48,4 +48,4 @@ Script Content
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-firefox.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-firefox.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
@ -52,4 +52,4 @@ if ($lastExitCode -ne "0") {
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-git-extensions.ps1 as of 09/20/2023 17:04:38)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-git-extensions.ps1 as of 10/19/2023 08:11:36)*
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user