Solved

How to add extra line into a CSV

Posted on 2013-06-17
4
420 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This article will help you understand what HashTables are and how to use them in PowerShell.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

806 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