Updated the Markdown manuals

This commit is contained in:
Markus Fleschutz
2023-12-07 20:24:45 +01:00
parent dafa6cf1d7
commit 1ffd91c5e2
605 changed files with 1927 additions and 1015 deletions

View File

@ -113,4 +113,4 @@ try {
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of add-firewall-rules.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of add-firewall-rules.ps1 as of 12/07/2023 20:24:14)*

View File

@ -79,4 +79,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of add-memo.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of add-memo.ps1 as of 12/07/2023 20:24:14)*

View File

@ -71,4 +71,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of alert.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of alert.ps1 as of 12/07/2023 20:24:14)*

View File

@ -66,18 +66,21 @@ param([string]$path = "$PWD")
function BuildInDir([string]$path) { function BuildInDir([string]$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 by using CMake into 📂$dirName/_My_Build..." "⏳ (1/4) Building 📂$dirName by using CMake into 📂$dirName/_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/"
"⏳ (2/4) Executing 'cmake' to generate the Makefile..."
& cmake .. & cmake ..
if ($lastExitCode -ne "0") { throw "Executing 'cmake ..' has failed" } if ($lastExitCode -ne "0") { throw "Executing 'cmake ..' has failed" }
"⏳ (3/4) Executing 'make -j4' to compile and link..."
& make -j4 & make -j4
if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" } if ($lastExitCode -ne "0") { throw "Executing 'make -j4' has failed" }
"⏳ (4/4) Executing 'make test' to perform tests (optional)..."
& make test & make test
if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" } if ($lastExitCode -ne "0") { throw "Executing 'make test' has failed" }
@ -189,4 +192,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of build-repo.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of build-repo.ps1 as of 12/07/2023 20:24:14)*

View File

@ -82,4 +82,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of build-repos.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of build-repos.ps1 as of 12/07/2023 20:24:14)*

View File

@ -60,4 +60,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-autostart.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-autostart.ps1 as of 12/07/2023 20:24:14)*

View File

@ -63,4 +63,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-crashdumps.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-crashdumps.ps1 as of 12/07/2023 20:24:14)*

View File

@ -64,4 +64,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-desktop.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-desktop.ps1 as of 12/07/2023 20:24:14)*

View File

@ -64,4 +64,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-docs.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-docs.ps1 as of 12/07/2023 20:24:14)*

View File

@ -64,4 +64,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-downloads.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-downloads.ps1 as of 12/07/2023 20:24:14)*

View File

@ -60,4 +60,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-dropbox.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-dropbox.ps1 as of 12/07/2023 20:24:14)*

View File

@ -64,4 +64,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-etc.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-etc.ps1 as of 12/07/2023 20:24:14)*

View File

@ -60,4 +60,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-fonts.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-fonts.ps1 as of 12/07/2023 20:24:14)*

View File

@ -60,4 +60,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-home.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-home.ps1 as of 12/07/2023 20:24:14)*

View File

@ -48,4 +48,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-logs.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-logs.ps1 as of 12/07/2023 20:24:14)*

View File

@ -64,4 +64,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-music.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-music.ps1 as of 12/07/2023 20:24:14)*

View File

@ -60,4 +60,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-onedrive.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-onedrive.ps1 as of 12/07/2023 20:24:14)*

View File

@ -62,4 +62,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-pics.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-pics.ps1 as of 12/07/2023 20:24:14)*

View File

@ -62,4 +62,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-public.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-public.ps1 as of 12/07/2023 20:24:14)*

View File

@ -53,4 +53,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-recycle-bin.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-recycle-bin.ps1 as of 12/07/2023 20:24:14)*

View File

@ -80,4 +80,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-repos.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-repos.ps1 as of 12/07/2023 20:24:14)*

View File

@ -57,4 +57,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-root.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-root.ps1 as of 12/07/2023 20:24:14)*

View File

@ -55,4 +55,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-screenshots.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-screenshots.ps1 as of 12/07/2023 20:24:14)*

View File

@ -17,7 +17,7 @@ Example
------- -------
```powershell ```powershell
PS> ./cd-scripts PS> ./cd-scripts
📂C:\Users\Markus\source\repos\PowerShell\Scripts 📂C:\Users\Markus\source\repos\PowerShell\scripts
``` ```
@ -39,7 +39,7 @@ Script Content
This PowerShell script changes the working directory to the PowerShell scripts folder. This PowerShell script changes the working directory to the PowerShell scripts folder.
.EXAMPLE .EXAMPLE
PS> ./cd-scripts PS> ./cd-scripts
📂C:\Users\Markus\source\repos\PowerShell\Scripts 📂C:\Users\Markus\source\repos\PowerShell\scripts
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -58,4 +58,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-scripts.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-scripts.ps1 as of 12/07/2023 20:24:14)*

View File

@ -58,4 +58,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-ssh.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-ssh.ps1 as of 12/07/2023 20:24:14)*

View File

@ -50,4 +50,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-temp.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-temp.ps1 as of 12/07/2023 20:24:14)*

View File

@ -62,4 +62,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-templates.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-templates.ps1 as of 12/07/2023 20:24:14)*

View File

@ -53,4 +53,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-trash.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-trash.ps1 as of 12/07/2023 20:24:14)*

View File

@ -58,4 +58,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-up.ps1 as of 12/07/2023 20:24:14)*

View File

@ -58,4 +58,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up2.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-up2.ps1 as of 12/07/2023 20:24:14)*

View File

@ -58,4 +58,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up3.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-up3.ps1 as of 12/07/2023 20:24:14)*

View File

@ -58,4 +58,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up4.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-up4.ps1 as of 12/07/2023 20:24:14)*

View File

@ -58,4 +58,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-users.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-users.ps1 as of 12/07/2023 20:24:14)*

View File

@ -62,4 +62,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-videos.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-videos.ps1 as of 12/07/2023 20:24:14)*

View File

@ -58,4 +58,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of cd-windows.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of cd-windows.ps1 as of 12/07/2023 20:24:14)*

View File

@ -79,4 +79,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of change-wallpaper.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of change-wallpaper.ps1 as of 12/07/2023 20:24:15)*

View File

@ -67,4 +67,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-admin.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-admin.ps1 as of 12/07/2023 20:24:15)*

View File

@ -48,13 +48,13 @@ Script Content
try { try {
if ($IsLinux) { if ($IsLinux) {
Write-Progress "Querying installed applications..." Write-Progress "Querying installed applications..."
$numPkgs = (apt list --installed 2>/dev/null).Count $numPkgs = (apt list --installed 2>/dev/null).Count
$numSnaps = (snap list).Count - 1 $numSnaps = (snap list).Count - 1
Write-Progress -Completed "." Write-Progress -Completed "."
Write-Host "✅ $numPkgs Debian packages, $numSnaps snaps installed" Write-Host "✅ $numPkgs Debian packages, $numSnaps snaps installed"
} else { } else {
Write-Progress "Querying installed applications..." Write-Progress "Querying installed applications..."
$Apps = Get-AppxPackage $Apps = Get-AppxPackage
Write-Progress -Completed "." Write-Progress -Completed "."
Write-Host "✅ $($Apps.Count) Windows apps installed, " -noNewline Write-Host "✅ $($Apps.Count) Windows apps installed, " -noNewline
@ -75,4 +75,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-apps.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-apps.ps1 as of 12/07/2023 20:24:15)*

View File

@ -48,7 +48,7 @@ Script Content
try { try {
if ($IsLinux) { if ($IsLinux) {
Write-Progress "Querying BIOS details..." Write-Progress "Querying BIOS details..."
$model = (sudo dmidecode -s system-product-name) $model = (sudo dmidecode -s system-product-name)
if ("$model" -ne "") { if ("$model" -ne "") {
$version = (sudo dmidecode -s bios-version) $version = (sudo dmidecode -s bios-version)
@ -76,4 +76,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-bios.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-bios.ps1 as of 12/07/2023 20:24:15)*

View File

@ -24,14 +24,26 @@ Script Content
This PowerShell script queries the CPU status (name, type, speed, temperature, etc) and prints it. This PowerShell script queries the CPU status (name, type, speed, temperature, etc) and prints it.
.EXAMPLE .EXAMPLE
PS> ./check-cpu.ps1 PS> ./check-cpu.ps1
Intel(R) Core(TM) i9-10900X CPU @ 3.70GHz (AMD64, 20 cores, CPU0, 3696MHz, CPU0 socket, 31.3°C) ✅ Intel(R) Core(TM) i9-10900X CPU @ 3.70GHz (AMD64, 20 cores, CPU0, 3696MHz, CPU0 socket, 31.3°C)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
Author: Markus Fleschutz | License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
function GetProcessorTemperature { function GetCPUArchitecture {
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" }
} elseif ([System.Environment]::Is64BitOperatingSystem) { return "64-bit" } else { return "32-bit" }
}
}
function GetCPUTemperature {
$temp = 99999.9 # unsupported $temp = 99999.9 # unsupported
if ($IsLinux) { if ($IsLinux) {
if (Test-Path "/sys/class/thermal/thermal_zone0/temp" -pathType leaf) { if (Test-Path "/sys/class/thermal/thermal_zone0/temp" -pathType leaf) {
@ -48,37 +60,10 @@ function GetProcessorTemperature {
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 status... " Write-Progress "Querying CPU status... "
$status = "✅" $status = "✅"
$celsius = GetProcessorTemperature $arch = GetCPUArchitecture
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"
}
$arch = GetProcessorArchitecture
if ($IsLinux) { if ($IsLinux) {
$cpuName = "$arch CPU" $cpuName = "$arch CPU"
$arch = "" $arch = ""
@ -94,7 +79,20 @@ try {
$socket = "$($details.SocketDesignation) socket, " $socket = "$($details.SocketDesignation) socket, "
} }
$cores = [System.Environment]::ProcessorCount $cores = [System.Environment]::ProcessorCount
Write-Progress -completed " " $celsius = GetCPUTemperature
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"
}
Write-Progress -completed "Done."
Write-Host "$status $cpuName ($($arch)$cores cores, $($deviceID)$($speed)$($socket)$temp)" Write-Host "$status $cpuName ($($arch)$cores cores, $($deviceID)$($speed)$($socket)$temp)"
exit 0 # success exit 0 # success
} catch { } catch {
@ -103,4 +101,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-cpu.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-cpu.ps1 as of 12/07/2023 20:24:15)*

View File

@ -57,4 +57,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-day.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-day.ps1 as of 12/07/2023 20:24:15)*

View File

@ -47,8 +47,8 @@ Script Content
#> #>
try { try {
Write-Progress "Measuring DNS resolution..." Write-Progress "Measuring DNS resolution..."
$table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv" $table = Import-CSV "$PSScriptRoot/../data/popular-domains.csv"
$numRows = $table.Length $numRows = $table.Length
$stopWatch = [system.diagnostics.stopwatch]::startNew() $stopWatch = [system.diagnostics.stopwatch]::startNew()
@ -73,4 +73,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-dns.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-dns.ps1 as of 12/07/2023 20:24:15)*

View File

@ -91,4 +91,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-drive-space.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-drive-space.ps1 as of 12/07/2023 20:24:15)*

View File

@ -76,10 +76,10 @@ function Bytes2String { param([int64]$bytes)
} }
try { try {
Write-Progress "Querying drives..." Write-Progress "Querying drives..."
$drives = Get-PSDrive -PSProvider FileSystem $drives = Get-PSDrive -PSProvider FileSystem
$minLevel *= 1000 * 1000 * 1000 $minLevel *= 1000 * 1000 * 1000
Write-Progress -completed "." Write-Progress -completed " "
foreach($drive in $drives) { foreach($drive in $drives) {
$details = (Get-PSDrive $drive.Name) $details = (Get-PSDrive $drive.Name)
if ($IsLinux) { $name = $drive.Name } else { $name = $drive.Name + ":" } if ($IsLinux) { $name = $drive.Name } else { $name = $drive.Name + ":" }
@ -105,4 +105,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-drives.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-drives.ps1 as of 12/07/2023 20:24:15)*

View File

@ -63,4 +63,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-dusk.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-dusk.ps1 as of 12/07/2023 20:24:15)*

View File

@ -61,4 +61,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-easter-sunday.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-easter-sunday.ps1 as of 12/07/2023 20:24:15)*

View File

@ -75,4 +75,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-file-system.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-file-system.ps1 as of 12/07/2023 20:24:15)*

View File

@ -170,4 +170,4 @@ function Check-Header { param( $path )
Check-Header $Path Check-Header $Path
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-file.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-file.ps1 as of 12/07/2023 20:24:15)*

View File

@ -65,4 +65,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-firewall.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-firewall.ps1 as of 12/07/2023 20:24:15)*

View File

@ -65,4 +65,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-gpu.ps1 as of 10/19/2023 08:11:35)* *(generated by convert-ps2md.ps1 using the comment-based help of check-gpu.ps1 as of 12/07/2023 20:24:15)*

View File

@ -63,4 +63,4 @@ Script Content
exit 0 # success exit 0 # success
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-hardware.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-hardware.ps1 as of 12/07/2023 20:24:15)*

View File

@ -58,4 +58,4 @@ Script Content
exit 0 # success exit 0 # success
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-health.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-health.ps1 as of 12/07/2023 20:24:15)*

View File

@ -61,4 +61,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-independence-day.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-independence-day.ps1 as of 12/07/2023 20:24:15)*

View File

@ -84,4 +84,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-ipv4-address.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-ipv4-address.ps1 as of 12/07/2023 20:24:15)*

View File

@ -98,4 +98,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-ipv6-address.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-ipv6-address.ps1 as of 12/07/2023 20:24:15)*

View File

@ -55,4 +55,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-iss-position.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-iss-position.ps1 as of 12/07/2023 20:24:15)*

View File

@ -87,4 +87,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-mac-address.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-mac-address.ps1 as of 12/07/2023 20:24:15)*

View File

@ -60,4 +60,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-midnight.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-midnight.ps1 as of 12/07/2023 20:24:15)*

View File

@ -57,4 +57,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-month.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-month.ps1 as of 12/07/2023 20:24:15)*

View File

@ -76,4 +76,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-moon-phase.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-moon-phase.ps1 as of 12/07/2023 20:24:15)*

View File

@ -64,4 +64,4 @@ Script Content
exit 0 # success exit 0 # success
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-network.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-network.ps1 as of 12/07/2023 20:24:15)*

View File

@ -60,4 +60,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-new-year.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-new-year.ps1 as of 12/07/2023 20:24:15)*

View File

@ -59,4 +59,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-noon.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-noon.ps1 as of 12/07/2023 20:24:15)*

View File

@ -50,7 +50,7 @@ try {
if ($IsLinux) { if ($IsLinux) {
$Name = $PSVersionTable.OS $Name = $PSVersionTable.OS
if ([System.Environment]::Is64BitOperatingSystem) { $Arch = "64-bit" } else { $Arch = "32-bit" } if ([System.Environment]::Is64BitOperatingSystem) { $Arch = "64-bit" } else { $Arch = "32-bit" }
Write-Host "✅ $Name $Arch" Write-Host "✅ $Name (Linux $Arch)"
} else { } else {
$OS = Get-WmiObject -class Win32_OperatingSystem $OS = Get-WmiObject -class Win32_OperatingSystem
$Name = $OS.Caption -Replace "Microsoft Windows","Windows" $Name = $OS.Caption -Replace "Microsoft Windows","Windows"
@ -73,4 +73,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-os.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-os.ps1 as of 12/07/2023 20:24:15)*

View File

@ -65,4 +65,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-outlook.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-outlook.ps1 as of 12/07/2023 20:24:15)*

View File

@ -94,4 +94,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-password.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-password.ps1 as of 12/07/2023 20:24:15)*

View File

@ -92,4 +92,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-pending-reboot.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-pending-reboot.ps1 as of 12/07/2023 20:24:15)*

View File

@ -90,4 +90,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-ping.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-ping.ps1 as of 12/07/2023 20:24:15)*

View File

@ -92,4 +92,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-power.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-power.ps1 as of 12/07/2023 20:24:15)*

View File

@ -64,4 +64,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-powershell.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-powershell.ps1 as of 12/07/2023 20:24:15)*

View File

@ -76,4 +76,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-ps1-file.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-ps1-file.ps1 as of 12/07/2023 20:24:15)*

View File

@ -98,4 +98,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-ram.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-ram.ps1 as of 12/07/2023 20:24:15)*

View File

@ -128,4 +128,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-repo.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-repo.ps1 as of 12/07/2023 20:24:15)*

View File

@ -56,4 +56,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-santa.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-santa.ps1 as of 12/07/2023 20:24:15)*

View File

@ -48,11 +48,11 @@ function Bytes2String { param([int64]$Bytes)
} }
try { try {
Write-Progress "(1/3) Searching for smartmontools..." 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 "(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 {
@ -60,7 +60,7 @@ try {
} }
foreach($Device in $Devices) { foreach($Device in $Devices) {
Write-Progress "(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 "#") {
@ -95,4 +95,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-smart-devices.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-smart-devices.ps1 as of 12/07/2023 20:24:15)*

View File

@ -69,4 +69,4 @@ Script Content
exit 0 # success exit 0 # success
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-software.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-software.ps1 as of 12/07/2023 20:24:15)*

View File

@ -84,4 +84,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-subnet-mask.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-subnet-mask.ps1 as of 12/07/2023 20:24:15)*

View File

@ -105,4 +105,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-swap-space.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-swap-space.ps1 as of 12/07/2023 20:24:16)*

View File

@ -100,4 +100,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-symlinks.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-symlinks.ps1 as of 12/07/2023 20:24:16)*

View File

@ -65,4 +65,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-time-zone.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-time-zone.ps1 as of 12/07/2023 20:24:16)*

View File

@ -61,4 +61,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-uptime.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-uptime.ps1 as of 12/07/2023 20:24:16)*

View File

@ -65,4 +65,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-vpn.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-vpn.ps1 as of 12/07/2023 20:24:16)*

View File

@ -81,4 +81,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-weather.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-weather.ps1 as of 12/07/2023 20:24:16)*

View File

@ -54,4 +54,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-week.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-week.ps1 as of 12/07/2023 20:24:16)*

View File

@ -72,4 +72,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-wind.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-wind.ps1 as of 12/07/2023 20:24:16)*

View File

@ -60,4 +60,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-windows-system-files.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-windows-system-files.ps1 as of 12/07/2023 20:24:16)*

View File

@ -6,9 +6,9 @@ This PowerShell script checks the given XML file for validity.
Parameters Parameters
---------- ----------
```powershell ```powershell
PS> ./check-xml-file.ps1 [[-file] <String>] [<CommonParameters>] PS> ./check-xml-file.ps1 [[-path] <String>] [<CommonParameters>]
-file <String> -path <String>
Specifies the path to the XML file to check Specifies the path to the XML file to check
Required? false Required? false
@ -25,8 +25,8 @@ PS> ./check-xml-file.ps1 [[-file] <String>] [<CommonParameters>]
Example Example
------- -------
```powershell ```powershell
PS> ./check-xml-file myfile.xml PS> ./check-xml-file.ps1 myfile.xml
XML file is valid Valid XML in 'myfile.xml'
``` ```
@ -43,30 +43,29 @@ Script Content
```powershell ```powershell
<# <#
.SYNOPSIS .SYNOPSIS
Checks the given XML file for validity Verifies the given XML file
.DESCRIPTION .DESCRIPTION
This PowerShell script checks the given XML file for validity. This PowerShell script checks the given XML file for validity.
.PARAMETER file .PARAMETER path
Specifies the path to the XML file to check Specifies the path to the XML file to check
.EXAMPLE .EXAMPLE
PS> ./check-xml-file myfile.xml PS> ./check-xml-file.ps1 myfile.xml
✔️ XML file is valid ✔️ Valid XML in 'myfile.xml'
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
Author: Markus Fleschutz | License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
param([string]$file = "") param([string]$path = "")
try { try {
if ($file -eq "" ) { $file = read-host "Enter path to XML file" } if ($path -eq "" ) { $path = Read-Host "Enter path to XML file" }
$XmlFile = Get-Item $file $XmlFile = Get-Item $path
$script:ErrorCount = 0
# Perform the XSD Validation # Perform the XSD Validation
$script:ErrorCount = 0
$ReaderSettings = New-Object -TypeName System.Xml.XmlReaderSettings $ReaderSettings = New-Object -TypeName System.Xml.XmlReaderSettings
$ReaderSettings.ValidationType = [System.Xml.ValidationType]::Schema $ReaderSettings.ValidationType = [System.Xml.ValidationType]::Schema
$ReaderSettings.ValidationFlags = [System.Xml.Schema.XmlSchemaValidationFlags]::ProcessInlineSchema -bor [System.Xml.Schema.XmlSchemaValidationFlags]::ProcessSchemaLocation $ReaderSettings.ValidationFlags = [System.Xml.Schema.XmlSchemaValidationFlags]::ProcessInlineSchema -bor [System.Xml.Schema.XmlSchemaValidationFlags]::ProcessSchemaLocation
@ -76,11 +75,10 @@ try {
$Reader.Close() $Reader.Close()
if ($script:ErrorCount -gt 0) { if ($script:ErrorCount -gt 0) {
write-warning "Invalid XML file" throw "Invalid XML in '$path'"
exit 1
} }
"✔️ XML file is valid" "✔️ Valid XML in '$path'"
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
@ -88,4 +86,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of check-xml-file.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of check-xml-file.ps1 as of 12/07/2023 20:24:16)*

86
docs/check-xml-files.md Normal file
View File

@ -0,0 +1,86 @@
*check-xml-files.ps1*
================
This PowerShell script verifies each XML file in the given directory tree for validity.
Parameters
----------
```powershell
PS> ./check-xml-files.ps1 [[-path] <String>] [<CommonParameters>]
-path <String>
Specifies the path to the directory tree (current working dir by default)
Required? false
Position? 1
Default value "$PWD"
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-xml-files.ps1 C:\Windows
...
Checked 3607 XML files within C:\Windows in 174 sec
```
Notes
-----
Author: Markus Fleschutz | License: CC0
Related Links
-------------
https://github.com/fleschutz/PowerShell
Script Content
--------------
```powershell
<#
.SYNOPSIS
Checks XML files in a directory tree
.DESCRIPTION
This PowerShell script verifies each XML file in the given directory tree for validity.
.PARAMETER path
Specifies the path to the directory tree (current working dir by default)
.EXAMPLE
PS> ./check-xml-files.ps1 C:\Windows
...
✔️ Checked 3607 XML files within C:\Windows in 174 sec
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([string]$path = "$PWD")
try {
$stopWatch = [system.diagnostics.stopwatch]::startNew()
$path = Resolve-Path "$path"
[int]$count = 0
Write-Progress "Checking all *.xml files under $path..."
Get-ChildItem -path "$path" -attributes !Directory -recurse -force | Where-Object { $_.Name -like "*.xml*" } | Foreach-Object {
& $PSScriptRoot/check-xml-file.ps1 "$($_.FullName)"
$count++
}
Write-Progress -completed "Done."
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"✔️ Checked $count XML files within $path in $elapsed sec"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}
```
*(generated by convert-ps2md.ps1 using the comment-based help of check-xml-files.ps1 as of 12/07/2023 20:24:16)*

View File

@ -101,4 +101,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of clean-repo.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of clean-repo.ps1 as of 12/07/2023 20:24:16)*

View File

@ -100,4 +100,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of clean-repos.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of clean-repos.ps1 as of 12/07/2023 20:24:16)*

View File

@ -60,4 +60,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of clear-dns-cache.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of clear-dns-cache.ps1 as of 12/07/2023 20:24:16)*

View File

@ -58,4 +58,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of clear-recycle-bin.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of clear-recycle-bin.ps1 as of 12/07/2023 20:24:16)*

View File

@ -1,14 +1,14 @@
*clone-repos.ps1* *clone-repos.ps1*
================ ================
This PowerShell script clones popular Git repositories into a target directory. This PowerShell script clones popular Git repositories into a common target directory.
Parameters Parameters
---------- ----------
```powershell ```powershell
PS> ./clone-repos.ps1 [[-TargetDir] <String>] [<CommonParameters>] PS> ./clone-repos.ps1 [[-targetDir] <String>] [<CommonParameters>]
-TargetDir <String> -targetDir <String>
Specifies the file path to the target directory (current working directory by default) Specifies the file path to the target directory (current working directory by default)
Required? false Required? false
@ -25,12 +25,9 @@ PS> ./clone-repos.ps1 [[-TargetDir] <String>] [<CommonParameters>]
Example Example
------- -------
```powershell ```powershell
PS> ./clone-repos C:\Repos PS> ./clone-repos C:\MyRepos
(1) Searching for Git executable... git version 2.41.0.windows.3
(2) Reading Data/popular-repositories.csv... 28 repos
(3) Checking target folder... 📂repos
(4/32) Cloning into 📂base256unicode (dev tool)...
... ...
Cloned 29 of 29 Git repos into 📂MyRepos in 123 sec
``` ```
@ -49,69 +46,65 @@ Script Content
.SYNOPSIS .SYNOPSIS
Clones Git repos Clones Git repos
.DESCRIPTION .DESCRIPTION
This PowerShell script clones popular Git repositories into a target directory. This PowerShell script clones popular Git repositories into a common target directory.
.PARAMETER targetDir .PARAMETER targetDir
Specifies the file path to the target directory (current working directory by default) Specifies the file path to the target directory (current working directory by default)
.EXAMPLE .EXAMPLE
PS> ./clone-repos C:\Repos PS> ./clone-repos C:\MyRepos
⏳ (1) Searching for Git executable... git version 2.41.0.windows.3
⏳ (2) Reading Data/popular-repositories.csv... 28 repos
⏳ (3) Checking target folder... 📂repos
⏳ (4/32) Cloning into 📂base256unicode (dev tool)...
... ...
✔️ Cloned 29 of 29 Git repos into 📂MyRepos in 123 sec
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
Author: Markus Fleschutz | License: CC0 Author: Markus Fleschutz | License: CC0
#> #>
param([string]$TargetDir = "$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) Reading Data/popular-repositories.csv... " -noNewline Write-Host "⏳ (2) Reading data/popular-repositories.csv... " -noNewline
$Table = Import-CSV "$PSScriptRoot/../Data/popular-repositories.csv" $table = Import-CSV "$PSScriptRoot/../data/popular-repositories.csv"
$NumEntries = $Table.count $total = $table.count
Write-Host "$NumEntries repos" Write-Host "$total repos"
$TargetDirName = (Get-Item "$TargetDir").Name $targetDirName = (Get-Item "$targetDir").Name
Write-Host "⏳ (3) Checking target folder... 📂$TargetDirName" Write-Host "⏳ (3) Checking target folder... 📂$targetDirName"
if (-not(Test-Path "$TargetDir" -pathType container)) { throw "Can't access directory: $TargetDir" } 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]$FolderName = $Row.FOLDERNAME [string]$folderName = $row.FOLDERNAME
[string]$Category = $Row.CATEGORY [string]$category = $row.CATEGORY
[string]$Branch = $Row.BRANCH [string]$URL = $row.URL
[string]$Shallow = $Row.SHALLOW [string]$branch = $row.BRANCH
[string]$URL = $Row.URL [string]$shallow = $row.SHALLOW
$Step++ $step++
if (Test-Path "$TargetDir/$FolderName" -pathType container) { if (Test-Path "$targetDir/$folderName" -pathType container) {
"⏳ ($Step/$($NumEntries + 4)) Skipping existing 📂$FolderName ($Category)..." "⏳ ($step/$($total + 4)) Skipping existing 📂$folderName (a $category)..."
$Skipped++ $skipped++
continue } elseif ($shallow -eq "yes") {
} "⏳ ($step/$($total + 4)) Cloning into 📂$folderName (a $category, $branch branch, shallow)..."
if ($Shallow -eq "yes") { & git clone --branch "$branch" --single-branch --recurse-submodules "$URL" "$targetDir/$folderName"
"⏳ ($Step/$($NumEntries + 4)) Cloning into 📂$FolderName ($Category) - $Branch branch only..." if ($lastExitCode -ne "0") { throw "'git clone --branch $branch $URL' failed with exit code $lastExitCode" }
& git clone --branch "$Branch" --single-branch --recurse-submodules "$URL" "$TargetDir/$FolderName" $cloned++
if ($lastExitCode -ne "0") { throw "'git clone --branch $Branch $URL' failed with exit code $lastExitCode" }
} else { } else {
"⏳ ($Step/$($NumEntries + 4)) Cloning into 📂$FolderName ($Category) - $Branch branch with full history..." "⏳ ($step/$($total + 4)) Cloning into 📂$folderName (a $category, $branch branch, full history)..."
& git clone --branch "$Branch" --recurse-submodules "$URL" "$TargetDir/$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" }
$clone++
} }
$Cloned++
} }
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds [int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"✔️ Cloning $Cloned of $NumEntries Git repos into folder 📂$TargetDirName took $Elapsed sec" "✔️ Cloned $cloned of $total Git repos into 📂$targetDirName 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])"
@ -119,4 +112,4 @@ try {
} }
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of clone-repos.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of clone-repos.ps1 as of 12/07/2023 20:24:16)*

View File

@ -48,4 +48,4 @@ Stop-Process -name "CalculatorApp"
exit 0 # success exit 0 # success
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of close-calculator.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of close-calculator.ps1 as of 12/07/2023 20:24:16)*

View File

@ -48,4 +48,4 @@ Script Content
exit 0 # success exit 0 # success
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of close-chrome.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of close-chrome.ps1 as of 12/07/2023 20:24:16)*

View File

@ -48,4 +48,4 @@ Script Content
exit 0 # success exit 0 # success
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of close-cortana.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of close-cortana.ps1 as of 12/07/2023 20:24:16)*

View File

@ -52,4 +52,4 @@ if ($lastExitCode -ne "0") {
exit 0 # success exit 0 # success
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of close-edge.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of close-edge.ps1 as of 12/07/2023 20:24:16)*

View File

@ -48,4 +48,4 @@ Script Content
exit 0 # success exit 0 # success
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of close-file-explorer.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of close-file-explorer.ps1 as of 12/07/2023 20:24:16)*

View File

@ -48,4 +48,4 @@ Script Content
exit 0 # success exit 0 # success
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of close-firefox.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of close-firefox.ps1 as of 12/07/2023 20:24:16)*

View File

@ -52,4 +52,4 @@ if ($lastExitCode -ne "0") {
exit 0 # success exit 0 # success
``` ```
*(generated by convert-ps2md.ps1 using the comment-based help of close-git-extensions.ps1 as of 10/19/2023 08:11:36)* *(generated by convert-ps2md.ps1 using the comment-based help of close-git-extensions.ps1 as of 12/07/2023 20:24:16)*

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