Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

Converting the FileSystemObject's WriteBlankLines Method

Windows PowerShell

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


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

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


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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft