Collections:
Other Resources:
Put Data into File in Windows PowerShell
How to put data into a file in Windows PowerShell?
✍: FYIcenter.com
You can use the "Set-Content" or "Add-Content" cmdlet to put data into a file in Windows PowerShell.
The "Set-Content" cmdlet is a string-processing cmdlet that writes or replaces the content in the specified item, such as a file. You can type the content in the command or send content through the pipeline to Set-Content.
The "Add-Content" cmdlet appends content to a specified item or file. You can specify the content by typing the content in the command or by specifying an object that contains the content.
Example 1: The following command replaces the contents of all files in the Test1 directory that have names beginning with "test" with "Hello, World".
PS C:\fyicenter> Set-Content -Path C:\Test1\test*.txt -Value "Hello, World"
Example 2: The following command replaces the contents of the final.xml file with the contents of the test.xml file. The command uses the Force parameter so that the command is successful even if the Final.xml file is read-only. It uses the Encoding dynamic parameter to specify an encoding of UTF-8.
PS C:\fyicenter> Get-Content test.xml | Set-Content final.xml -Force -Encoding UTF8
Example 3: The following command adds "END" to all text files in the current directory, except for those with file names that begin with "help."
PS C:\fyicenter> Add-Content -Path *.txt -Exclude help* -Value "END"
⇒ Send Console Output to File in Windows PowerShell
⇐ Get File Content in Windows PowerShell
2016-10-22, ∼3181🔥, 0💬
Popular Posts:
Everytime when connect a USB device the volume lowers by 80% It happen with Soundblaster Audigy SE a...
How to use .htaccess file with Apache server on Window systems? Assuming that you have installed the...
I have a problem wiht the Drivers Video Card, I have a laptop HP dv6448se and the video card are a N...
Why I am getting the "Why did my PC restart?" message? After taking the quick setup information, you...
Can I remove startup application "WZQKPICK.exe - WinZip Quick Pick" to speedup my computer and reduc...