Solved

How to add extra line into a CSV

Posted on 2013-06-17
4
418 Views
Last Modified: 2013-06-17
Hello, i am trying to build a CSV with the following:
$date = Get-Date
$Out0 = "---------------VMware Health vCenter2---------------"
$Out1 = "---------------------Date and Time---------------------"
$Out2 = "--------------------" + $date + "----------------------"

Open in new window

But would like to add an space or extra line below of Out2.
Thanks for your help,
0
Comment
Question by:namerg
  • 2
  • 2
4 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39254668
If you are using Add-Content to construct the CSV, then you can try something like..
$file = "C:\temp.csv"
$date = Get-Date
$Out0 = "---------------VMware Health vCenter2---------------`n---------------------Date and Time---------------------`n--------------------" + $date + "----------------------"
Add-Content $file $date                                  
Add-Content $file $Out0
Add-Content $file ""
Add-Content $file "Data Here"

Open in new window

0
 

Author Comment

by:namerg
ID: 39254696
Yep...
Question:
What is the difference between the `n and Add-Content $file "" ?
0
 

Author Comment

by:namerg
ID: 39254715
Hmm, it looks the same thing..right ?
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39254736
`n - is for a new line in PowerShell
If you run Add-Content $file "`n" then it will write "" in a new line (means you get two empty lines before you write "Data Here")


Add-Content $file $Out0
Add-Content $file ""
Add-Content $file "Data Here"


and

Add-Content $file $Out0
Add-Content $file "`nData Here"

Will give the same result..
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Synchronize a new Active Directory domain with an existing Office 365 tenant
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now