Summary: Use the Trim() method to remove extraneous space from a String object.
Is there an easy way to drop all spaces that are before or after a string in Windows PowerShell?
Use the Trim() method to remove all spaces before and after a string from the output, for example:
$Something=' I love PowerShell '
$Something.trim()