这里有简单的脚本,至少我认为应该是这样,但我对最终结果有疑问:
$a = Get-Content "content\file\location"
$destfile = "destination\of\file"
$source ="source\file\location"
$dest = "c$\destination"
$destfolder = "c:\folder\destination"
foreach ($a in $a) {
if (Test-Connection $a -Count 1 -Quiet) {
if (Test-Path "\\$a\$destfile") {
Write-Host $a "File exists" -ForegroundColor Green
} else {
Write-Host $a "File is missing and will now be copied to $a\$destfolder" -ForegroundColor Red |
Copy-Item $source -Destination "\\$a\$dest"
}
}
}
问题是它从不复制文件,我哪里出错了?
我在这里先向您的帮助表示感谢。