I'm looking to remove the final '/' character from a string that contains multiple storage paths in it, what is the best way to go about this, I keep getting close but I still can't quite get what I'm looking for, is a loop really the only way?
$Paths = /some/path/1/ /some/path/2/ /some/path/3/
$Paths = $Paths.Remove($Paths.Length - 1)
$Index = $Paths.LastIndexOf('/')
$ID = $Paths.Substring($Index + 1)
I'm currently getting errors like the following:
Exception calling "Remove" with "1" argument(s): "Collection was of a fixed size."
The desired final version of $Paths would be
/some/path/1 /some/path/2 /some/path/3
Any help would be greatly appreciated, I think I may have a process issue as well as a coding issue...