我需要从服务器列表(computer-list.txt)中删除文件列表(在 remove-files.txt 中)。我已经尝试了以下方法,但没有成功,我希望有人可以帮助我纠正我的错误。
$SOURCE = "C:\powershell\copy\data"
$DESTINATION = "d$\copy"
$LOG = "C:\powershell\copy\logsremote_copy.log"
$REMOVE = Get-Content C:\powershell\copy\remove-list.txt
Remove-Item $LOG -ErrorAction SilentlyContinue
$computerlist = Get-Content C:\powershell\copy\computer-list.txt
foreach ($computer in $computerlist) {
Remove-Item \\$computer\$DESTINATION\$REMOVE -Recurse}
错误
Remove-Item : Cannot find path '\\NT-xxxx-xxxx\d$\copy\File1.msi, File2.msi, File3.exe, File4, File5.msi,' because it does not exist.
At C:\powershell\copy\REMOVE_DATA_x.ps1:13 char:12
+ Remove-Item <<<< \\$computer\$DESTINATION\$REMOVE -Recurse}
+ CategoryInfo : ObjectNotFound: (\\NT-xxxx-xxxxx\...-file1.msi,:String) [Remove-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand