Reading and Writing Text File using PowerShell

Here I am listing some of the common cmdlets which help to operate with text file-

How to create text file using PowerShell?
New-Item <File Path>
How to open text file or any folder sturcture using PowerShell?
Invoke-Item <File Path>
How to add or append contents in text file using PowerShell?
Add-Content <File Path> Text with single quote
How to clear contents in text file using PowerShell?
Clear-Content <File Path>
How to clear contents and add new contents in text file using PowerShell?
Set-Content <File Path> Text with single quote
How to read file contents using PowerShell?
Get-Content <File Path>
How to save cmdlets outputs directly to text file?
Cmdlets | Out-File <File Path>. Example: Get-Process | Out-File D:\PowerShell
How to remove text file using PowerShell?
Remove-Item <File Path>

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s