POWERSHELL HANDLE FILE CONTENTS

To add contents to a file we can use the Add-Content cmdlet.

powershell

Add-Content -Path C:\path_to_destination_file "Content to be added"

To get a file contents we can use the Get-Content cmdlet.

powershell

Get-Content C:\file_to_source | Add-Content -Path C:\path_to_destination_file

This is similar to use cat and redirection >> in the Unix world.

bash

cat /file_to_source >> /path_to_destination_file

powershell

Add-Content -Path C:\path_to_destination_file "Content to be added"; Get-Content C:\file_to_source | Add-Content -Path C:\path_to_destination_file

Related Content