【发布时间】:2019-03-31 15:14:23
【问题描述】:
我想从pathlist.txt中的每个路径获取内容,每个路径内容都应该保存到他自己的pathname.txt文件中,命名为输入路径。
所以是这样的:
$pathlist = Get-Content C:\Test\pathlist.txt
$pathlist | % {
Get-ChildItem $_ -Recurse |
Out-File C:\Test\Output\"computername_" + $($_.replace("\","_").replace(":","")) +".txt"
}
输入:
- C:\Test\Test\Test
- D:\下载
- C:\Windows\Temp
输出:
- 计算机名_C_Test_Test_Test.txt
- 计算机名_D_Download.txt
- 计算机名_C_Windows_Temp.txt
每个输出文本文件都包含来自 Get-ChildItem -Recurse 命名路径的结果。
【问题讨论】:
标签: powershell