How to Remove Whitespace from Strings in PowerShell
To remove whitespace from strings in PowerShell, use .Trim() for spaces at the start and end, or -replace ‘\s’, ” to strip every space, tab and line break: Which one you need depends on whether the spaces inside the text matter. I tested every example in PowerShell 7 and Windows PowerShell 5.1, including the invisible … Read more