mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-08 20:54:38 +02:00
Merge branch 'master' into master
This commit is contained in:
88
Docs/FAQ.md
88
Docs/FAQ.md
@ -1,5 +1,5 @@
|
||||
🤔 PowerShell FAQ
|
||||
==================
|
||||
 PowerShell FAQ
|
||||
===================================================
|
||||
|
||||
<details><summary>What is PowerShell?</summary>
|
||||
|
||||
@ -17,46 +17,48 @@
|
||||
|
||||
✔️ **It's open-source and free** - see the Github repository at: https://github.com/PowerShell/PowerShell
|
||||
|
||||
✔️ **It's fully documented** - see the PowerShell documentation at: https://docs.microsoft.com/en-us/powershell/
|
||||
✔️ **It's fully documented** - see the PowerShell documentation at: https://docs.microsoft.com/en-us/powershell
|
||||
</details>
|
||||
|
||||
<details><summary>How to install PowerShell on Linux?</summary>
|
||||
|
||||
1. On Linux with Snap support just execute:
|
||||
1. **On Linux with Snap support just execute:**
|
||||
```
|
||||
$ snap install PowerShell
|
||||
$ ln -s /snap/bin/pwsh /usr/bin/pwsh
|
||||
```
|
||||
2 Otherwise visit: https://github.com/PowerShell/PowerShell for installation (scroll down to 'Get PowerShell').
|
||||
2. **Otherwise, please visit:** https://github.com/PowerShell/PowerShell **and scroll down to: 'Get PowerShell'.**
|
||||
</details>
|
||||
|
||||
<details><summary>How to install PowerShell on MacOS?</summary>
|
||||
|
||||
Visit: https://github.com/PowerShell/PowerShell for installation (scroll down to 'Get PowerShell').
|
||||
**Please visit:** https://github.com/PowerShell/PowerShell **and scroll down to: 'Get PowerShell'.**
|
||||
</details>
|
||||
|
||||
<details><summary>How to install PowerShell on Windows?</summary>
|
||||
|
||||
Good news: it's preinstalled, **but** the script execution policy is *restricted* (forbidden) by default! To change this: open the *Windows PowerShell (Administrator)* console and enter:
|
||||
**Good news:** it's preinstalled, **but** the script execution policy is *restricted* (forbidden) by default! To change this: open the *Windows PowerShell (Administrator)* console and enter:
|
||||
```
|
||||
PS> Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser
|
||||
```
|
||||
NOTE: the group policy object (GPO) settings of your organization might disallow changes. In that case contact your system administrator for help.
|
||||
**NOTE:** the group policy object (GPO) settings of your organization might disallow changes. In that case contact your system administrator for help.
|
||||
</details>
|
||||
|
||||
<details><summary>How to get this PowerShell script collection?</summary>
|
||||
<details><summary>How to get the Mega collection of PowerShell scripts?</summary>
|
||||
|
||||
1. When using **Git**, execute in a terminal window: `> git clone https://github.com/fleschutz/PowerShell`
|
||||
2. **Otherwise,** download and unzip it from: https://github.com/fleschutz/PowerShell/archive/master.zip
|
||||
1. **When using Git, execute in a terminal window:** `> git clone https://github.com/fleschutz/PowerShell`
|
||||
2. **Otherwise, download and unzip it from:** https://github.com/fleschutz/PowerShell/archive/master.zip
|
||||
</details>
|
||||
|
||||
<details><summary>How to execute PowerShell scripts on Windows?</summary>
|
||||
|
||||
1. In the Windows desktop: right-click the script and select: *Execute with PowerShell*
|
||||
2. In a command-line interface (CLI, e.g. *Windows Terminal*, either local or remote via SSH) by typing: `./<FILENAME_OF_SCRIPT>`.
|
||||
3. By connecting a context menu item with a script.
|
||||
4. By voice control, e.g. see repo [talk2windows](https://github.com/fleschutz/talk2windows) for more information.
|
||||
5. By using automation software, e.g. [Jenkins](https://www.jenkins.io).
|
||||
1. **In the Windows desktop:** right-click the script and select: *Execute with PowerShell*
|
||||
2. **On the command-line:** launch a terminal application (e.g. *Windows Terminal*), then type: `./<SCRIPT>.ps1`.
|
||||
3. **By remote login:** use *SSH* to login to the Windows machine, then type: `cd <PATH>`, then: `./<SCRIPT>.ps1`.
|
||||
4. **By context menu:** see below.
|
||||
5. **By voice control:** see repo [talk2windows](https://github.com/fleschutz/talk2windows) for more information.
|
||||
6. **By automation software:** see [Jenkins.io](https://www.jenkins.io) or [AutoHotKey.com](https://www.autohotkey.com/) for more information.
|
||||
7. **Automatically on login:** see below.
|
||||
</details>
|
||||
|
||||
<details><summary>How to execute PowerShell scripts in Windows context menus?</summary>
|
||||
@ -67,33 +69,35 @@ NOTE: the group policy object (GPO) settings of your organization might disallow
|
||||
|
||||
<details><summary>How to execute PowerShell scripts automatically on login in Windows?</summary>
|
||||
|
||||
1. Open the **File Explorer** with your **Autostart folder** (usually at: C:\Users\YOUR_USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup).
|
||||
2. Copy the script (or a link to it) into this folder.
|
||||
1. **Open the *File Explorer* with your Autostart folder** (usually at: `C:\Users\YOUR_USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup`).
|
||||
2. **Copy the script (or a link to it) into this folder.**
|
||||
</details>
|
||||
|
||||
<details><summary>How to execute PowerShell scripts in Jenkins?</summary>
|
||||
|
||||
1. Install the Jenkins plugin **PowerShell plugin** (it uses PowerShell.exe on Windows and pwsh on Linux).
|
||||
2. Add or reference your PowerShell scripts in the Jenkins jobs or in your Jenkinsfiles.
|
||||
1. **Install the Jenkins plugin:** `PowerShell plugin` (it uses PowerShell.exe on Windows and pwsh on Linux).
|
||||
2. **Add or reference your PowerShell scripts in the Jenkins jobs or in your Jenkinsfiles.**
|
||||
</details>
|
||||
|
||||
<details><summary>How to learn PowerShell?</summary>
|
||||
|
||||
* Please find **tutorials** at: https://www.guru99.com/powershell-tutorial.html
|
||||
* See a **cheat sheet** at: [PowerShell/Docs/cheat-sheet.md](cheat-sheet.md)
|
||||
* The official PowerShell **documentation** is at: https://docs.microsoft.com/en-us/powershell/
|
||||
* **Please find tutorials at:** https://www.guru99.com/powershell-tutorial.html
|
||||
* **See a cheat sheet at:** [PowerShell/Docs/cheat-sheet.md](cheat-sheet.md)
|
||||
* **The official PowerShell documentation can be found here:** https://docs.microsoft.com/en-us/powershell/
|
||||
</details>
|
||||
|
||||
<details><summary>What about security?</summary>
|
||||
|
||||
1. Execute scripts only that you trust (and/or where you have checked the code before)!
|
||||
2. Prefer SSH Remoting instead of PowerShell Remoting
|
||||
3. More recommendations by NSA and cyber security centers in the U.S. (CISA), New Zealand (NZ NCSC), and the U.K. (NCSC-UK) can be found here: https://media.defense.gov/2022/Jun/22/2003021689/-1/-1/1/CSI_KEEPING_POWERSHELL_SECURITY_MEASURES_TO_USE_AND_EMBRACE_20220622.PDF
|
||||
1. **Execute scripts only that you trust (and/or where you have checked the code before)!**
|
||||
2. **Prefer SSH Remoting instead of PowerShell Remoting**
|
||||
3. **More recommendations by NSA and cyber security centers in the U.S. (CISA), New Zealand (NZ NCSC), and the U.K. (NCSC-UK) can be found here:** https://media.defense.gov/2022/Jun/22/2003021689/-1/-1/1/CSI_KEEPING_POWERSHELL_SECURITY_MEASURES_TO_USE_AND_EMBRACE_20220622.PDF
|
||||
</details>
|
||||
|
||||
<details><summary>Why do some scripts show gibberish characters?</summary>
|
||||
|
||||
**Your current terminal application doesn't support Unicode characters used by those PowerShell scripts. Use a modern one such as *Windows Terminal*, please.**
|
||||
**Your current terminal application doesn't support Unicode characters used by those PowerShell scripts.**
|
||||
|
||||
**Use a modern one such as *Windows Terminal*, please.**
|
||||
</details>
|
||||
|
||||
<details><summary>How to configure PowerShell as my default shell on Linux?</summary>
|
||||
@ -122,40 +126,42 @@ Want to use the PowerShell scripts everywhere on the command-line? Then you need
|
||||
* **PowerShell Plus** - an all in one IDE.
|
||||
* **Atom package** - an add-on with PowerShell language support for Atom.
|
||||
* **SublimeText package** - an add-on with PowerShell language support for Sublime Text.
|
||||
* or your **favorite text editor** as an alternative.
|
||||
* or simply your **favorite text editor** as an alternative.
|
||||
</details>
|
||||
|
||||
<details><summary>How to write good PowerShell scripts?</summary>
|
||||
|
||||
**Good PowerShell scripts are both user-friendly and platform-independent. As a starting point I recommend the following:**
|
||||
|
||||
* As filename use the `<verb>-<object>.ps1` scheme. Approved verbs can be found here: [https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands](https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands)
|
||||
* Use `UTF-8 BOM` encoding to support Unicode characters in the script.
|
||||
* Add a comment-based help at the beginning with: `.SYNOPSIS`, `.DESCRIPTION`, `.PARAMETER`, `.EXAMPLE`, `.LINK`, and `.NOTES`.
|
||||
* Check the requirements for the script, e.g. `#Requires -RunAsAdministrator`, or `#Requires -Version 3`
|
||||
* Prefer command-line options, else ask the user for help
|
||||
* Recommended is `Set-StrictMode -Version Latest` to enable additional error checking.
|
||||
* For readibility use UpperCamelCase for variables and functions, lowerCamelCase for everything else.
|
||||
* Set *execute* file permissions for Linux: `chmod a+rx <filename>`
|
||||
* On success exit with error code 0 (`exit 0`), otherwise print the error with keyword "ERROR:" (to support log parsers) and exit the error code (mostly 1)
|
||||
* Use the `<verb>-<noun>.ps1` scheme for filenames (e.g. *new-symlink.ps1*). Official approved verbs can be found here: [https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands](https://learn.microsoft.com/en-us/powershell/scripting/developer/cmdlet/approved-verbs-for-windows-powershell-commands)
|
||||
* Use **UTF-8 BOM** encoding to support Unicode characters in the script.
|
||||
* Add a **comment-based help** at the beginning with: `.SYNOPSIS`, `.DESCRIPTION`, `.PARAMETER`, `.EXAMPLE`, `.LINK`, and `.NOTES`.
|
||||
* Check the **requirements** for the script, e.g. `#Requires -RunAsAdministrator`, or `#Requires -Version 3`
|
||||
* Prefer **command-line options**, else ask the user for help
|
||||
* Recommended is **Set-StrictMode -Version Latest** to enable additional error checking.
|
||||
* For readibility use **lowerCamelCase** to name variables, functions, etc.
|
||||
* Set execute file permissions for Linux: **chmod a+rx <filename>**
|
||||
* On success exit with error code 0 (**exit 0**), otherwise print the error with keyword **ERROR:** (to support log parsers) and exit the error code (mostly 1)
|
||||
</details>
|
||||
|
||||
<details><summary>Where's the Star History of this repo?</summary>
|
||||
<details><summary>Where's the Star History of this repository?</summary>
|
||||
|
||||
[](https://star-history.com/#fleschutz/PowerShell&Date)
|
||||
</details>
|
||||
|
||||
<details><summary>How to contribute or how to report a bug?</summary>
|
||||
|
||||
**If you find something bad (like a bug, error, or any issue), please report it here by opening an Issue. Or even better: Fork the repository, add or fix the script and submit a pull request, so others can participate too.**
|
||||
**If you find something bad (like a bug, error, or any issue), please report it here by opening an Issue.**
|
||||
|
||||
**Or even better: Fork the repository, add or fix the script and submit a pull request, so others can participate too.**
|
||||
</details>
|
||||
|
||||
<details><summary>How to donate to this project?</summary>
|
||||
|
||||
**Just follow this link: [https://www.paypal.com/paypalme/Fleschutz](https://www.paypal.com/paypalme/Fleschutz). Thank you very much!**
|
||||
**Thanks a lot! Just follow this link:** [https://www.paypal.com/paypalme/Fleschutz](https://www.paypal.com/paypalme/Fleschutz)
|
||||
</details>
|
||||
|
||||
<details><summary>What if my question is not answered here?</summary>
|
||||
|
||||
**Just send your question by e-mail to: markus.fleschutz [at] gmail.com**
|
||||
**Just send your question by e-mail to:** `markus.fleschutz [at] gmail.com`
|
||||
</details>
|
||||
|
@ -6,10 +6,10 @@ This PowerShell script adds firewall rules for the given executable. Administrat
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./add-firewall-rules.ps1 [[-PathToExecutables] <String>] [<CommonParameters>]
|
||||
PS> ./add-firewall-rules.ps1 [[-PathToExecutables] <String>] [[-Direction] <String>] [[-FirewallProfile] <Array>] [<CommonParameters>]
|
||||
|
||||
-PathToExecutables <String>
|
||||
Specifies the path to the executables
|
||||
Specifies the path to the executables.
|
||||
|
||||
Required? false
|
||||
Position? 1
|
||||
@ -17,6 +17,23 @@ PS> ./add-firewall-rules.ps1 [[-PathToExecutables] <String>] [<CommonParameters>
|
||||
Accept pipeline input? false
|
||||
Accept wildcard characters? false
|
||||
|
||||
-Direction <String>
|
||||
Specifies the direction for the firewall rule. Can be 'Inbound' or 'Outbound'. Default is 'Inbound'.
|
||||
|
||||
Required? false
|
||||
Position? 2
|
||||
Default value Inbound
|
||||
Accept pipeline input? false
|
||||
Accept wildcard characters? false
|
||||
|
||||
-FirewallProfile <Array>
|
||||
|
||||
Required? false
|
||||
Position? 3
|
||||
Default value @("Domain", "Private")
|
||||
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.
|
||||
@ -25,10 +42,7 @@ PS> ./add-firewall-rules.ps1 [[-PathToExecutables] <String>] [<CommonParameters>
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./add-firewall-rules.ps1 C:\MyApp\bin
|
||||
Adding firewall rule for C:\MyApp\bin\app1.exe
|
||||
Adding firewall rule for C:\MyApp\bin\app2.exe
|
||||
...
|
||||
PS> ./add-firewall-rules.ps1 -PathToExecutables C:\MyApp\bin -Direction Outbound -Profile Private
|
||||
|
||||
```
|
||||
|
||||
@ -45,16 +59,17 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Adds firewall rules for executables (needs admin rights)
|
||||
Adds firewall rules for executables (needs admin rights).
|
||||
.DESCRIPTION
|
||||
This PowerShell script adds firewall rules for the given executable. Administrator rights are required.
|
||||
.PARAMETER PathToExecutables
|
||||
Specifies the path to the executables
|
||||
Specifies the path to the executables.
|
||||
.PARAMETER Direction
|
||||
Specifies the direction for the firewall rule. Can be 'Inbound' or 'Outbound'. Default is 'Inbound'.
|
||||
.PARAMETER Profile
|
||||
Specifies the firewall profile. Can be 'Domain', 'Private', or 'Public'. Multiple values can be specified as an array.
|
||||
.EXAMPLE
|
||||
PS> ./add-firewall-rules.ps1 C:\MyApp\bin
|
||||
Adding firewall rule for C:\MyApp\bin\app1.exe
|
||||
Adding firewall rule for C:\MyApp\bin\app2.exe
|
||||
...
|
||||
PS> ./add-firewall-rules.ps1 -PathToExecutables C:\MyApp\bin -Direction Outbound -Profile Private
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -63,50 +78,39 @@ Script Content
|
||||
|
||||
#Requires -RunAsAdministrator
|
||||
|
||||
param([string]$PathToExecutables = "")
|
||||
|
||||
$command = '
|
||||
$output = ''Firewall rules for path '' + $args[0]
|
||||
write-output $output
|
||||
for($i = 1; $i -lt $args.count; $i++){
|
||||
$path = $args[0]
|
||||
$path += ''\''
|
||||
$path += $args[$i]
|
||||
|
||||
$null = $args[$i] -match ''[^\\]*\.exe$''
|
||||
$name = $matches[0]
|
||||
$output = ''Adding firewall rule for '' + $name
|
||||
write-output $output
|
||||
$null = New-NetFirewallRule -DisplayName $name -Direction Inbound -Program $path -Profile Domain, Private -Action Allow
|
||||
}
|
||||
write-host -foregroundColor green -noNewline ''Done - press any key to continue...'';
|
||||
[void]$Host.UI.RawUI.ReadKey(''NoEcho,IncludeKeyDown'');
|
||||
'
|
||||
|
||||
param(
|
||||
[string]$PathToExecutables = "",
|
||||
[string]$Direction = "Inbound",
|
||||
[array]$FirewallProfile = @("Domain", "Private")
|
||||
)
|
||||
|
||||
try {
|
||||
if ($PathToExecutables -eq "" ) {
|
||||
$PathToExecutables = read-host "Enter path to executables"
|
||||
if (-not $PathToExecutables) {
|
||||
$PathToExecutables = Read-Host "Enter path to executables"
|
||||
}
|
||||
|
||||
$PathToExecutables = Convert-Path -Path $PathToExecutables
|
||||
$AbsPath = Convert-Path -Path $PathToExecutables
|
||||
$Executables = Get-ChildItem -Path $AbsPath -Filter "*.exe"
|
||||
|
||||
$Apps = Get-ChildItem "$PathToExecutables\*.exe" -Name
|
||||
|
||||
if($Apps.count -eq 0){
|
||||
write-warning "No executables found. No Firewall rules have been created."
|
||||
Write-Host -NoNewhLine 'Press any key to continue...';
|
||||
[void]$Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');
|
||||
exit 1
|
||||
if (-not $Executables) {
|
||||
Write-Warning "No executables found. No Firewall rules have been created."
|
||||
Read-Host "Press Enter to continue..."
|
||||
return
|
||||
}
|
||||
|
||||
$arg = "PathToExecutables $Apps"
|
||||
Start-Process powershell -Verb runAs -ArgumentList "-command & {$command} $arg"
|
||||
exit 0 # success
|
||||
foreach ($exe in $Executables) {
|
||||
$exeName = $exe.Name
|
||||
$exeFullPath = $exe.FullName
|
||||
|
||||
Write-Output "Adding firewall rule for $exeName"
|
||||
New-NetFirewallRule -DisplayName $exeName -Direction $Direction -Program $exeFullPath -Profile $FirewallProfile -Action Allow
|
||||
}
|
||||
|
||||
Write-Host -ForegroundColor Green "Done"
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
Write-Error "Error in line $($_.InvocationInfo.ScriptLineNumber): $($_.Exception.Message)"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of add-firewall-rules.ps1 as of 08/06/2023 21:36:04)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of add-firewall-rules.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -79,4 +79,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of add-memo.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of add-memo.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -71,4 +71,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of alert.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of alert.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -177,4 +177,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of build-repo.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of build-repo.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -82,4 +82,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of build-repos.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of build-repos.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-autostart.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-autostart.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-crashdumps.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-crashdumps.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -64,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-desktop.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-desktop.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -64,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-docs.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-docs.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -64,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-downloads.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-downloads.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-dropbox.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-dropbox.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -64,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-etc.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-etc.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-fonts.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-fonts.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-home.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-home.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -48,4 +48,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-logs.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-logs.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -64,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-music.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-music.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-onedrive.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-onedrive.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -62,4 +62,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-pics.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-pics.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -62,4 +62,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-public.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-public.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -53,4 +53,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-recycle-bin.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-recycle-bin.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -80,4 +80,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-repos.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-repos.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -57,4 +57,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-root.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-root.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -55,4 +55,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-screenshots.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-screenshots.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-scripts.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-scripts.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-ssh.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-ssh.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -50,4 +50,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-temp.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-temp.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -62,4 +62,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-templates.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-templates.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -53,4 +53,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-trash.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-trash.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up2.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up2.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up3.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up3.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up4.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-up4.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-users.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-users.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -62,4 +62,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-videos.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-videos.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-windows.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of cd-windows.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -79,4 +79,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of change-wallpaper.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of change-wallpaper.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -1,5 +1,5 @@
|
||||
PowerShell Cheat Sheet
|
||||
======================
|
||||
 PowerShell Cheat Sheet
|
||||
===========================================================
|
||||
|
||||
Basic Commands
|
||||
--------------
|
||||
@ -325,4 +325,4 @@ $Params = @{
|
||||
Method = 'Get'
|
||||
}
|
||||
Invoke-RestMethod @Params # Call a REST API, using the HTTP GET method
|
||||
```
|
||||
```
|
||||
|
@ -1,7 +1,7 @@
|
||||
*check-apps.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script queries the application status and prints it.
|
||||
This PowerShell script queries the installed applications and prints it.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -17,7 +17,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-apps.ps1
|
||||
✅ 119 apps installed, 11 upgrades available
|
||||
✅ 119 Windows apps installed, 11 upgrades available
|
||||
|
||||
```
|
||||
|
||||
@ -36,10 +36,10 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Query the app status
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries the application status and prints it.
|
||||
This PowerShell script queries the installed applications and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-apps.ps1
|
||||
✅ 119 apps installed, 11 upgrades available
|
||||
✅ 119 Windows apps installed, 11 upgrades available
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -48,12 +48,16 @@ Script Content
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$NumSnaps = (snap list).Count - 1
|
||||
Write-Host "✅ $($NumSnaps) snaps installed"
|
||||
Write-Progress "⏳ Querying installed applications..."
|
||||
$numPkgs = (apt list --installed 2>/dev/null).Count
|
||||
$numSnaps = (snap list).Count - 1
|
||||
Write-Progress -Completed "."
|
||||
Write-Host "✅ $numPkgs Debian packages, $numSnaps snaps installed"
|
||||
} else {
|
||||
Write-Progress "⏳ Querying installed apps and updates..."
|
||||
Write-Progress "⏳ Querying installed applications..."
|
||||
$Apps = Get-AppxPackage
|
||||
$Status = "✅ $($Apps.Count) apps installed"
|
||||
Write-Progress -Completed "."
|
||||
Write-Host "✅ $($Apps.Count) Windows apps installed, " -noNewline
|
||||
|
||||
[int]$NumNonOk = 0
|
||||
foreach($App in $Apps) { if ($App.Status -ne "Ok") { $NumNonOk++ } }
|
||||
@ -62,8 +66,7 @@ try {
|
||||
if ($NumErrors -gt 0) { $Status += ", $NumErrors errors" }
|
||||
|
||||
$NumUpdates = (winget upgrade --include-unknown).Count - 5
|
||||
Write-Progress -Completed "."
|
||||
Write-Host "$Status, $NumUpdates upgrades available"
|
||||
Write-Host "$NumUpdates upgrades available"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
@ -72,4 +75,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-apps.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-apps.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -17,7 +17,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-bios.ps1
|
||||
✅ BIOS model F6 version ALASKA - 1072009 by American Megatrends Inc.
|
||||
✅ BIOS model P62 v02.67 by HP (version HPQOEM - 5, S/N CZC1080B01)
|
||||
|
||||
```
|
||||
|
||||
@ -39,7 +39,7 @@ Script Content
|
||||
This PowerShell script queries the BIOS status and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-bios.ps1
|
||||
✅ BIOS model F6 version ALASKA - 1072009 by American Megatrends Inc.
|
||||
✅ BIOS model P62 v02.67 by HP (version HPQOEM - 5, S/N CZC1080B01)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -49,24 +49,24 @@ Script Content
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
Write-Progress "⏳ Querying BIOS details..."
|
||||
$Model = (sudo dmidecode -s system-product-name)
|
||||
if ("$Model" -ne "") {
|
||||
$Version = (sudo dmidecode -s bios-version)
|
||||
$RelDate = (sudo dmidecode -s bios-release-date)
|
||||
$Manufacturer = (sudo dmidecode -s system-manufacturer)
|
||||
Write-Host "✅ BIOS model $Model version $Version of $RelDate by $Manufacturer"
|
||||
$model = (sudo dmidecode -s system-product-name)
|
||||
if ("$model" -ne "") {
|
||||
$version = (sudo dmidecode -s bios-version)
|
||||
$releaseDate = (sudo dmidecode -s bios-release-date)
|
||||
$manufacturer = (sudo dmidecode -s system-manufacturer)
|
||||
Write-Host "✅ BIOS model $model by $manufacturer (version $version of $releaseDate)"
|
||||
}
|
||||
Write-Progress -completed "."
|
||||
} else {
|
||||
$BIOS = Get-CimInstance -ClassName Win32_BIOS
|
||||
$Model = $BIOS.Name.Trim()
|
||||
$Version = $BIOS.Version.Trim()
|
||||
$Serial = $BIOS.SerialNumber.Trim()
|
||||
$Manufacturer = $BIOS.Manufacturer.Trim()
|
||||
if ($Serial -eq "To be filled by O.E.M.") {
|
||||
Write-Host "✅ BIOS model $Model version $Version by $Manufacturer"
|
||||
$model = $BIOS.Name.Trim()
|
||||
$version = $BIOS.Version.Trim()
|
||||
$serialNumber = $BIOS.SerialNumber.Trim()
|
||||
$manufacturer = $BIOS.Manufacturer.Trim()
|
||||
if ($serialNumber -eq "To be filled by O.E.M.") {
|
||||
Write-Host "✅ BIOS model $model by $manufacturer (version $version)"
|
||||
} else {
|
||||
Write-Host "✅ BIOS model $Model version $Version, S/N $Serial, by $Manufacturer"
|
||||
Write-Host "✅ BIOS model $model by $manufacturer (version $version, S/N $serialNumber)"
|
||||
}
|
||||
}
|
||||
exit 0 # success
|
||||
@ -76,4 +76,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-bios.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-bios.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -103,4 +103,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-cpu.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-cpu.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -57,4 +57,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-day.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-day.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
*check-dns.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script measures and prints the DNS resolution speed by using 200 popular domains.
|
||||
This PowerShell script measures the DNS resolution speed (using 100 popular domains) and prints it.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -17,7 +17,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-dns.ps1
|
||||
✅ DNS resolves 156.5 domains per second
|
||||
✅ DNS resolves 56.5 domains per second
|
||||
|
||||
```
|
||||
|
||||
@ -34,12 +34,12 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Check DNS resolution
|
||||
Check the DNS resolution
|
||||
.DESCRIPTION
|
||||
This PowerShell script measures and prints the DNS resolution speed by using 200 popular domains.
|
||||
This PowerShell script measures the DNS resolution speed (using 100 popular domains) and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-dns.ps1
|
||||
✅ DNS resolves 156.5 domains per second
|
||||
✅ DNS resolves 56.5 domains per second
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -47,15 +47,15 @@ Script Content
|
||||
#>
|
||||
|
||||
try {
|
||||
Write-Progress "⏳ Resolving 200 popular domain names..."
|
||||
$table = Import-CSV "$PSScriptRoot/../Data/popular-domains.csv"
|
||||
$numRows = $table.Length
|
||||
Write-Progress "⏳ Resolving $numRows domain names..."
|
||||
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
if ($IsLinux) {
|
||||
foreach($row in $table){$nop=dig $row.Domain +short}
|
||||
foreach($row in $table){$nop=dig $row.Domain +short}
|
||||
} else {
|
||||
foreach($row in $table){$nop=Resolve-DNSName $row.Domain}
|
||||
foreach($row in $table){$nop=Resolve-DNSName $row.Domain}
|
||||
}
|
||||
Write-Progress -completed "."
|
||||
[float]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
@ -72,4 +72,4 @@ foreach($row in $table){$nop=Resolve-DNSName $row.Domain}
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-dns.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-dns.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -91,4 +91,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-drive-space.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-drive-space.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -1,14 +1,14 @@
|
||||
*check-drives.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script checks all drives for free space left.
|
||||
This PowerShell script queries the free space of all drives and prints it.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./check-drives.ps1 [[-MinLevel] <Int32>] [<CommonParameters>]
|
||||
PS> ./check-drives.ps1 [[-minLevel] <Int64>] [<CommonParameters>]
|
||||
|
||||
-MinLevel <Int32>
|
||||
-minLevel <Int64>
|
||||
Specifies the minimum warning level (10 GB by default)
|
||||
|
||||
Required? false
|
||||
@ -26,7 +26,8 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-drives.ps1
|
||||
✅ Drive C: with 250GB at 10%, 225GB free
|
||||
✅ Drive C: uses 49% of 1TB, 512GB free
|
||||
✅ Drive D: uses 84% of 4TB, 641GB free
|
||||
|
||||
```
|
||||
|
||||
@ -45,60 +46,56 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Checks the drive space
|
||||
.DESCRIPTION
|
||||
This PowerShell script checks all drives for free space left.
|
||||
.PARAMETER MinLevel
|
||||
This PowerShell script queries the free space of all drives and prints it.
|
||||
.PARAMETER minLevel
|
||||
Specifies the minimum warning level (10 GB by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-drives.ps1
|
||||
✅ Drive C: with 250GB at 10%, 225GB free
|
||||
✅ Drive C: uses 49% of 1TB, 512GB free
|
||||
✅ Drive D: uses 84% of 4TB, 641GB free
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([int]$MinLevel = 10) # 10 GB minimum
|
||||
param([int64]$minLevel = 10) # 10 GB minimum
|
||||
|
||||
function Bytes2String { param([int64]$Bytes)
|
||||
if ($Bytes -lt 1000) { return "$Bytes bytes" }
|
||||
$Bytes /= 1000
|
||||
if ($Bytes -lt 1000) { return "$($Bytes)KB" }
|
||||
$Bytes /= 1000
|
||||
if ($Bytes -lt 1000) { return "$($Bytes)MB" }
|
||||
$Bytes /= 1000
|
||||
if ($Bytes -lt 1000) { return "$($Bytes)GB" }
|
||||
$Bytes /= 1000
|
||||
if ($Bytes -lt 1000) { return "$($Bytes)TB" }
|
||||
$Bytes /= 1000
|
||||
if ($Bytes -lt 1000) { return "$($Bytes)PB" }
|
||||
$Bytes /= 1000
|
||||
if ($Bytes -lt 1000) { return "$($Bytes)EB" }
|
||||
function Bytes2String { param([int64]$bytes)
|
||||
if ($bytes -lt 1000) { return "$bytes bytes" }
|
||||
$bytes /= 1000
|
||||
if ($bytes -lt 1000) { return "$($bytes)KB" }
|
||||
$bytes /= 1000
|
||||
if ($bytes -lt 1000) { return "$($bytes)MB" }
|
||||
$bytes /= 1000
|
||||
if ($bytes -lt 1000) { return "$($bytes)GB" }
|
||||
$bytes /= 1000
|
||||
if ($bytes -lt 1000) { return "$($bytes)TB" }
|
||||
$bytes /= 1000
|
||||
return "$($bytes)PB"
|
||||
}
|
||||
|
||||
try {
|
||||
Write-Progress "⏳ Querying drives..."
|
||||
$Drives = Get-PSDrive -PSProvider FileSystem
|
||||
$drives = Get-PSDrive -PSProvider FileSystem
|
||||
$minLevel *= 1000 * 1000 * 1000
|
||||
Write-Progress -completed "."
|
||||
foreach($Drive in $Drives) {
|
||||
$Details = (Get-PSDrive $Drive.Name)
|
||||
if ($IsLinux) { $ID = $Drive.Name } else { $ID = $Drive.Name + ":" }
|
||||
[int64]$Free = $Details.Free
|
||||
[int64]$Used = $Details.Used
|
||||
[int64]$Total = ($Used + $Free)
|
||||
foreach($drive in $drives) {
|
||||
$details = (Get-PSDrive $drive.Name)
|
||||
if ($IsLinux) { $name = $drive.Name } else { $name = $drive.Name + ":" }
|
||||
[int64]$free = $details.Free
|
||||
[int64]$used = $details.Used
|
||||
[int64]$total = ($used + $free)
|
||||
|
||||
if ($Total -eq 0) {
|
||||
Write-Host "✅ Drive $ID is empty"
|
||||
} elseif ($Free -eq 0) {
|
||||
Write-Host "⚠️ Drive $ID with $(Bytes2String $Total) is 100% full"
|
||||
} elseif ($Free -lt $MinLevel) {
|
||||
Write-Host "⚠️ Drive $ID with $(Bytes2String $Total) is nearly full, $(Bytes2String $Free) free"
|
||||
if ($total -eq 0) {
|
||||
Write-Host "✅ Drive $name is empty"
|
||||
} elseif ($free -eq 0) {
|
||||
Write-Host "⚠️ Drive $name with $(Bytes2String $total) is full"
|
||||
} elseif ($free -lt $minLevel) {
|
||||
Write-Host "⚠️ Drive $name with $(Bytes2String $total) is nearly full, $(Bytes2String $free) free"
|
||||
} else {
|
||||
[int]$Percent = ($Used * 100) / $Total
|
||||
if ($Percent -gt 90) {
|
||||
Write-Host "✅ Drive $ID with $(Bytes2String $Total) is $Percent% full, $(Bytes2String $Free) free"
|
||||
} else {
|
||||
Write-Host "✅ Drive $ID with $(Bytes2String $Total) at $Percent%, $(Bytes2String $Free) free"
|
||||
}
|
||||
[int]$percent = ($used * 100) / $total
|
||||
Write-Host "✅ Drive $name uses $percent% of $(Bytes2String $total), $(Bytes2String $free) free"
|
||||
}
|
||||
}
|
||||
exit 0 # success
|
||||
@ -108,4 +105,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-drives.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-drives.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -63,4 +63,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-dusk.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-dusk.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -61,4 +61,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-easter-sunday.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-easter-sunday.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -75,4 +75,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-file-system.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-file-system.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -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 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-file.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-firewall.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-firewall.ps1 as of 09/20/2023 17:04:37)*
|
||||
|
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-gpu.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-gpu.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -59,8 +59,8 @@ Script Content
|
||||
& "$PSScriptRoot/check-gpu.ps1"
|
||||
& "$PSScriptRoot/check-smart-devices.ps1"
|
||||
& "$PSScriptRoot/check-drives.ps1"
|
||||
& "$PSScriptRoot/check-battery.ps1"
|
||||
& "$PSScriptRoot/check-power.ps1"
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-hardware.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-hardware.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -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 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-health.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -61,4 +61,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-independence-day.ps1 as of 08/06/2023 21:36:05)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-independence-day.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -84,4 +84,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ipv4-address.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ipv4-address.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -98,4 +98,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ipv6-address.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ipv6-address.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -55,4 +55,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-iss-position.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-iss-position.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -87,4 +87,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-mac-address.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-mac-address.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-midnight.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-midnight.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -57,4 +57,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-month.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-month.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -76,4 +76,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-moon-phase.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-moon-phase.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -21,7 +21,7 @@ PS> ./check-network.ps1
|
||||
|
||||
|
||||
N E T W O R K
|
||||
✅ Firewall enabled
|
||||
✅ Online with 30ms latency (16ms..56ms, 0/10 loss)
|
||||
...
|
||||
|
||||
```
|
||||
@ -46,7 +46,7 @@ Script Content
|
||||
PS> ./check-network.ps1
|
||||
|
||||
N E T W O R K
|
||||
✅ Firewall enabled
|
||||
✅ Online with 30ms latency (16ms..56ms, 0/10 loss)
|
||||
...
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -56,12 +56,12 @@ Script Content
|
||||
|
||||
" "
|
||||
& "$PSScriptRoot/write-green.ps1" " N E T W O R K"
|
||||
& "$PSScriptRoot/check-firewall"
|
||||
& "$PSScriptRoot/check-ping.ps1"
|
||||
& "$PSScriptRoot/check-firewall"
|
||||
& "$PSScriptRoot/check-dns.ps1"
|
||||
& "$PSScriptRoot/check-vpn.ps1"
|
||||
& "$PSScriptRoot/check-ip.ps1"
|
||||
& "$PSScriptRoot/list-public-ip.ps1"
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-network.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-network.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-new-year.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-new-year.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -59,4 +59,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-noon.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-noon.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -73,4 +73,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-os.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-os.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-outlook.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-outlook.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -94,4 +94,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-password.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-password.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -92,4 +92,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-pending-reboot.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-pending-reboot.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
*check-ping.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script measures the ping roundtrip times from the local computer to 10 Internet servers.
|
||||
This PowerShell script measures the ping roundtrip times from the local computer to other computers (10 Internet servers by default).
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -9,11 +9,11 @@ Parameters
|
||||
PS> ./check-ping.ps1 [[-hosts] <String>] [<CommonParameters>]
|
||||
|
||||
-hosts <String>
|
||||
Specifies the hosts to check, seperated by commata (default is: amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,github.com,google.com,live.com,twitter.com,youtube.com)
|
||||
Specifies the hosts to check, seperated by commata (default is: amazon.com,bing.com,cnn.com,dropbox.com,github.com,google.com,live.com,meta.com,x.com,youtube.com)
|
||||
|
||||
Required? false
|
||||
Position? 1
|
||||
Default value amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,github.com,google.com,live.com,twitter.com,youtube.com
|
||||
Default value bing.com,cnn.com,dropbox.com,github.com,google.com,ibm.com,live.com,meta.com,x.com,youtube.com
|
||||
Accept pipeline input? false
|
||||
Accept wildcard characters? false
|
||||
|
||||
@ -26,7 +26,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-ping.ps1
|
||||
✅ Ping latency is 29ms average (13ms...109ms, 0 loss)
|
||||
✅ Online with 18ms latency average (13ms...109ms, 0/10 ping loss)
|
||||
|
||||
```
|
||||
|
||||
@ -45,42 +45,46 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Checks the ping latency
|
||||
.DESCRIPTION
|
||||
This PowerShell script measures the ping roundtrip times from the local computer to 10 Internet servers.
|
||||
This PowerShell script measures the ping roundtrip times from the local computer to other computers (10 Internet servers by default).
|
||||
.PARAMETER hosts
|
||||
Specifies the hosts to check, seperated by commata (default is: amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,github.com,google.com,live.com,twitter.com,youtube.com)
|
||||
Specifies the hosts to check, seperated by commata (default is: amazon.com,bing.com,cnn.com,dropbox.com,github.com,google.com,live.com,meta.com,x.com,youtube.com)
|
||||
.EXAMPLE
|
||||
PS> ./check-ping.ps1
|
||||
✅ Ping latency is 29ms average (13ms...109ms, 0 loss)
|
||||
✅ Online with 18ms latency average (13ms...109ms, 0/10 ping loss)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$hosts = "amazon.com,bing.com,cnn.com,dropbox.com,facebook.com,github.com,google.com,live.com,twitter.com,youtube.com")
|
||||
param([string]$hosts = "bing.com,cnn.com,dropbox.com,github.com,google.com,ibm.com,live.com,meta.com,x.com,youtube.com")
|
||||
|
||||
try {
|
||||
Write-Host "✅ Ping latency is" -noNewline
|
||||
$hostsArray = $hosts.Split(",")
|
||||
$t = $hostsArray | foreach {
|
||||
(New-Object Net.NetworkInformation.Ping).SendPingAsync($_, 250)
|
||||
$parallelTasks = $hostsArray | foreach {
|
||||
(New-Object Net.NetworkInformation.Ping).SendPingAsync($_, 500)
|
||||
}
|
||||
[Threading.Tasks.Task]::WaitAll($t)
|
||||
[int]$min = 9999999
|
||||
[int]$max = [int]$avg = [int]$successCount = [int]$lossCount = 0
|
||||
foreach($ping in $t.Result) {
|
||||
[int]$totalCount = $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 }
|
||||
if ($latency -lt $min) { $min = $latency }
|
||||
if ($latency -gt $max) { $max = $latency }
|
||||
$avg += $latency
|
||||
$successCount++
|
||||
} else {
|
||||
$lossCount++
|
||||
}
|
||||
}
|
||||
$avg /= $successCount
|
||||
Write-Host " $($avg)ms average ($($min)ms...$($max)ms, $lossCount loss)"
|
||||
if ($successCount -ne 0) {
|
||||
$avg /= $successCount
|
||||
Write-Host "✅ Online with $($avg)ms latency average ($($min)ms...$($max)ms, $lossCount/$totalCount ping loss)"
|
||||
} else {
|
||||
Write-Host "⚠️ Offline ($lossCount/$totalCount ping loss)"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -88,4 +92,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ping.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ping.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
93
Docs/check-power.md
Normal file
93
Docs/check-power.md
Normal file
@ -0,0 +1,93 @@
|
||||
*check-power.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script queries the power status and prints it.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./check-power.ps1 [<CommonParameters>]
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-power.ps1
|
||||
⚠️ Battery at 9% (54 min remaining) with power scheme: HP Optimized
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks the power status
|
||||
.DESCRIPTION
|
||||
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
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$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%)"
|
||||
} else {
|
||||
$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"
|
||||
} else {
|
||||
$Reply = "✅ Battery at $Percent% with $Remaining min remaining"
|
||||
}
|
||||
}
|
||||
$PowerScheme = (powercfg /getactivescheme)
|
||||
$PowerScheme = $PowerScheme -Replace "^(.*) \(",""
|
||||
$PowerScheme = $PowerScheme -Replace "\)$",""
|
||||
$Reply += ", power scheme is '$PowerScheme'"
|
||||
}
|
||||
Write-Output $Reply
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-power.ps1 as of 09/20/2023 17:04:38)*
|
@ -17,7 +17,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-powershell.ps1
|
||||
✅ PowerShell Desktop edition 5.1.19041.2673 (10 modules, 1458 cmdlets, 172 aliases)
|
||||
✅ PowerShell 5.1.19041.2673 Desktop edition (10 modules, 1458 cmdlets, 172 aliases)
|
||||
|
||||
```
|
||||
|
||||
@ -39,7 +39,7 @@ Script Content
|
||||
This PowerShell script queries the PowerShell status and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-powershell.ps1
|
||||
✅ PowerShell Desktop edition 5.1.19041.2673 (10 modules, 1458 cmdlets, 172 aliases)
|
||||
✅ PowerShell 5.1.19041.2673 Desktop edition (10 modules, 1458 cmdlets, 172 aliases)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -47,15 +47,15 @@ Script Content
|
||||
#>
|
||||
|
||||
try {
|
||||
$Version = $PSVersionTable.PSVersion
|
||||
$Edition = $PSVersionTable.PSEdition
|
||||
$NumModules = (Get-Module).Count
|
||||
$NumAliases = (Get-Alias).Count
|
||||
$version = $PSVersionTable.PSVersion
|
||||
$edition = $PSVersionTable.PSEdition
|
||||
$numModules = (Get-Module).Count
|
||||
$numAliases = (Get-Alias).Count
|
||||
if ($IsLinux) {
|
||||
"✅ PowerShell $Edition edition $Version ($NumModules modules, $NumAliases aliases)"
|
||||
"✅ PowerShell $version $edition edition ($numModules modules, $numAliases aliases)"
|
||||
} else {
|
||||
$NumCmdlets = (Get-Command -Command-Type cmdlet).Count
|
||||
"✅ PowerShell $Edition edition $Version ($NumModules modules, $NumCmdlets cmdlets, $NumAliases aliases)"
|
||||
$numCmdlets = (Get-Command -Command-Type cmdlet).Count
|
||||
"✅ PowerShell $version $edition edition ($numModules modules, $numCmdlets cmdlets, $numAliases aliases)"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
@ -64,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-powershell.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-powershell.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -76,4 +76,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ps1-file.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ps1-file.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -19,12 +19,12 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Check the RAM status
|
||||
Checks the RAM
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries the status of the installed RAM and prints it.
|
||||
This PowerShell script queries the status of the installed RAM memory modules and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-ram.ps1
|
||||
✅ 16GB DDR4 RAM @ 3200MHz (1.2V) in P0 CHANNEL A/DIMM 0 by Samsung
|
||||
✅ 16GB DDR4 RAM @ 3200MHz by Micron (in CPU0/CPU0-DIMM3 @ 1.2V)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -88,7 +88,7 @@ try {
|
||||
[float]$Voltage = $Bank.ConfiguredVoltage / 1000.0
|
||||
$Manufacturer = $Bank.Manufacturer
|
||||
$Location = "$($Bank.BankLabel)/$($Bank.DeviceLocator)"
|
||||
Write-Host "✅ $Capacity $Type @ $($Speed)MHz ($($Voltage)V) in $Location by $Manufacturer"
|
||||
Write-Host "✅ $Capacity $Type @ $($Speed)MHz by $Manufacturer (in $Location @ $($Voltage)V)"
|
||||
}
|
||||
}
|
||||
exit 0 # success
|
||||
@ -98,4 +98,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ram.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-ram.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -120,7 +120,7 @@ try {
|
||||
|
||||
$RepoDirName = (Get-Item "$FullPath").Name
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ checked Git repository 📂$RepoDirName in $Elapsed sec"
|
||||
"✔️ Checked repo 📂$RepoDirName in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -128,4 +128,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-repo.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-repo.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -56,4 +56,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-santa.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-santa.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -95,4 +95,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-smart-devices.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-smart-devices.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -21,7 +21,8 @@ PS> ./check-software.ps1
|
||||
|
||||
|
||||
S O F T W A R E
|
||||
✅ BIOS 'P62 v02.67', release HPQOEM - 0, S/N CZC448B9C1 by HP
|
||||
✅ BIOS model 'P62 v02.67' version HPQOEM - 0 by HP
|
||||
✅ Windows 10 Pro 64-Bit (v10.0.19045, since 5/2/2021)
|
||||
...
|
||||
|
||||
```
|
||||
@ -46,7 +47,8 @@ Script Content
|
||||
PS> ./check-software.ps1
|
||||
|
||||
S O F T W A R E
|
||||
✅ BIOS 'P62 v02.67', release HPQOEM - 0, S/N CZC448B9C1 by HP
|
||||
✅ BIOS model 'P62 v02.67' version HPQOEM - 0 by HP
|
||||
✅ Windows 10 Pro 64-Bit (v10.0.19045, since 5/2/2021)
|
||||
...
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -58,8 +60,8 @@ Script Content
|
||||
& "$PSScriptRoot/write-green.ps1" " S O F T W A R E"
|
||||
& "$PSScriptRoot/check-bios.ps1"
|
||||
& "$PSScriptRoot/check-os.ps1"
|
||||
& "$PSScriptRoot/check-powershell.ps1"
|
||||
& "$PSScriptRoot/check-apps.ps1"
|
||||
& "$PSScriptRoot/check-powershell.ps1"
|
||||
& "$PSScriptRoot/check-uptime.ps1"
|
||||
& "$PSScriptRoot/check-time-zone.ps1"
|
||||
& "$PSScriptRoot/check-swap-space.ps1"
|
||||
@ -67,4 +69,4 @@ Script Content
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-software.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-software.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -84,4 +84,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-subnet-mask.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-subnet-mask.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -6,10 +6,10 @@ This PowerShell script queries the status of the swap space and prints it.
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./check-swap-space.ps1 [[-MinLevel] <Int32>] [<CommonParameters>]
|
||||
PS> ./check-swap-space.ps1 [[-minLevel] <Int32>] [<CommonParameters>]
|
||||
|
||||
-MinLevel <Int32>
|
||||
Specifies the minimum level (10 GB by default)
|
||||
-minLevel <Int32>
|
||||
Specifies the minimum level in GB (10 GB by default)
|
||||
|
||||
Required? false
|
||||
Position? 1
|
||||
@ -26,7 +26,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-swap-space.ps1
|
||||
✅ Swap space with 1GB at 42%, 748MB free
|
||||
✅ Swap space uses 42% of 1GB, 748MB free
|
||||
|
||||
```
|
||||
|
||||
@ -46,18 +46,18 @@ Script Content
|
||||
Checks the swap space status
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries the status of the swap space and prints it.
|
||||
.PARAMETER MinLevel
|
||||
Specifies the minimum level (10 GB by default)
|
||||
.PARAMETER minLevel
|
||||
Specifies the minimum level in GB (10 GB by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-swap-space.ps1
|
||||
✅ Swap space with 1GB at 42%, 748MB free
|
||||
✅ Swap space uses 42% of 1GB, 748MB free
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([int]$MinLevel = 10) # minimum level in GB
|
||||
param([int]$minLevel = 10)
|
||||
|
||||
function MB2String { param([int64]$Bytes)
|
||||
if ($Bytes -lt 1000) { return "$($Bytes)MB" }
|
||||
@ -72,35 +72,31 @@ function MB2String { param([int64]$Bytes)
|
||||
}
|
||||
|
||||
try {
|
||||
[int]$Total = [int]$Used = [int]$Free = 0
|
||||
[int64]$Total = [int64]$Used = [int64]$Free = 0
|
||||
if ($IsLinux) {
|
||||
$Result = $(free --mega | grep Swap:)
|
||||
[int]$Total = $Result.subString(5,14)
|
||||
[int]$Used = $Result.substring(20,13)
|
||||
[int]$Free = $Result.substring(32,11)
|
||||
[int64]$Total = $Result.subString(5,14)
|
||||
[int64]$Used = $Result.substring(20,13)
|
||||
[int64]$Free = $Result.substring(32,11)
|
||||
} else {
|
||||
$Items = Get-WmiObject -class "Win32_PageFileUsage" -namespace "root\CIMV2" -computername localhost
|
||||
foreach ($Item in $Items) {
|
||||
$Total = $Item.AllocatedBaseSize
|
||||
$Used = $Item.CurrentUsage
|
||||
$Free = ($Total - $Used)
|
||||
$Total += $Item.AllocatedBaseSize
|
||||
$Used += $Item.CurrentUsage
|
||||
$Free += ($Total - $Used)
|
||||
}
|
||||
}
|
||||
if ($Total -eq 0) {
|
||||
Write-Output "⚠️ No swap space configured"
|
||||
} elseif ($Free -eq 0) {
|
||||
Write-Output "⚠️ Swap space with $(MB2String $Total) is full"
|
||||
} elseif ($Free -lt $MinLevel) {
|
||||
Write-Output "⚠️ Swap space with $(MB2String $Total) is nearly full, only $(MB2String $Free) free"
|
||||
Write-Output "⚠️ Swap space of $(MB2String $Total) is full"
|
||||
} elseif ($Free -lt $minLevel) {
|
||||
Write-Output "⚠️ Swap space of $(MB2String $Total) is nearly full, only $(MB2String $Free) free"
|
||||
} elseif ($Used -eq 0) {
|
||||
Write-Output "✅ Swap space with $(MB2String $Total) reserved"
|
||||
Write-Output "✅ Swap space of $(MB2String $Total) reserved"
|
||||
} else {
|
||||
[int]$Percent = ($Used * 100) / $Total
|
||||
if ($Percent -ge 90) {
|
||||
Write-Output "✅ Swap space with $(MB2String $Total) is $Percent% full, $(MB2String $Free) free"
|
||||
} else {
|
||||
Write-Output "✅ Swap space with $(MB2String $Total) at $Percent%, $(MB2String $Free) free"
|
||||
}
|
||||
Write-Output "✅ Swap space uses $Percent% of $(MB2String $Total), $(MB2String $Free) free"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
@ -109,4 +105,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-swap-space.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-swap-space.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -100,4 +100,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-symlinks.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-symlinks.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-time-zone.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-time-zone.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -82,4 +82,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-uptime.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-uptime.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
*check-vpn.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script queries and prints the status of the VPN connection(s).
|
||||
This PowerShell script queries the status of the VPN connection(s) and prints it.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -17,7 +17,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-vpn.ps1
|
||||
✅ VPN to NASA L2TP is disconnected
|
||||
✅ VPN to NASA L2TP is connected
|
||||
|
||||
```
|
||||
|
||||
@ -36,10 +36,10 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Checks the VPN status
|
||||
.DESCRIPTION
|
||||
This PowerShell script queries and prints the status of the VPN connection(s).
|
||||
This PowerShell script queries the status of the VPN connection(s) and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-vpn.ps1
|
||||
✅ VPN to NASA L2TP is disconnected
|
||||
✅ VPN to NASA L2TP is connected
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -47,17 +47,17 @@ Script Content
|
||||
#>
|
||||
|
||||
try {
|
||||
$NoVPN = $true
|
||||
$noVPN = $true
|
||||
if ($IsLinux) {
|
||||
# TODO
|
||||
} else {
|
||||
$Connections = Get-VPNConnection
|
||||
foreach($Connection in $Connections) {
|
||||
Write-Host "✅ VPN to $($Connection.Name) is $($Connection.ConnectionStatus.ToLower())"
|
||||
$NoVPN = $false
|
||||
$noVPN = $false
|
||||
}
|
||||
}
|
||||
if ($NoVPN) { Write-Host "⚠️ No VPN configured" }
|
||||
if ($noVPN) { Write-Host "⚠️ No VPN configured" }
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-vpn.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-vpn.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -81,4 +81,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-weather.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-weather.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -54,4 +54,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-week.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-week.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -72,4 +72,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-wind.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-wind.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-windows-system-files.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-windows-system-files.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -88,4 +88,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-xml-file.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of check-xml-file.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -26,12 +26,12 @@ PS> ./clean-repo.ps1 [[-RepoDir] <String>] [<CommonParameters>]
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./clean-repo C:\base256unicode
|
||||
PS> ./clean-repo.ps1 C:\rust
|
||||
⏳ (1/4) Searching for Git executable... git version 2.41.0.windows.3
|
||||
⏳ (2/4) Checking local repository... 📂C:\base256unicode
|
||||
⏳ (2/4) Checking local repository... 📂C:\rust
|
||||
⏳ (3/4) Removing untracked files in repository...
|
||||
⏳ (4/4) Removing untracked files in submodules...
|
||||
✔️ Cleaning the 📂base256unicode repo took 1 sec
|
||||
✔️ Cleaned repo 📂rust in 1 sec
|
||||
|
||||
```
|
||||
|
||||
@ -55,12 +55,12 @@ Script Content
|
||||
.PARAMETER RepoDir
|
||||
Specifies the file path to the local Git repository
|
||||
.EXAMPLE
|
||||
PS> ./clean-repo C:\base256unicode
|
||||
PS> ./clean-repo.ps1 C:\rust
|
||||
⏳ (1/4) Searching for Git executable... git version 2.41.0.windows.3
|
||||
⏳ (2/4) Checking local repository... 📂C:\base256unicode
|
||||
⏳ (2/4) Checking local repository... 📂C:\rust
|
||||
⏳ (3/4) Removing untracked files in repository...
|
||||
⏳ (4/4) Removing untracked files in submodules...
|
||||
✔️ Cleaning the 📂base256unicode repo took 1 sec
|
||||
✔️ Cleaned repo 📂rust in 1 sec
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -93,7 +93,7 @@ try {
|
||||
if ($lastExitCode -ne "0") { throw "'git clean' in the submodules failed with exit code $lastExitCode" }
|
||||
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ Cleaning the 📂$RepoDirName repo took $Elapsed sec"
|
||||
"✔️ Cleaned repo 📂$RepoDirName in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -101,4 +101,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clean-repo.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clean-repo.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -92,4 +92,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clean-repos.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clean-repos.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -17,7 +17,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./clear-dns-cache.ps1
|
||||
✔️ cleared DNS cache in 0 ms
|
||||
✔️ Cleared DNS cache in 1 sec
|
||||
|
||||
```
|
||||
|
||||
@ -39,7 +39,7 @@ Script Content
|
||||
This PowerShell script clears the DNS client cache of the local computer.
|
||||
.EXAMPLE
|
||||
PS> ./clear-dns-cache.ps1
|
||||
✔️ cleared DNS cache in 0 ms
|
||||
✔️ Cleared DNS cache in 1 sec
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -52,7 +52,7 @@ try {
|
||||
Clear-DnsClientCache
|
||||
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ cleared DNS cache in $Elapsed sec"
|
||||
"✔️ Cleared DNS cache in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clear-dns-cache.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clear-dns-cache.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clear-recycle-bin.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clear-recycle-bin.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -27,7 +27,7 @@ Example
|
||||
```powershell
|
||||
PS> ./clone-repos C:\Repos
|
||||
⏳ (1) Searching for Git executable... git version 2.41.0.windows.3
|
||||
⏳ (2) Loading Data/popular-git-repos.csv... 28 repos
|
||||
⏳ (2) Reading Data/popular-repositories.csv... 28 repos
|
||||
⏳ (3) Checking target folder... 📂repos
|
||||
⏳ (4/32) Cloning into 📂base256unicode (dev tool)...
|
||||
...
|
||||
@ -55,7 +55,7 @@ Script Content
|
||||
.EXAMPLE
|
||||
PS> ./clone-repos C:\Repos
|
||||
⏳ (1) Searching for Git executable... git version 2.41.0.windows.3
|
||||
⏳ (2) Loading Data/popular-git-repos.csv... 28 repos
|
||||
⏳ (2) Reading Data/popular-repositories.csv... 28 repos
|
||||
⏳ (3) Checking target folder... 📂repos
|
||||
⏳ (4/32) Cloning into 📂base256unicode (dev tool)...
|
||||
...
|
||||
@ -74,8 +74,8 @@ try {
|
||||
& git --version
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
|
||||
Write-Host "⏳ (2) Loading Data/popular-git-repos.csv... " -noNewline
|
||||
$Table = Import-CSV "$PSScriptRoot/../Data/popular-git-repos.csv"
|
||||
Write-Host "⏳ (2) Reading Data/popular-repositories.csv... " -noNewline
|
||||
$Table = Import-CSV "$PSScriptRoot/../Data/popular-repositories.csv"
|
||||
$NumEntries = $Table.count
|
||||
Write-Host "$NumEntries repos"
|
||||
|
||||
@ -90,7 +90,7 @@ try {
|
||||
[string]$FolderName = $Row.FOLDERNAME
|
||||
[string]$Category = $Row.CATEGORY
|
||||
[string]$Branch = $Row.BRANCH
|
||||
[string]$Full = $Row.FULL
|
||||
[string]$Shallow = $Row.SHALLOW
|
||||
[string]$URL = $Row.URL
|
||||
$Step++
|
||||
|
||||
@ -99,14 +99,14 @@ try {
|
||||
$Skipped++
|
||||
continue
|
||||
}
|
||||
if ($Full -eq "yes") {
|
||||
"⏳ ($Step/$($NumEntries + 4)) Cloning into 📂$FolderName ($Category) - $Branch branch with full history..."
|
||||
& git clone --branch "$Branch" --recurse-submodules "$URL" "$TargetDir/$FolderName"
|
||||
if ($lastExitCode -ne "0") { throw "'git clone --branch $Branch $URL' failed with exit code $lastExitCode" }
|
||||
} else {
|
||||
if ($Shallow -eq "yes") {
|
||||
"⏳ ($Step/$($NumEntries + 4)) Cloning into 📂$FolderName ($Category) - $Branch branch only..."
|
||||
& git clone --branch "$Branch" --single-branch --recurse-submodules "$URL" "$TargetDir/$FolderName"
|
||||
if ($lastExitCode -ne "0") { throw "'git clone --branch $Branch $URL' failed with exit code $lastExitCode" }
|
||||
} else {
|
||||
"⏳ ($Step/$($NumEntries + 4)) Cloning into 📂$FolderName ($Category) - $Branch branch with full history..."
|
||||
& git clone --branch "$Branch" --recurse-submodules "$URL" "$TargetDir/$FolderName"
|
||||
if ($lastExitCode -ne "0") { throw "'git clone --branch $Branch $URL' failed with exit code $lastExitCode" }
|
||||
}
|
||||
$Cloned++
|
||||
}
|
||||
@ -119,4 +119,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clone-repos.ps1 as of 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of clone-repos.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -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 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-calculator.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -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 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-chrome.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -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 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-cortana.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -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 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-edge.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -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 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-file-explorer.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -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 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-firefox.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
@ -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 08/06/2023 21:36:06)*
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of close-git-extensions.ps1 as of 09/20/2023 17:04:38)*
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user