输出

我们可以在PowerShell控制台中看到以下输出。

Get-Content D:\temp\test\test.txt
;This is a test file.
Powershell-检索内容

Cmdlet

Get-Content cmdlet用于以数组形式检索文件的内容。

例1

在本例中,我们将读取文件D:\Temp\Test\test.txt的内容

在PowerShell ISE控制台中键入以下命令

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

例2

在本例中,我们将读取文件内容的大小。

在PowerShell ISE控制台中键入以下命令

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

我们可以在PowerShell控制台中看到以下输出。

(Get-Content D:\temp\test\test.txt).length
20
日期:2019-08-20 13:51:00 来源:oir作者:oir