$line = "one two three" # -split takes a regex; \s+ collapses runs of spaces $words = $line -split '\s+' Write-Output $words.Count
split on a regex