That's because $user isn't a string. It's an object having a Username property (you could see that if you piped it to Get-Member). If, instead, you did "select-object -expand username" then you'd get the behavior you expected. -Expand extracts the CONTENT of the property, in this case returning a simple string.
The topic ‘Removing characters from a string with -replace’ is closed to new replies.