mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 05:04:39 +02:00
Updated the manuals
This commit is contained in:
@ -116,4 +116,4 @@ try {
|
||||
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:33)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -72,4 +72,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:33)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -28,9 +28,9 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./build-repo.ps1 C:\Repos\ninja
|
||||
⏳ Building 📂ninja by using CMake...
|
||||
⏳ Building 'ninja' by executing cmake...
|
||||
...
|
||||
✅ Build of 📂ninja succeeded in 47s, results at: 📂C:\Repos\ninja\_results
|
||||
✅ Build of 'ninja' succeeded in 47s, results at: 📂C:\Repos\ninja\_results
|
||||
|
||||
```
|
||||
|
||||
@ -55,9 +55,9 @@ Script Content
|
||||
Specifies the file path to the Git repository (default: current working directory)
|
||||
.EXAMPLE
|
||||
PS> ./build-repo.ps1 C:\Repos\ninja
|
||||
⏳ Building 📂ninja by using CMake...
|
||||
⏳ Building 'ninja' by executing cmake...
|
||||
...
|
||||
✅ Build of 📂ninja succeeded in 47s, results at: 📂C:\Repos\ninja\_results
|
||||
✅ Build of 'ninja' succeeded in 47s, results at: 📂C:\Repos\ninja\_results
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -69,117 +69,120 @@ param([string]$path = "$PWD")
|
||||
function BuildFolder([string]$path) {
|
||||
$dirName = (Get-Item "$path").Name
|
||||
if (Test-Path "$path/CMakeLists.txt" -pathType leaf) {
|
||||
"⏳ (1/4) Building 📂$dirName by using CMake..."
|
||||
"⏳ (1/3) Building '$dirName' by executing cmake..."
|
||||
$global:results = "$path/_results/"
|
||||
if (-not(Test-Path $global:results -pathType container)) {
|
||||
& mkdir $global:results
|
||||
}
|
||||
Set-Location $global:results
|
||||
|
||||
"⏳ (2/4) Executing 'cmake' to generate the Makefile..."
|
||||
& cmake ..
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'cmake ..' failed with exit code $lastExitCode" }
|
||||
|
||||
"⏳ (3/4) Executing 'make -j4' to compile and link..."
|
||||
"⏳ (2/3) Executing 'make -j4' to compile and link..."
|
||||
& make -j4
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' failed with exit code $lastExitCode" }
|
||||
|
||||
"⏳ (4/4) Executing 'ctest -V'... (if tests are provided)"
|
||||
"⏳ (3/3) Checking '$dirName' by executing 'ctest -V'... (if tests are provided)"
|
||||
& ctest -V
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'ctest -V' failed with exit code $lastExitCode" }
|
||||
} elseif (Test-Path "$path/.cargo/release.toml" -pathType leaf) {
|
||||
"⏳ (1/4) Building 📂$dirName by using Cargo..."
|
||||
Set-Location "$path/"
|
||||
|
||||
"⏳ Building '$dirName' by executing 'cargo build'..."
|
||||
Set-Location "$path/"
|
||||
& cargo build --config .cargo/release.toml --release
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'cargo build' failed with exit code $lastExitCode" }
|
||||
|
||||
} elseif (Test-Path "$path/autogen.sh" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by executing 'autogen.sh'..."
|
||||
|
||||
"⏳ (1/3) Building '$dirName' by executing 'autogen.sh'..."
|
||||
Set-Location "$path/"
|
||||
& ./autogen.sh --force
|
||||
if ($lastExitCode -ne 0) { throw "Executing './autogen.sh --force' failed with exit code $lastExitCode" }
|
||||
"⏳ Executing './configure'..."
|
||||
|
||||
"⏳ (2/3) Executing './configure'..."
|
||||
& ./configure
|
||||
if ($lastExitCode -ne 0) { throw "Executing './configure' failed with exit code $lastExitCode" }
|
||||
|
||||
"⏳ (3/3) Executing 'make -j4' to compile and link..."
|
||||
& make -j4
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' failed with exit code $lastExitCode" }
|
||||
|
||||
} elseif (Test-Path "$path/configure" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by executing './configure' and 'make'..."
|
||||
Set-Location "$path/"
|
||||
|
||||
"⏳ (1/3) Building '$dirName' by executing './configure'..."
|
||||
Set-Location "$path/"
|
||||
& ./configure
|
||||
#if ($lastExitCode -ne 0) { throw "Executing './configure' exited with error code $lastExitCode" }
|
||||
|
||||
"⏳ (2/3) Compiling and linking '$dirName' by executing 'make -j4'..."
|
||||
& make -j4
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' failed with exit code $lastExitCode" }
|
||||
|
||||
"⏳ (3/3) Checking '$dirName' by executing 'make test'..."
|
||||
& make test
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'make test' failed with exit code $lastExitCode" }
|
||||
|
||||
} elseif (Test-Path "$path/build.gradle" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using Gradle..."
|
||||
Set-Location "$path"
|
||||
|
||||
"⏳ (1/2) Building '$dirName' by executing 'gradle build'..."
|
||||
Set-Location "$path"
|
||||
& gradle build
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'gradle build' failed with exit code $lastExitCode" }
|
||||
|
||||
"⏳ (2/2) Checking '$dirName' by executing 'gradle test'..."
|
||||
& gradle test
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'gradle test' failed with exit code $lastExitCode" }
|
||||
|
||||
} elseif (Test-Path "$path/meson.build" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using Meson..."
|
||||
"⏳ Building '$dirName' by using Meson..."
|
||||
Set-Location "$path"
|
||||
& meson . build --prefix=/usr/local
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'meson . build' failed with exit code $lastExitCode" }
|
||||
|
||||
} elseif (Test-Path "$path/Imakefile" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using Imakefile..."
|
||||
"⏳ Building '$dirName' by using Imakefile..."
|
||||
Set-Location "$path/"
|
||||
|
||||
& xmkmf
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'xmkmf' failed with exit code $lastExitCode" }
|
||||
|
||||
"⏳ Executing 'make -j4' to compile and link..."
|
||||
& make -j4
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' failed with exit code $lastExitCode" }
|
||||
|
||||
} elseif (Test-Path "$path/Makefile" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using Makefile..."
|
||||
Set-Location "$path"
|
||||
|
||||
"⏳ Building '$dirName' by using Makefile..."
|
||||
Set-Location "$path"
|
||||
& make -j4
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' failed with exit code $lastExitCode" }
|
||||
|
||||
} elseif (Test-Path "$path/makefile" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by using makefile..."
|
||||
"⏳ Building '$dirName' by using makefile..."
|
||||
Set-Location "$path"
|
||||
|
||||
& make -j4
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' failed with exit code $lastExitCode" }
|
||||
|
||||
} elseif (Test-Path "$path/compile.sh" -pathType leaf) {
|
||||
"⏳ Building 📂$dirName by executing 'compile.sh'..."
|
||||
Set-Location "$path/"
|
||||
|
||||
"⏳ Building '$dirName' by executing 'compile.sh'..."
|
||||
Set-Location "$path/"
|
||||
& ./compile.sh
|
||||
if ($lastExitCode -ne 0) { throw "Executing './compile.sh' failed with exit code $lastExitCode" }
|
||||
|
||||
"⏳ Executing 'make -j4' to compile and link..."
|
||||
& make -j4
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'make -j4' failed with exit code $lastExitCode" }
|
||||
|
||||
} elseif (Test-Path "$path/attower/src/build/DevBuild/build.bat" -pathType leaf) {
|
||||
|
||||
Write-Host "⏳ Building 📂$dirName by executing 'build.bat'..."
|
||||
Write-Host "⏳ Building '$dirName' by executing 'build.bat'..."
|
||||
Set-Location "$path/attower/src/build/DevBuild/"
|
||||
& ./build.bat build-core-release
|
||||
if ($lastExitCode -ne 0) { throw "Executing 'build.bat' failed with exit code $lastExitCode" }
|
||||
$global:results = "$path\attower\Executables"
|
||||
|
||||
} elseif (Test-Path "$path/$dirName" -pathType container) {
|
||||
"⏳ No make rule found, trying subfolder 📂$($dirName)..."
|
||||
"⏳ No make rule found, trying subfolder '$($dirName)'..."
|
||||
BuildFolder "$path/$dirName"
|
||||
} else {
|
||||
Write-Warning "Sorry, no make rule applies to: 📂$dirName"
|
||||
@ -197,19 +200,19 @@ try {
|
||||
BuildFolder "$path"
|
||||
Set-Location "$previousPath"
|
||||
|
||||
$repoDirName = (Get-Item "$path").Name
|
||||
$dirName = (Get-Item "$path").Name
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
if ($global:results -eq "") {
|
||||
"✅ Build of 📂$repoDirName succeeded in $($elapsed)s."
|
||||
"✅ Build of '$dirName' succeeded in $($elapsed)s."
|
||||
} else {
|
||||
"✅ Build of 📂$repoDirName succeeded in $($elapsed)s, results at: 📂$($global:results)"
|
||||
"✅ Build of '$dirName' succeeded in $($elapsed)s, results at: 📂$($global:results)"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
Set-Location "$previousPath"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -78,9 +78,9 @@ try {
|
||||
"✅ Built $FolderCount Git repositories at 📂$ParentDirName in $Elapsed sec"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
61
docs/calculate-BMI.md
Normal file
61
docs/calculate-BMI.md
Normal file
@ -0,0 +1,61 @@
|
||||
The *calculate-BMI.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script calculates the BMI.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
/Repos/PowerShell/scripts/calculate-BMI.ps1 [<CommonParameters>]
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./calculate-BMI.ps1
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Calculate the BMI
|
||||
.DESCRIPTION
|
||||
This PowerShell script calculates the BMI.
|
||||
.EXAMPLE
|
||||
PS> ./calculate-BMI.ps1
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
[float]$height = Read-Host("Enter your height in m ")
|
||||
[float]$weight = Read-Host("Enter your weight in kg")
|
||||
$BMI = $weight / ($height * $height)
|
||||
"Your BMI is $BMI, for adults the WHO regards <16 as Underweight (severe thinness), 16-17 as Underweight (moderate thinness), 17-18.5 as Underweight (mild thinness), 18.5-25 as Normal range, 25-30 as Overweight (pre-obese), 30-35 as Obese (class I), 35-40 as Obese (class II), and >=40 as Obese (class III)."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
$path = Resolve-Path "~/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup"
|
||||
if (-not(Test-Path "$path" -pathType container)) {
|
||||
@ -60,4 +62,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if ($IsLinux) { throw "Sorry, Windows only" }
|
||||
|
||||
@ -65,4 +67,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if ($IsLinux -or $IsMacOS) {
|
||||
if (-not(Test-Path "~/Desktop" -pathType container)) {
|
||||
@ -69,4 +71,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-docs.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script sets the current working directory to the documents folder.
|
||||
This PowerShell script changes the current working directory to the documents folder.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -36,7 +36,7 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Sets the working dir to the documents folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script sets the current working directory to the documents folder.
|
||||
This PowerShell script changes the current working directory to the documents folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-docs.ps1
|
||||
📂C:\Users\Markus\Documents with 3 files and 0 folders entered.
|
||||
@ -46,10 +46,12 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if ($IsLinux -or $IsMacOS) {
|
||||
if (-not(Test-Path "~/Documents" -pathType container)) {
|
||||
throw "No 'Documents' folder in your home directory yet"
|
||||
throw "Your home directory has no 'Documents' folder yet"
|
||||
}
|
||||
$path = Resolve-Path "~/Documents"
|
||||
} else {
|
||||
@ -64,9 +66,9 @@ try {
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if ($IsLinux -or $IsMacOS) {
|
||||
if (-not(Test-Path "~/Downloads" -pathType container)) {
|
||||
@ -69,4 +71,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if (-not(Test-Path "~/Dropbox" -pathType container)) {
|
||||
throw "No 'Dropbox' folder in your home directory - is Dropbox installed?"
|
||||
@ -62,4 +64,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-etc.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script changes the working directory to the /etc directory.
|
||||
This PowerShell script changes the current working directory to the /etc directory.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -16,8 +16,8 @@ Parameters
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-etc
|
||||
📂C:\Windows\System32\drivers\etc (has 5 files and 0 folders)
|
||||
PS> ./cd-etc.ps1
|
||||
📂C:\Windows\System32\drivers\etc with 5 files and 0 folders entered.
|
||||
|
||||
```
|
||||
|
||||
@ -36,16 +36,18 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Changes to the /etc directory
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the /etc directory.
|
||||
This PowerShell script changes the current working directory to the /etc directory.
|
||||
.EXAMPLE
|
||||
PS> ./cd-etc
|
||||
📂C:\Windows\System32\drivers\etc (has 5 files and 0 folders)
|
||||
PS> ./cd-etc.ps1
|
||||
📂C:\Windows\System32\drivers\etc with 5 files and 0 folders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if ($IsLinux -or $IsMacOS) {
|
||||
$path = "/etc"
|
||||
@ -58,12 +60,12 @@ try {
|
||||
Set-Location "$path"
|
||||
$files = Get-ChildItem $path -attributes !Directory
|
||||
$folders = Get-ChildItem $path -attributes Directory
|
||||
"📂$path entered (has $($files.Count) files and $($folders.Count) folders)"
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
$path = [Environment]::GetFolderPath('Fonts')
|
||||
if (-not(Test-Path "$path" -pathType container)) {
|
||||
@ -61,4 +63,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if (-not(Test-Path "~" -pathType container)) { throw "No home directory at: $path" }
|
||||
$path = Resolve-Path "~"
|
||||
@ -60,4 +62,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -16,7 +16,7 @@ Parameters
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-jenkins
|
||||
PS> ./cd-jenkins.ps1
|
||||
📂C:\Users\Markus\.jenkins entered (has 2 files and 21 folders)
|
||||
|
||||
```
|
||||
@ -38,7 +38,7 @@ Script Content
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the Jenkins home directory.
|
||||
.EXAMPLE
|
||||
PS> ./cd-jenkins
|
||||
PS> ./cd-jenkins.ps1
|
||||
📂C:\Users\Markus\.jenkins entered (has 2 files and 21 folders)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if (Test-Path "~/.jenkins" -pathType container) {
|
||||
$path = "~/.jenkins"
|
||||
@ -65,4 +67,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,19 +1,34 @@
|
||||
The *cd-logs.ps1* Script
|
||||
===========================
|
||||
|
||||
cd-logs.ps1
|
||||
|
||||
This PowerShell script changes the current working directory to the logs directory.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
|
||||
/Repos/PowerShell/scripts/cd-logs.ps1 [<CommonParameters>]
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-logs.ps1
|
||||
📂/var/logs with 3 files and 2 folders entered.
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
@ -23,14 +38,16 @@ Script Content
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the current working directory to the logs directory.
|
||||
.EXAMPLE
|
||||
PS> ./cd-logs
|
||||
📂/var/logs entered (has 3 files and 2 subfolders)
|
||||
PS> ./cd-logs.ps1
|
||||
📂/var/logs with 3 files and 2 folders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
function GetLogsDir {
|
||||
if ($IsLinux -or $IsMacOS) { return "/var/logs" }
|
||||
$WinDir = [System.Environment]::GetFolderPath('Windows')
|
||||
@ -42,12 +59,12 @@ try {
|
||||
Set-Location "$path"
|
||||
$files = Get-ChildItem $path -attributes !Directory
|
||||
$folders = Get-ChildItem $path -attributes Directory
|
||||
"📂$path entered (has $($files.Count) files and $($folders.Count) subfolders)"
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
if (-not(Test-Path "~/Music/" -pathType container)) {
|
||||
@ -64,9 +66,9 @@ try {
|
||||
"📂$path with $($folders.Count) folders and $($files.Count) files entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -16,8 +16,8 @@ Parameters
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-nextcloud
|
||||
📂C:\Users\Markus\NextCloud entered (has 2 files and 0 folders)
|
||||
PS> ./cd-nextcloud.ps1
|
||||
📂C:\Users\Markus\NextCloud with 2 files and 0 folders entered.
|
||||
|
||||
```
|
||||
|
||||
@ -38,14 +38,16 @@ Script Content
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the user's NextCloud folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-nextcloud
|
||||
📂C:\Users\Markus\NextCloud entered (has 2 files and 0 folders)
|
||||
PS> ./cd-nextcloud.ps1
|
||||
📂C:\Users\Markus\NextCloud with 2 files and 0 folders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if (-not(Test-Path "~/NextCloud" -pathType container)) {
|
||||
throw "No 'NextCloud' folder in your home directory - is NextCloud installed?"
|
||||
@ -54,12 +56,12 @@ try {
|
||||
Set-Location "$path"
|
||||
$files = Get-ChildItem $path -attributes !Directory
|
||||
$folders = Get-ChildItem $path -attributes Directory
|
||||
"📂$path entered (has $($files.Count) files and $($folders.Count) folders)"
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if (-not(Test-Path "~/OneDrive" -pathType container)) {
|
||||
throw "No 'OneDrive' folder in your home directory - is OneDrive installed?"
|
||||
@ -57,9 +59,9 @@ try {
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-pics.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script sets the current working directory to the user's pictures folder.
|
||||
This PowerShell script changes the current working directory to the user's pictures folder.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -36,7 +36,7 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Sets the working dir to the user's pictures folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script sets the current working directory to the user's pictures folder.
|
||||
This PowerShell script changes the current working directory to the user's pictures folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-pics.ps1
|
||||
📂C:\Users\Markus\Pictures with 7 files and 0 folders entered.
|
||||
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
if (-not(Test-Path "~/Pictures" -pathType container)) {
|
||||
@ -64,9 +66,9 @@ try {
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-public.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script sets the current working directory to the Public folder.
|
||||
This PowerShell script changes the current working directory to the Public folder.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -36,7 +36,7 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Sets the working dir to the Public folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script sets the current working directory to the Public folder.
|
||||
This PowerShell script changes the current working directory to the Public folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-public.ps1
|
||||
📂C:\Users\Public with 2 files and 3 folders entered.
|
||||
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
if (-not(Test-Path "~/Public" -pathType container)) {
|
||||
@ -64,9 +66,9 @@ try {
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-recent.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script changes the working directory to the 'recent' folder.
|
||||
This PowerShell script changes the current working directory to the 'recent' folder.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -16,8 +16,8 @@ Parameters
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-recent
|
||||
📂C:\Users\Markus\AppData\Roaming\Microsoft\Windows\Recent entered (has 2 files and 3 subfolders)
|
||||
PS> ./cd-recent.ps1
|
||||
📂C:\Users\Markus\AppData\Roaming\Microsoft\Windows\Recent with 2 files and 3 folders entered.
|
||||
|
||||
```
|
||||
|
||||
@ -36,30 +36,31 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the 'recent' folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the 'recent' folder.
|
||||
This PowerShell script changes the current working directory to the 'recent' folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-recent
|
||||
📂C:\Users\Markus\AppData\Roaming\Microsoft\Windows\Recent entered (has 2 files and 3 subfolders)
|
||||
PS> ./cd-recent.ps1
|
||||
📂C:\Users\Markus\AppData\Roaming\Microsoft\Windows\Recent with 2 files and 3 folders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
$path = [Environment]::GetFolderPath('Recent')
|
||||
if (-not(Test-Path "$path" -pathType container)) {
|
||||
throw "No recent folder at $path"
|
||||
}
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "No recent folder at $path" }
|
||||
|
||||
Set-Location "$path"
|
||||
$files = Get-ChildItem $path -attributes !Directory
|
||||
$folders = Get-ChildItem $path -attributes Directory
|
||||
"📂$path entered (has $($files.Count) files and $($folders.Count) subfolders)"
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,36 +1,53 @@
|
||||
The *cd-recycle-bin.ps1* Script
|
||||
===========================
|
||||
|
||||
cd-recycle-bin.ps1
|
||||
|
||||
This PowerShell script changes the current working directory to the user's recycle bin folder.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
|
||||
/Repos/PowerShell/scripts/cd-recycle-bin.ps1 [<CommonParameters>]
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-recycle-bin.ps1
|
||||
📂C:\$Recycle.Bin\S-1-5-21-123404-23309-294260-1001 with 2 files and 0 folders entered.
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the recycle bin folder
|
||||
Sets the working dir to the recycle bin folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the user's recycle bin folder.
|
||||
This PowerShell script changes the current working directory to the user's recycle bin folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-recycle-bin
|
||||
📂C:\$Recycle.Bin\S-1-5-21-123404-23309-294260-1001 entered (has 2 files and 0 subfolders)
|
||||
PS> ./cd-recycle-bin.ps1
|
||||
📂C:\$Recycle.Bin\S-1-5-21-123404-23309-294260-1001 with 2 files and 0 folders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
function GetCurrentUserSID { [CmdletBinding()] param()
|
||||
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
|
||||
return ([System.DirectoryServices.AccountManagement.UserPrincipal]::Current).SID.Value
|
||||
@ -49,12 +66,12 @@ try {
|
||||
Set-Location "$path"
|
||||
$files = Get-ChildItem $path -attributes !Directory
|
||||
$folders = Get-ChildItem $path -attributes Directory
|
||||
"📂$path entered (has $($files.Count) files and $($folders.Count) subfolders)"
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-repo.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script changes the working directory to the given local Git repository.
|
||||
This PowerShell script changes the current working directory to the given local Git repository.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -46,7 +46,7 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Sets the working directory to a repo
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the given local Git repository.
|
||||
This PowerShell script changes the current working directory to the given local Git repository.
|
||||
.PARAMETER folderName
|
||||
Specifies the folder name of the Git repository
|
||||
.EXAMPLE
|
||||
@ -58,6 +58,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
param([string]$folderName = "")
|
||||
|
||||
try {
|
||||
@ -85,9 +87,9 @@ try {
|
||||
& git status --branch --short
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-repos.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script changes the working directory to the folder for Git repositories.
|
||||
This PowerShell script changes the current working directory to the folder for Git repositories.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -36,7 +36,7 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Sets the working dir to the repos folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the folder for Git repositories.
|
||||
This PowerShell script changes the current working directory to the folder for Git repositories.
|
||||
.EXAMPLE
|
||||
PS> ./cd-repos.ps1
|
||||
📂C:\Repos with 33 folders entered.
|
||||
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if (Test-Path "~/Repos" -pathType container) { $path = "~/Repos"
|
||||
} elseif (Test-Path "~/repos" -pathType container) { $path = "~/repos"
|
||||
@ -64,9 +66,9 @@ try {
|
||||
"📂$path with $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if ($IsLinux -or $IsMacOS) { $path = "/" } else { $path = "C:\" }
|
||||
Set-Location "$path"
|
||||
@ -54,9 +56,9 @@ try {
|
||||
"📂$path with $($folders.Count) folders and $($files.Count) files entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,19 +1,34 @@
|
||||
The *cd-screenshots.ps1* Script
|
||||
===========================
|
||||
|
||||
cd-screenshots.ps1
|
||||
|
||||
This PowerShell script sets the current working directory to the user's screenshots folder.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
|
||||
/Repos/PowerShell/scripts/cd-screenshots.ps1 [<CommonParameters>]
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-screenshots.ps1
|
||||
📂C:\Users\Markus\Pictures\Screenshots with 7 files and 0 folders entered.
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
@ -31,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
function GetScreenshotsFolder {
|
||||
if ($IsLinux) {
|
||||
if (-not(Test-Path "~/Pictures" -pathType container)) { throw "No 'Pictures' folder in your home directory yet" }
|
||||
@ -52,9 +69,9 @@ try {
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-scripts.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script changes the working directory to the PowerShell scripts folder.
|
||||
This PowerShell script changes the currrent working directory to the PowerShell scripts folder.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -36,7 +36,7 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the PowerShell scripts folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the PowerShell scripts folder.
|
||||
This PowerShell script changes the currrent working directory to the PowerShell scripts folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-scripts.ps1
|
||||
📂C:\Repos\PowerShell\scripts with 655 scripts entered.
|
||||
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
$path = Resolve-Path "$PSScriptRoot"
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "No scripts folder at: $path" }
|
||||
@ -54,9 +56,9 @@ try {
|
||||
"📂$path with $($files.Count) scripts entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-ssh.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script sets the current working directory to the user's secure shell (SSH) folder.
|
||||
This PowerShell script changes the current working directory to the user's secure shell (SSH) folder.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -36,7 +36,7 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Sets the working dir to the SSH folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script sets the current working directory to the user's secure shell (SSH) folder.
|
||||
This PowerShell script changes the current working directory to the user's secure shell (SSH) folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-ssh.ps1
|
||||
📂C:\Users\Markus\.ssh with 4 files entered.
|
||||
@ -46,10 +46,12 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
$path = "~/.ssh"
|
||||
if (-not(Test-Path "$path" -pathType container)) {
|
||||
throw "No '.ssh' folder in your home directory yet - Is SSH installed?"
|
||||
throw "No '.ssh' folder in your home directory yet - Please install SSH."
|
||||
}
|
||||
$path = Resolve-Path "$path"
|
||||
Set-Location "$path"
|
||||
@ -57,9 +59,9 @@ try {
|
||||
"📂$path with $($files.Count) files entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-sync.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script changes the working directory to the user's Syncthing folder.
|
||||
This PowerShell script changes the current working directory to the user's Syncthing folder.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -17,7 +17,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-sync.ps1
|
||||
📂C:\Users\Markus\Sync entered (has 2 files and 0 folders)
|
||||
📂C:\Users\Markus\Sync with 2 files and 0 folders entered.
|
||||
|
||||
```
|
||||
|
||||
@ -36,30 +36,32 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the user's Sync folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the user's Syncthing folder.
|
||||
This PowerShell script changes the current working directory to the user's Syncthing folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-sync.ps1
|
||||
📂C:\Users\Markus\Sync entered (has 2 files and 0 folders)
|
||||
📂C:\Users\Markus\Sync with 2 files and 0 folders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if (-not(Test-Path "~/Sync" -pathType container)) {
|
||||
throw "No 'Sync' folder in your home directory - is Syncthing installed?"
|
||||
throw "No 'Sync' folder in your home directory yet - Please install Syncthing."
|
||||
}
|
||||
$path = Resolve-Path "~/Sync"
|
||||
Set-Location "$path"
|
||||
$files = Get-ChildItem $path -attributes !Directory
|
||||
$folders = Get-ChildItem $path -attributes Directory
|
||||
"📂$path entered (has $($files.Count) files and $($folders.Count) folders)"
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,19 +1,34 @@
|
||||
The *cd-temp.ps1* Script
|
||||
===========================
|
||||
|
||||
cd-temp.ps1
|
||||
|
||||
This PowerShell script changes the current working directory to the temporary folder.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
|
||||
/Repos/PowerShell/scripts/cd-temp.ps1 [<CommonParameters>]
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-temp.ps1
|
||||
📂C:\Users\Markus\AppData\Local\Temp with 2 files and 3 subfolders entered.
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
@ -21,37 +36,37 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the temporary folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the temporary folder.
|
||||
This PowerShell script changes the current working directory to the temporary folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-temp
|
||||
📂C:\Users\Markus\AppData\Local\Temp (has 2 files and 3 subfolders)
|
||||
PS> ./cd-temp.ps1
|
||||
📂C:\Users\Markus\AppData\Local\Temp with 2 files and 3 subfolders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
function GetTempDir {
|
||||
if ("$env:TEMP" -ne "") { return "$env:TEMP" }
|
||||
if ("$env:TMP" -ne "") { return "$env:TMP" }
|
||||
if ($IsLinux) { return "/tmp" }
|
||||
if ($IsLinux -or $IsMacOS) { return "/tmp" }
|
||||
return "C:\Temp"
|
||||
}
|
||||
|
||||
try {
|
||||
$path = GetTempDir
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw
|
||||
"No temporary folder at $path"
|
||||
}
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "No temporary folder at: $path" }
|
||||
Set-Location "$path"
|
||||
$files = Get-ChildItem $path -attributes !Directory
|
||||
$folders = Get-ChildItem $path -attributes Directory
|
||||
"📂$path entered (has $($files.Count) files and $($folders.Count) subfolders)"
|
||||
"📂$path with $($files.Count) files and $($folders.Count) subfolders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
if (-not(Test-Path "~/Templates" -pathType container)) {
|
||||
@ -64,9 +66,9 @@ try {
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,36 +1,53 @@
|
||||
The *cd-trash.ps1* Script
|
||||
===========================
|
||||
|
||||
cd-trash.ps1
|
||||
|
||||
This PowerShell script changes the current working directory to the user's trash folder.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
|
||||
/Repos/PowerShell/scripts/cd-trash.ps1 [<CommonParameters>]
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-trash.ps1
|
||||
📂C:\$Recycle.Bin\S-1-5-21-123404-23309-294260-1001 with 4 files and 0 folders entered.
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the trash folder
|
||||
Sets the working dir to the trash folder
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the user's trash folder.
|
||||
This PowerShell script changes the current working directory to the user's trash folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-trash
|
||||
📂C:\$Recycle.Bin\S-1-5-21-123404-23309-294260-1001 entered (has 4 files and 0 subfolders)
|
||||
PS> ./cd-trash.ps1
|
||||
📂C:\$Recycle.Bin\S-1-5-21-123404-23309-294260-1001 with 4 files and 0 folders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
function GetCurrentUserSID { [CmdletBinding()] param()
|
||||
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
|
||||
return ([System.DirectoryServices.AccountManagement.UserPrincipal]::Current).SID.Value
|
||||
@ -49,12 +66,12 @@ try {
|
||||
Set-Location "$path"
|
||||
$files = Get-ChildItem $path -attributes !Directory
|
||||
$folders = Get-ChildItem $path -attributes Directory
|
||||
"📂$path entered (has $($files.Count) files and $($folders.Count) subfolders)"
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-up.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script changes the working directory to one directory level up.
|
||||
This PowerShell script changes the current working directory to one directory level up.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -16,7 +16,7 @@ Parameters
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> .\cd-up
|
||||
PS> .\cd-up.ps1
|
||||
📂C:\Users
|
||||
|
||||
```
|
||||
@ -36,9 +36,9 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Sets the working directory to one level up
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to one directory level up.
|
||||
This PowerShell script changes the current working directory to one directory level up.
|
||||
.EXAMPLE
|
||||
PS> .\cd-up
|
||||
PS> .\cd-up.ps1
|
||||
📂C:\Users
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
$path = Resolve-Path ".."
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
||||
@ -53,9 +55,9 @@ try {
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-up2.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script changes the working directory to two directory level up.
|
||||
This PowerShell script changes the current working directory to two directory level up.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -16,7 +16,7 @@ Parameters
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-up2
|
||||
PS> ./cd-up2.ps1
|
||||
📂C:\
|
||||
|
||||
```
|
||||
@ -34,11 +34,11 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the working directory to two directory levels up
|
||||
Sets the working directory 2 directory levels up
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to two directory level up.
|
||||
This PowerShell script changes the current working directory to two directory level up.
|
||||
.EXAMPLE
|
||||
PS> ./cd-up2
|
||||
PS> ./cd-up2.ps1
|
||||
📂C:\
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
$path = Resolve-Path "../.."
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
||||
@ -53,9 +55,9 @@ try {
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-up3.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script changes the working directory to three directory levels up.
|
||||
This PowerShell script changes the current working directory to three directory levels up.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -16,7 +16,7 @@ Parameters
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-up3
|
||||
PS> ./cd-up3.ps1
|
||||
📂C:\
|
||||
|
||||
```
|
||||
@ -34,11 +34,11 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the working directory to three directory levels up
|
||||
Sets the working directory 3 directory levels up
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to three directory levels up.
|
||||
This PowerShell script changes the current working directory to three directory levels up.
|
||||
.EXAMPLE
|
||||
PS> ./cd-up3
|
||||
PS> ./cd-up3.ps1
|
||||
📂C:\
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
$path = Resolve-Path "../../.."
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
||||
@ -53,9 +55,9 @@ try {
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-up4.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script changes the working directory to four directory levels up.
|
||||
This PowerShell script changes the current working directory to four directory levels up.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -16,7 +16,7 @@ Parameters
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-up4
|
||||
PS> ./cd-up4.ps1
|
||||
📂C:\
|
||||
|
||||
```
|
||||
@ -34,11 +34,11 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the working directory to four directory levels up
|
||||
Sets the working directory 4 directory levels up
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to four directory levels up.
|
||||
This PowerShell script changes the current working directory to four directory levels up.
|
||||
.EXAMPLE
|
||||
PS> ./cd-up4
|
||||
PS> ./cd-up4.ps1
|
||||
📂C:\
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
@ -46,6 +46,8 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
$path = Resolve-Path "../../../.."
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "Folder at 📂$path doesn't exist (yet)" }
|
||||
@ -53,9 +55,9 @@ try {
|
||||
"📂$path"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -46,19 +46,20 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
$path = Resolve-Path "~/.."
|
||||
if (-not(Test-Path "$path" -pathType container)) {
|
||||
throw "No users directory at: $path"
|
||||
}
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "No users directory at: $path" }
|
||||
|
||||
Set-Location "$path"
|
||||
$folders = Get-ChildItem $path -attributes Directory
|
||||
"📂$path with $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -16,8 +16,8 @@ Parameters
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-videos
|
||||
📂C:\Users\Markus\Videos entered (has 3 files and 0 subfolders)
|
||||
PS> ./cd-videos.ps1
|
||||
📂C:\Users\Markus\Videos with 3 files and 0 folders entered.
|
||||
|
||||
```
|
||||
|
||||
@ -38,14 +38,16 @@ Script Content
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the user's videos folder.
|
||||
.EXAMPLE
|
||||
PS> ./cd-videos
|
||||
📂C:\Users\Markus\Videos entered (has 3 files and 0 subfolders)
|
||||
PS> ./cd-videos.ps1
|
||||
📂C:\Users\Markus\Videos with 3 files and 0 folders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if ($IsLinux) {
|
||||
$path = Resolve-Path "~/Videos"
|
||||
@ -58,12 +60,12 @@ try {
|
||||
Set-Location "$path"
|
||||
$files = Get-ChildItem $path -attributes !Directory
|
||||
$folders = Get-ChildItem $path -attributes Directory
|
||||
"📂$path entered (has $($files.Count) files and $($folders.Count) subfolders)"
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *cd-windows.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script changes the working directory to the Windows directory.
|
||||
This PowerShell script sets the current working directory to the Windows directory.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -16,8 +16,8 @@ Parameters
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./cd-windows
|
||||
📂C:\Windows entered (has 7 files and 42 folders)
|
||||
PS> ./cd-windows.ps1
|
||||
📂C:\Windows with 7 files and 42 folders entered.
|
||||
|
||||
```
|
||||
|
||||
@ -34,32 +34,35 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the working directory to the Windows directory
|
||||
Sets the working dir to the Windows directory
|
||||
.DESCRIPTION
|
||||
This PowerShell script changes the working directory to the Windows directory.
|
||||
This PowerShell script sets the current working directory to the Windows directory.
|
||||
.EXAMPLE
|
||||
PS> ./cd-windows
|
||||
📂C:\Windows entered (has 7 files and 42 folders)
|
||||
PS> ./cd-windows.ps1
|
||||
📂C:\Windows with 7 files and 42 folders entered.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#requires -version 5.1
|
||||
|
||||
try {
|
||||
if ($IsLinux -or $IsMacOS) { throw "This script requires a Windows operating system" }
|
||||
|
||||
$path = Resolve-Path "$env:WINDIR"
|
||||
if (-not(Test-Path "$path" -pathType container)) {
|
||||
throw "No Windows directory at $path"
|
||||
}
|
||||
if (-not(Test-Path "$path" -pathType container)) { throw "No Windows directory at $path" }
|
||||
|
||||
Set-Location "$path"
|
||||
$files = Get-ChildItem $path -attributes !Directory
|
||||
$folders = Get-ChildItem $path -attributes Directory
|
||||
"📂$path entered (has $($files.Count) files and $($folders.Count) folders)"
|
||||
"📂$path with $($files.Count) files and $($folders.Count) folders entered."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -80,4 +80,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -67,4 +67,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -72,4 +72,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -75,4 +75,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -104,4 +104,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -83,4 +83,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -57,4 +57,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -72,4 +72,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -112,4 +112,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -103,4 +103,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -63,4 +63,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -61,4 +61,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -76,4 +76,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -171,4 +171,4 @@ function Check-Header { param( $path )
|
||||
Check-Header $Path
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -67,4 +67,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -64,4 +64,4 @@ Write-Host "`n === H A R D W A R E ===" -foregroundColor green
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -58,4 +58,4 @@ Script Content
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -61,4 +61,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -85,4 +85,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -99,4 +99,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -55,4 +55,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -88,4 +88,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -57,4 +57,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -76,4 +76,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -59,4 +59,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -67,4 +67,4 @@ Write-Host "`n === N E T W O R K ===" -foregroundColor green
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -59,4 +59,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -73,4 +73,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -95,4 +95,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:34)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -90,4 +90,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -91,4 +91,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -59,4 +59,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -77,4 +77,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:20)*
|
||||
|
@ -98,4 +98,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -6,9 +6,9 @@ This PowerShell script verifies the integrity of a local Git repository and perf
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
/Repos/PowerShell/scripts/check-repo.ps1 [[-pathToRepo] <String>] [<CommonParameters>]
|
||||
/Repos/PowerShell/scripts/check-repo.ps1 [[-path] <String>] [<CommonParameters>]
|
||||
|
||||
-pathToRepo <String>
|
||||
-path <String>
|
||||
Specifies the file path to the local Git repository (current working directory by default)
|
||||
|
||||
Required? false
|
||||
@ -51,10 +51,10 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks a Git repository
|
||||
Checks a Git repo
|
||||
.DESCRIPTION
|
||||
This PowerShell script verifies the integrity of a local Git repository and performs maintenance tasks.
|
||||
.PARAMETER pathToRepo
|
||||
.PARAMETER path
|
||||
Specifies the file path to the local Git repository (current working directory by default)
|
||||
.EXAMPLE
|
||||
PS> ./check-repo.ps1 C:\MyRepo
|
||||
@ -72,7 +72,7 @@ Script Content
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$pathToRepo = "$PWD")
|
||||
param([string]$path = "$PWD")
|
||||
|
||||
try {
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
@ -82,7 +82,7 @@ try {
|
||||
if ($lastExitCode -ne 0) { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
|
||||
Write-Host "⏳ (2/10) Checking local repository... " -noNewline
|
||||
$FullPath = Resolve-Path "$pathToRepo"
|
||||
$FullPath = Resolve-Path "$path"
|
||||
if (!(Test-Path "$FullPath" -pathType Container)) { throw "Can't access folder: $FullPath" }
|
||||
"$FullPath"
|
||||
|
||||
@ -122,12 +122,12 @@ try {
|
||||
|
||||
$repoDirName = (Get-Item "$FullPath").Name
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✅ Checked 📂$repoDirName repo in $($elapsed)s."
|
||||
"✅ Repo '$repoDirName' has been checked in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -28,9 +28,9 @@ Example
|
||||
```powershell
|
||||
PS> ./check-repos.ps1 C:\Repos
|
||||
⏳ Checking parent folder 📂C:\Repos... 16 subfolders
|
||||
⏳ Checking 📂rust repository (1/16)...
|
||||
⏳ Checking repo 'rust' (1/16)...
|
||||
...
|
||||
✅ Checked all 16 Git repos in 📂C:\Repos in 356s.
|
||||
✅ 16 Git repos checked at 📂C:\Repos in 356s.
|
||||
|
||||
```
|
||||
|
||||
@ -55,9 +55,9 @@ Script Content
|
||||
.EXAMPLE
|
||||
PS> ./check-repos.ps1 C:\Repos
|
||||
⏳ Checking parent folder 📂C:\Repos... 16 subfolders
|
||||
⏳ Checking 📂rust repository (1/16)...
|
||||
⏳ Checking repo 'rust' (1/16)...
|
||||
...
|
||||
✅ Checked all 16 Git repos in 📂C:\Repos in 356s.
|
||||
✅ 16 Git repos checked at 📂C:\Repos in 356s.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -78,13 +78,13 @@ try {
|
||||
|
||||
[int]$step = 1
|
||||
foreach ($folder in $folders) {
|
||||
"`n⏳ Checking 📂$folder repository ($step/$numFolders)..."
|
||||
"`n⏳ Checking repo '$folder' ($step/$numFolders)..."
|
||||
& "$PSScriptRoot/check-repo.ps1" "$folder"
|
||||
$step++
|
||||
}
|
||||
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✅ Checked all $numFolders Git repos in 📂$parentDir in $($elapsed)s."
|
||||
"✅ $numFolders Git repos checked at 📂$parentDir in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
@ -92,4 +92,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -56,4 +56,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -120,4 +120,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -64,4 +64,4 @@ Write-Host "`n === S O F T W A R E ===" -foregroundColor green
|
||||
exit 0 # success
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -85,4 +85,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -108,4 +108,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -6,10 +6,10 @@ This PowerShell script checks all symbolic links in a directory tree. It returns
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
/Repos/PowerShell/scripts/check-symlinks.ps1 [[-Folder] <String>] [<CommonParameters>]
|
||||
/Repos/PowerShell/scripts/check-symlinks.ps1 [[-path] <String>] [<CommonParameters>]
|
||||
|
||||
-Folder <String>
|
||||
Specifies the path to the folder
|
||||
-path <String>
|
||||
Specifies the file path to the directory tree
|
||||
|
||||
Required? false
|
||||
Position? 1
|
||||
@ -26,9 +26,9 @@ Parameters
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./check-symlinks D:\
|
||||
⏳ Please wait while checking symlinks at: 📂D:\ ...
|
||||
✅ Found 0 broken symlinks at 📂D:\ in 60s.
|
||||
PS> ./check-symlinks C:\Windows
|
||||
⏳ Checking symlinks at C:\Windows including subfolders...
|
||||
✅ No symlinks at C:\Windows (took 102s).
|
||||
|
||||
```
|
||||
|
||||
@ -45,29 +45,29 @@ Script Content
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Checks all symlinks in a folder
|
||||
Checks all symlinks in a dir tree
|
||||
.DESCRIPTION
|
||||
This PowerShell script checks all symbolic links in a directory tree. It returns the number of broken symlinks as exit value.
|
||||
.PARAMETER folder
|
||||
Specifies the path to the folder
|
||||
.PARAMETER path
|
||||
Specifies the file path to the directory tree
|
||||
.EXAMPLE
|
||||
PS> ./check-symlinks D:\
|
||||
⏳ Please wait while checking symlinks at: 📂D:\ ...
|
||||
✅ Found 0 broken symlinks at 📂D:\ in 60s.
|
||||
PS> ./check-symlinks C:\Windows
|
||||
⏳ Checking symlinks at C:\Windows including subfolders...
|
||||
✅ No symlinks at C:\Windows (took 102s).
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$Folder = "")
|
||||
param([string]$path = "")
|
||||
|
||||
try {
|
||||
if ($Folder -eq "" ) { $Folder = Read-Host "Enter the path to the folder" }
|
||||
if ($path -eq "" ) { $path = Read-Host "Enter the file path to the directory tree" }
|
||||
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
$fullPath = Resolve-Path "$Folder"
|
||||
"⏳ Please wait while checking symlinks at 📂$fullPath ..."
|
||||
$fullPath = Resolve-Path "$path"
|
||||
"⏳ Checking symlinks at $fullPath including subfolders..."
|
||||
|
||||
[int]$numTotal = [int]$numBroken = 0
|
||||
Get-ChildItem $fullPath -recurse | Where { $_.Attributes -match "ReparsePoint" } | ForEach-Object {
|
||||
@ -86,17 +86,19 @@ try {
|
||||
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
if ($numTotal -eq 0) {
|
||||
"✅ No symlink found at 📂$fullPath in $($elapsed)s."
|
||||
"✅ No symlinks at $fullPath (took $($elapsed)s)."
|
||||
} elseif ($numBroken -eq 0) {
|
||||
"✅ No broken symlinks at $fullPath ($numTotal symlinks in total, took $($elapsed)s)."
|
||||
} elseif ($numBroken -eq 1) {
|
||||
"✅ Found $numBroken broken symlink at 📂$fullPath in $($elapsed)s ($numTotal symlinks in total)."
|
||||
"⚠️ 1 broken symlink within $fullPath ($numTotal symlinks in total, took $($elapsed)s)."
|
||||
} else {
|
||||
"✅ Found $numBroken broken symlinks at 📂$fullPath in $($elapsed)s ($numTotal symlinks in total)."
|
||||
"⚠️ $numBroken broken symlinks within $fullPath ($numTotal symlinks in total, took $($elapsed)s)."
|
||||
}
|
||||
exit $numBroken
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -66,4 +66,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -114,4 +114,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -65,4 +65,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -82,4 +82,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -54,4 +54,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -73,4 +73,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -60,4 +60,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -86,4 +86,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -85,4 +85,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -28,11 +28,11 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./clean-repo.ps1 C:\Repos\rust
|
||||
⏳ (1/4) Searching for Git executable... git version 2.47.0
|
||||
⏳ (2/4) Checking local repository... C:\Repos\rust
|
||||
⏳ (1/4) Searching for Git executable... git version 2.50.0
|
||||
⏳ (2/4) Checking local repository... C:\Repos\rust
|
||||
⏳ (3/4) Removing untracked files in repository...
|
||||
⏳ (4/4) Removing untracked files in submodules...
|
||||
✅ Repo 📂rust is clean now.
|
||||
✅ Repo 'rust' is clean now.
|
||||
|
||||
```
|
||||
|
||||
@ -57,11 +57,11 @@ Script Content
|
||||
Specifies the file path to the local Git repository (current working directory by default)
|
||||
.EXAMPLE
|
||||
PS> ./clean-repo.ps1 C:\Repos\rust
|
||||
⏳ (1/4) Searching for Git executable... git version 2.47.0
|
||||
⏳ (2/4) Checking local repository... C:\Repos\rust
|
||||
⏳ (1/4) Searching for Git executable... git version 2.50.0
|
||||
⏳ (2/4) Checking local repository... C:\Repos\rust
|
||||
⏳ (3/4) Removing untracked files in repository...
|
||||
⏳ (4/4) Removing untracked files in submodules...
|
||||
✅ Repo 📂rust is clean now.
|
||||
✅ Repo 'rust' is clean now.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -71,6 +71,8 @@ Script Content
|
||||
param([string]$path = "$PWD")
|
||||
|
||||
try {
|
||||
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
|
||||
Write-Host "⏳ (1/4) Searching for Git executable... " -noNewline
|
||||
& git --version
|
||||
if ($lastExitCode -ne 0) { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
@ -91,12 +93,13 @@ try {
|
||||
& git -C "$path" submodule foreach --recursive git clean -xfd -f # to delete all untracked files in the submodules
|
||||
if ($lastExitCode -ne 0) { throw "'git clean' in the submodules failed with exit code $lastExitCode" }
|
||||
|
||||
"✅ Repo 📂$repoName is clean now."
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✅ Repo '$repoName' cleaned in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -96,9 +96,9 @@ try {
|
||||
"✅ Cleaned $numFolders Git repositories under 📂$parentDirName in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ ERROR: $($Error[0]) in script line $($_.InvocationInfo.ScriptLineNumber)."
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -1,7 +1,7 @@
|
||||
The *clear-dns-cache.ps1* Script
|
||||
===========================
|
||||
|
||||
This PowerShell script clears the DNS client cache of the local computer.
|
||||
This PowerShell script empties the DNS client cache of the local computer.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@ -17,7 +17,7 @@ Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./clear-dns-cache.ps1
|
||||
✅ Cleared DNS cache in 1s.
|
||||
✅ DNS cache cleared in 1s.
|
||||
|
||||
```
|
||||
|
||||
@ -36,10 +36,10 @@ Script Content
|
||||
.SYNOPSIS
|
||||
Clears the DNS cache
|
||||
.DESCRIPTION
|
||||
This PowerShell script clears the DNS client cache of the local computer.
|
||||
This PowerShell script empties the DNS client cache of the local computer.
|
||||
.EXAMPLE
|
||||
PS> ./clear-dns-cache.ps1
|
||||
✅ Cleared DNS cache in 1s.
|
||||
✅ DNS cache cleared in 1s.
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
@ -52,12 +52,12 @@ try {
|
||||
Clear-DnsClientCache
|
||||
|
||||
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||||
"✅ Cleared DNS cache in $($elapsed)s."
|
||||
"✅ DNS cache cleared in $($elapsed)s."
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
"⚠️ Error: $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -58,4 +58,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
@ -119,4 +119,4 @@ try {
|
||||
}
|
||||
```
|
||||
|
||||
*(page generated by convert-ps2md.ps1 as of 06/22/2025 10:37:35)*
|
||||
*(page generated by convert-ps2md.ps1 as of 08/06/2025 15:18:21)*
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user