user358485 user358485 - 1 year ago 147
PowerShell Question

script to make content entry into a text file

How to include some "text" into a .txt format file without opening the same via a script on windows?

Answer Source

I will give you an all PowerShell answer. You can use Add-Content or Set-Content cmdlets.

Set-Content overwrites the target file and Add-Content appends to the file.

Set-Content -Value "Test1" -Path C:\Scripts\Scratch\test.txt
Add-Content -Value "Test" -Path C:\Scripts\Scratch\test.txt

Or, you can use Out-File also.

"Test" | Out-File -FilePath C:\Scripts\Scratch\test.txt -Append
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download