Solved

How to add extra line into a CSV

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
"Requested registry access is not allowed" 10 53
Problem with Powershell 15 42
AD Expiration from CSV 4 21
Can't a Exchange 2010 snap-in in PowerShell script 25 15
How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

18 Experts available now in Live!

Get 1:1 Help Now