I am new at Powershell and I have spent a whole day working out this how to split a string I have this string path
RootFolder\Subfolder1\SubFolder2\SubFolder3
I want to split this into two strings so that the first string holds the RootFolder and the second string has rest of the string.
E.g: RootFolder\Subfolder1\SubFolder2\SubFolder3
$rootFolder = RootFolder
$subFolders = Subfolder1\SubFolder2\SubFolder3
Thanks in advance!
$root, $path = "RootFolder\Subfolder1\SubFolder2\SubFolder3".Split("\", 2)leaves you with$root # --> RootFolderand$path # --> Subfolder1\SubFolder2\SubFolder3Get-Help Split-Path -Parameter *<<< [grin] look specifically at 'qualifier', 'parent', & 'leaf'. also, if the item is a FileInfo or DirInfo object, look at the.Root,.Parent, and.Directory.Parentproperties.