Powershell - 建立檔案
Cmdlet
New-Item cmdlet 用於通過使用 -Path 作為檔案路徑並將 -ItemType 作為 File 來建立檔案。
例
在這個例子中,我們將在 D:\Temp\Test 資料夾中建立一個名為 Test File.txt 的檔案。
在 PowerShell ISE 控制檯中鍵入以下命令
New-Item -Path 'D:\temp\Test Folder\Test File.txt' -ItemType File
輸出
你將看到以下輸出。
Directory: D:\temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/3/2018 7:14 PM 0 Test File.txt
你可以在 Windows 資源管理器中看到相同的內容,其中在 D:\Temp\Test Folder 目錄中建立了 Test File.txt。