Script to make content entry into a text file
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 also use Out-File.
"Test" | Out-File -FilePath C:\Scripts\Scratch\test.txt -Append
Here is the sample code to create and add content into a text file:
$text = Hello World
# This is to create file:
$text | Set-Content MyFile.txt
# Or
$text | Out-File MyFile.txt
# Or
$text > MyFile.txt
# This is to write into a file or append to the text file created:
$text | Add-Content MyFile.txt
# Or
$text | Out-File MyFile.txt -Append
# Or
$text >> MyFile.txt
The command you need is echo
(alias of Write-Output - use Get-Alias to get the list):
echo Text >> textFile.txt
This link should prove helpful in learning Windows commands.