Powershell - Create HTML File



Cmdlet

New-Item cmdlet is used to create a html file and Set-Content cmdlet to put content into it.

Step 1

In this example, we're creating a new html file named test.html

Type the following command in PowerShell ISE Console

New-Item D:\temp\test\test.html -ItemType File

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

Step 2

In this example, we're adding content to test.html.

Type the following command in PowerShell ISE Console

Set-Content D:\temp\test\test.html '<html>Welcome to TutorialsPoint</html>'

Step 3

In this example, we're reading content of test.html.

Get-Content D:\temp\test\test.html

Output

You can see following output in PowerShell console.

<html>Welcome to TutorialsPoint</html>
powershell_files_io.htm
Advertisements