Powershell - 刪除檔案內容

Cmdlet

Clear-Content cmdlet 可用於清除 txt 檔案的內容。

在這個例子中,我們正在刪除檔案 test.txt 的內容。

Clear-Content D:\temp\test\test.txt

現在,如果我們讀取檔案 test.txt 的內容。

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

就會發現檔案裡的內容時空的。