Skip to content

cd-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
} catch {
throw
}

This script has no configurable parameters.

An interactive directory of PowerShell scripts.