Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Converting the FileSystemObject's WriteBlankLines Method


Windows PowerShell


Definition: Adds a specified number of blank lines (newline characters) to a text file.

WriteBlankLines


To add a blank line in PowerShell, use either of these commands:


Add-Content c:\scripts\test2.txt -value ""


-or-


Add-Content c:\scripts\test2.txt -value "`n"


You can use the latter to add more than one blank line; this example adds three blank lines:


Add-Content c:\scripts\test2.txt -value "`n`n`n"


To add a lot of blank lines, you could simply put the command in a loop, looping through once for each blank line you want to add. This loop adds 5 blank lines:


for($i = 1; $i -lt 6; $i++)
{
    Add-Content c:\scripts\test2.txt -value "`n"
}


See conversions of other FileSystemObject methods and properties.
Return to the VBScript to Windows PowerShell home page

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.