Powershell - 建立 HTML 檔案



Cmdlet

New-Item cmdlet 用於建立一個 html 檔案,Set-Content cmdlet 用於在其中放置內容。

步驟 1

在此示例中,我們正在建立一個名為 test.html 的新 html 檔案

在 PowerShell ISE 控制檯中鍵入以下命令

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

你可以在 D:\temp\test 目錄中看到建立的 test.html。

步驟 2

在此示例中,我們正在將內容新增到 test.html。

在 PowerShell ISE 控制檯中鍵入以下命令

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

步驟 3

在此示例中,我們正在讀取 test.html 的內容。

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

輸出

你可以在 PowerShell 控制檯中看到以下輸出。

<html>Welcome to TutorialsPoint</html>
powershell_files_io.htm
廣告
© . All rights reserved.