VMware Cloud Community
GGovinda
Contributor
Contributor
Jump to solution

Remove White spaces

Hello,

How do i remove the White space at the begining or end of variable value,

for ex:

I use .csv to have the vmnames and other values. i want to make sure that before passing the $vmname to Powecli Comdlets the spaces if any should be truncated.

any pointers?

Thanks,Govinda.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can use the Trim, TrimStart and TrimEnd methods.

For example

$t = "   abc"

$t.TrimStart(' ')


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You can use the Trim, TrimStart and TrimEnd methods.

For example

$t = "   abc"

$t.TrimStart(' ')


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
GGovinda
Contributor
Contributor
Jump to solution

Thank you Luc, Thats perfect !! works Awesome.

0 Kudos