Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to add extra line into a CSV

Posted on 2013-06-17
4
Medium Priority
?
437 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

636 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