命令:Get-Content
作用:獲取信息
摘要:獲取指定位置的項的內容。
語法:
Get-Content [-Path] <System.String[]> [-ReadCount <System.Int64>] [-TotalCount <System.Int64>] [-Tail <System.Int32
>] [-Filter <System.String>] [-Include <System.String[]>] [-Exclude <System.String[]>] [-Force] [-Credential <Syste
m.Management.Automation.PSCredential>] [-Delimiter <System.String>] [-Wait] [-Raw] [-Encoding {ASCII | BigEndianUni
code | BigEndianUTF32 | Byte | Default | OEM | String | Unicode | Unknown | UTF7 | UTF8 | UTF32}] [-Stream <System.
String>] [-UseTransaction] [<CommonParameters>]
Get-Content -LiteralPath <System.String[]> [-ReadCount <System.Int64>] [-TotalCount <System.Int64>] [-Tail <System.
Int32>] [-Filter <System.String>] [-Include <System.String[]>] [-Exclude <System.String[]>] [-Force] [-Credential <
System.Management.Automation.PSCredential>] [-Delimiter <System.String>] [-Wait] [-Raw] [-Encoding {ASCII | BigEndi
anUnicode | BigEndianUTF32 | Byte | Default | OEM | String | Unicode | Unknown | UTF7 | UTF8 | UTF32}] [-Stream <Sy
stem.String>] [-UseTransaction] [<CommonParameters>]
說明:“Get Content”cmdlet在路徑指定的位置獲取項的內容,例如文件或函數的內容。對於文件,每次讀取一行內容並返回ob的集合對象,每個對象代表一行內容。
例子1:
Get-Content -Path D:\測試\移動\tao-333.bin
讀取D:\測試\移動\tao-333.bin文件內容
例子2:
Get-Content -Path D:\測試\移動\tao-333.bin | Set-Content D:\測試\移動\123.txt
先讀取D:\測試\移動\tao-333.bin內容再寫入D:\測試\移動\123.txt文件中