PowerShell: File Write

Writing to a file from stdin line by line

PS C:\> Set-Content file.txt

cmdlet Set-Content at command pipeline position 1
Supply values for the following parameters:
Value[0]: aaa
Value[1]: bbb
Value[2]: 

Writing to a file from a variable

PS C:\> $str = "Hello, World"
PS C:\> Set-Content file.txt -Value $str
PS C:\> Get-Content file.txt
Hello, World

Writing to a file as Byte[]

PS C:\> [Byte[]] $str = 0x10, 0x20, 0x30, 0x40
PS C:\> Set-Content file.txt -Value $str -AsByteStream

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *