如何在PowerShell中检索文件的内容?
要在PowerShell中检索文件的内容,您需要使用Get-Contentcmdlet。例如,我们将从特定位置检索名为Aliases.txt的文本文件的内容。
示例
Get-Content D:\Temp\aliases.txt
输出结果
PS C:\WINDOWS\system32> Get-Content D:\Temp\aliases.txt # Alias File # Exported by : admin # Date/Time : 26 January 2020 19:20:24 # Computer : DESKTOP-9435KM9 "foreach","ForEach-Object","","ReadOnly, AllScope" "%","ForEach-Object","","ReadOnly, AllScope" "where","Where-Object","","ReadOnly, AllScope" "?","Where-Object","","ReadOnly, AllScope" "ac","Add-Content","","ReadOnly, AllScope" "clc","Clear-Content","","ReadOnly, AllScope" "cli","Clear-Item","","ReadOnly, AllScope" "clp","Clear-ItemProperty","","ReadOnly, AllScope" "clv","Clear-Variable","","ReadOnly, AllScope" "compare","Compare-Object","","ReadOnly, AllScope" "cpi","Copy-Item","","ReadOnly, AllScope" "cpp","Copy-ItemProperty","","ReadOnly, AllScope" "cvpa","Convert-Path","","ReadOnly, AllScope" "dbp","Disable-PSBreakpoint","","ReadOnly, AllScope" "diff","Compare-Object","","ReadOnly, AllScope" "ebp","Enable-PSBreakpoint","","ReadOnly, AllScope" "epal","Export-Alias","","ReadOnly, AllScope" "epcsv","Export-Csv","","ReadOnly, AllScope" "fc","Format-Custom","","ReadOnly, AllScope" "fl","Format-List","","ReadOnly, AllScope" "ft","Format-Table","","ReadOnly, AllScope" "fw","Format-Wide","","ReadOnly, AllScope" "gal","Get-Alias","","ReadOnly, AllScope" "gbp","Get-PSBreakpoint","","ReadOnly, AllScope" "gc","Get-Content","","ReadOnly, AllScope"
您也可以从远程位置检索文件的内容。
例如,
Get-Content \\Test-PC\Shared\Powershellaliases.txt
热门推荐
1 训练狗狗基础
2 怎么训练狗狗笑
3 怎么训练狗狗卧下
4 上海狗狗训练基地
5 训练狗狗排便
6 狗狗基础训练
8 如何训练狗狗装死
9 狗狗站姿训练
10 狗狗训练用品
11 训练狗狗吧
12 狗狗要怎么训练
13 怎么训练狗狗玩球
14 训练狗狗唤回
15 狗狗训练躺下
16 狗狗训练指令
17 狗狗的训练技巧
18 狗狗不好训练