Add-content to beginning of file power shell
cls #Define Functions (gc g:\area907.info) -replace '\S+$','$& 1GB RAM 1x 1 GB Stick' | out-file "g:\ram area907.info" Change the file location. First file is the file you want to edit. Adding Lines to the Beginning and Ending of Files Using PowerShell. Looping through these file names, each file is read into memory (using Get-Content). The root of the file is then removed with the first replace command, and for aesthetics, I chose to change backslashes into forward slashes with the second one (lines 4 and 5). Aug 10, · Add a Line to the Beginning of a Text File and Simultaneously Delete the Last L. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose.