Go-Windows
Sets the working dir to the Windows directory
#requires -version 5.1
try {
if ($IsLinux -or $IsMacOS) { throw "This script requires Windows" }
$path = Resolve-Path "$env:WINDIR"
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)"
exit 0 # success
} catch {
"?? ERROR: $($Error[0])"
exit 1
}This script has no configurable parameters.