Extra new lines when writing variables to file issue


PS C:\> gc c:\test.out
abc def
PS C:\>

The reason why ‘gha’ is in second line is that $var2 had a special sign of new line in it.

What i wanted to see in this file is to see 1 line ” abc def gha”. That’s just an example. I was printing to file some vms report and noticed that instead 1 line i had several variables that were making new line. In order to be sure that there is no additional characters besides text we can trim our variables.




PS C:\> echo “$var1 $($var2.trim()) $var3” > c:\test.out
PS C:\> gc C:\test.out
abc def gha

So whenever you will see in output files unexpected new lines,  just trim the variable. For people who are starting with powershell : $() means sub-expression, you can read about it here :


or you can read about it from your powershell console typing:

help about_operators | more

FREE vmware course , Free ebook VMware ESXi: Planning, Implementation, and Security

I was reading deinoscloud blog, and noticed 1 news, a GREAT NEWS !!!!
You can register for free vmware online course at:

About the course, let me paste the overview :

” This self-paced training course covers the requirements and effects of transitioning your VMware vSphere™ environment to VMware® ESXi. It provides the knowledge necessary to make fundamental design decisions and successfully add ESXi to a deployed vSphere environment. This course is based on ESXi 4.1.”

As deinosCloud writes :

“By completing the Transition to ESXi Essentials course and the short survey that follows at the end, you will also receive a FREE ebook copy of “VMware ESXi: Planning, Implementation, and Security authored by Dave Mishchenko and edited by VMware technical experts. Dave’s book is truly a phenomenal resource for all VMware users to learn everything there is to know about ESXi. While the Transition to ESXi Essentials course will remain available for free in the VMware Education Services portal, we’ll be able to also offer Dave’s book for free only while supplies last. So, hurry up, complete the training and turn in your survey as soon as possible!”

I hope there will be still 1 for me 😉