Hi guys,
I have the following PowerShell code;
$FolderPath = "\\server\folder1\folder2\~folder3"
$SplitFolder = $FolderPath -split '\\'
I can then echo each split using;
echo $SplitFolder[2]
server
echo $SplitFolder[3]
folder1
echo $SplitFolder[4]
folder2
but when I get to echo $SplitFolder[5], because the folder name begins with a tilde (~), it fails;
echo $SplitFolder[5]
Cannot index into a null array.
At line:1 char:1
+ echo $SplitFolder[5]
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorI