
- PowerShell Tutorial
- PowerShell - Home
- PowerShell - Overview
- PowerShell - Environment Setup
- PowerShell - Cmdlets
- PowerShell - Files and Folders
- PowerShell - Dates and Timers
- PowerShell - Files I/O
- PowerShell - Advanced Cmdlets
- PowerShell - Scripting
- PowerShell - Special Variables
- PowerShell - Operators
- PowerShell - Looping
- PowerShell - Conditions
- PowerShell - Array
- PowerShell - Hashtables
- PowerShell - Regex
- PowerShell - Backtick
- PowerShell - Brackets
- PowerShell - Alias
- PowerShell Useful Resources
- PowerShell - Quick Guide
- PowerShell - Useful Resources
- PowerShell - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Powershell - Create Text File
Cmdlet
New-Item cmdlet is used to create a text file and Set-Content cmdlet to put content into it.
Step 1
In this example, we're creating a new text file named test.txt
Type the following command in PowerShell ISE Console
New-Item D:\temp\test\test.txt
You can see the test.txt created in D:\temp\test directory.
Step 2
In this example, we're adding content to test.txt.
Type the following command in PowerShell ISE Console
Set-Content D:\temp\test\test.txt 'Welcome to TutorialsPoint'
Step 3
In this example, we're reading content of test.txt.
get-Content D:\temp\test\test.txt
Output
You can see following output in PowerShell console.
Welcome to TutorialsPoint
powershell_files_io.htm
Advertisements