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.html