Eu reescrevi um pouco o script e consegui que ele funcionasse sem usar o protocolo FTP. Eu mudei para usar o comando move em vez disso:
$down = "C:\Script\log\down-hosts.log"
$computers = Get-Content "C:\Script\list\Computers.txt"
$TargetPath = "\ServerName\ShareName\Path"
$SourceFileName = "source_file.csv"
foreach ($computer in $computers) {
if ( Test-Connection -ComputerName $computer -Count 1 -ErrorAction SilentlyContinue
{
$sourcefilePath = "\$computer\c$\UPS CSV Exports\$SourceFileName"
Write-Host "$computer is up"
Write-Host "Copying $SourceFilePath ..."
Try {
If (Test-Path $SourceFilePath) {
Move-Item $SourceFilePath "$TargetPath\$computer'_$SourceFileName" -force
} Else {
Throw "$SourceFilePath does not exist"
}
} Catch {
Write-Host "Error: $($Error[0].Exception.Message)"
}
} Else {
Write-Host "$computer is down"
"$computer is down" | Out-File $down -append
}
}
Depois de fazer as alterações, o script funciona perfeitamente!