Hi,
I'm trying to trim off the file extension from a filename like this:
$FileName = "C:\Program Files\Microsoft\Configuration Manager\Configuration Manager Console.exe"
$NewName = $FileName.Split("\")[-1].TrimEnd(".exe")
Result is ...
Configuration Manager Consol
... with the "e" at the end missing.
There are a couple of workarounds to fix this including using "-replace" or "Split" it again via the dot. But I would like to understand how TrimEnd works as I was under the impression that only ".exe" would be remove from the end of the string. But it also removes any similar characters before the dot if these characters are "e" or "x" or any combination of them.
Something to do with the way it interprets the characters before and after the dot. Any advice would be most appreciated.
Thanks.