How to create Text File using PowerShell

In this post, we gonna create a Text file using PowerShell. Using the New-Item cmdlet we can create a text file and with the Set-Content cmdlet, we can put content into it. Using get-Content cmdlet we can read the generated file.

Create a text file

In this example, we’re creating a new text file named test.txt

Open your Powershell and execute below command

You can see the test.txt created in D:\temp directory.

Add or Replace text in the file

In this example, we’re going to add content to the text file named test.txt

Open your PowerShell and execute below command

You can see the test.txt created or updated file in D:\temp directory.

Set-Content will update the file if it already exists otherwise it will create and put content.

you can test it with the get-content cmdlet will give the “Welcome to ArjunPHP.com” text output.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
DMCA.com Protection Status
0
Would love your thoughts, please comment.x
()
x