Difference between revisions of "Writing to a file"
From MyWiki
(Created page with " $text = 'Hello World' # Create file: $text | Set-Content 'file.txt' #or $text | Out-File 'file.txt' #or $text > 'file.txt' # Append to file: $text | Add-Content '...") |
|||
Line 1: | Line 1: | ||
$text = 'Hello World' | $text = 'Hello World' | ||
− | + | # | |
# Create file: | # Create file: | ||
− | + | # | |
$text | Set-Content 'file.txt' | $text | Set-Content 'file.txt' | ||
#or | #or | ||
Line 8: | Line 8: | ||
#or | #or | ||
$text > 'file.txt' | $text > 'file.txt' | ||
− | + | # | |
# Append to file: | # Append to file: | ||
− | + | # | |
$text | Add-Content 'file.txt' | $text | Add-Content 'file.txt' | ||
#or | #or |
Latest revision as of 09:55, 9 September 2014
$text = 'Hello World' # # Create file: # $text | Set-Content 'file.txt' #or $text | Out-File 'file.txt' #or $text > 'file.txt' # # Append to file: # $text | Add-Content 'file.txt' #or $text | Out-File 'file.txt' -Append #or $text >> 'file.txt'