powershell - Powershell 从多台远程计算机、所有驱动器中查找多个文件
问题描述
需要制作一个从多台计算机列表中查找文件列表的脚本。下面的脚本可以正常工作。现在需要添加一个功能,以便脚本通过每台计算机的所有驱动器,而不仅仅是 C$。问题是我不知道哪些电脑有哪些驱动器..
当前脚本:
$computers = Get-Content .\computers.txt
$filenames = Get-Content .\filenamelist.txt
foreach ($computer in $computers) {
foreach ($filename in $filenames) {
Get-ChildItem -Recurse -Force \\$computer\c$ -ErrorAction SilentlyContinue |
Where-Object { ($_.PSIsContainer -eq $false) -and ( $_.Name -eq "$filename") } |
Select-Object Name, Directory |
Export-Csv .\FoundFiles.csv -nti -append
}
}
所以我应该以某种方式实现命令行:
$Drives = Get-PSDrive -PSProvider 'FileSystem'
这样它就可以在每台计算机上运行,并根据结果运行 Get-ChildItem 行,用于每台远程计算机上的每个现有驱动器。
请问有什么想法吗?
解决方案
推荐阅读
- spring-boot - 从枚举中插入默认实体
- c++ - C ++测试回调是否为空
- python - 应用程序未运行时如何在 kivy 中发送推送通知?
- javascript - 在 VSCode 中查找和覆盖默认代码片段
- javascript - 是否可以从 CORS 政策网站上抓取数据?
- flutter - 我在颤动的刷卡器中看不到我的照片
- c# - C# - Linq - 在 linq 表达式中动态添加比较运算符 (==,>=,<=,!=)
- gaussian - 与 c2c 相比,使用 fftw3 r2c 的 2D 双数组的 DFT
- python - 如何在这个网站上获得发帖请求?https://www.upiqrcode.com/iban-generator/de/germany
- angular - 角度通用在waveform.js中不起作用