Trimming white space

Friday, October 10th, 2014

Working with a CSV file; I had a situation where the command line would give the output I wanted but the script would get the object information.  I found I could get what I needed by converting the output to a script but it introduced white space.  A computer name would turn into:

“Computer                                       “

What was interesting was the system commands would treat the white space as part of the computer name which of course cause the commands to fail.

Look around the Net; I found a command to trim white space.

$server = $server.trim()

The system name returned to proper size and what is great about this command is that it will trim white space from both sides.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: