PowerShell - 檢索項



Cmdlet

Get-Content cmdlet 用於將檔案的正文作為陣列檢索出來。

示例 1

在此示例中,我們將讀取檔案 D:\Temp\Test\Test.txt

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

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

輸出

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

Get-Content D:\temp\test\test.txt
;This is a test file.

示例 2

在此示例中,我們將讀取已讀取的檔案內容的大小。

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

(Get-Content D:\temp\test\test.txt).length

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

(Get-Content D:\temp\test\test.txt).length
20
powershell_files_folders.htm
廣告
© . All rights reserved.