$path = "usr/local/bin/pwsh" # -split takes a regex and a max-splits count $head, $rest = $path -split '/', 2 Write-Output $head Write-Output $rest
regex split into head and rest