Skip to content

New-Dir

Creates a new directory

param([string]$path = "")

try {
	if ($path -eq "") { $path = Read-Host "Enter the filename (and path) of the new directory" }

	if (Test-Path $path) { throw "Directory at $path already exists" }

	$null =	(New-Item -itemType directory -path $path)

	$path = Resolve-Path $path
	"? New ??$path created."
	exit 0 # success
} catch {
	"?? ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
	exit 1
}

Specifies the path and filename of the new directory

An interactive directory of PowerShell scripts.