Skip to content

Count-Characters

Counts the number of characters

param([string]$givenString = "")

try {
	if ($givenString -eq "" ) { $givenString = Read-Host "Enter the string" }

	[int64]$numChars = $givenString.Length
	"? $numChars characters counted in '$givenString'." 
	exit 0 # success
} catch {
	"?? ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
	exit 1
}

Specifies the given string.

An interactive directory of PowerShell scripts.