Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Remove Leading and Trailing Spaces with PowerShell

$
0
0

Summary: Use the Trim() method to remove extraneous space from a String object.

Hey, Scripting Guy! Question Is there an easy way to drop all spaces that are before or after a string in Windows PowerShell?

Hey, Scripting Guy! Answer Use the Trim() method to remove all spaces before and after a string from the output, for example:

$Something='                 I love PowerShell                     '

$Something.trim()


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>