私はいくつかのファイルをFTPサーバーに置くスクリプトを持っているので、サーバーIP($ FTPServer)とファイルからのディレクトリがアップロードされます(\ Upload)。PowerShell FTPクライアントモジュールの上書き確認を自動化
PSFTPモジュールhttps://gallery.technet.microsoft.com/scriptcenter/PowerShell-FTP-Client-db6fe0cbが使用されています。
問題は、アップロードしたファイルがすでにサーバー上に存在し、上書きについて尋ねられるたびに問題です。私はこのことを自動化する必要があります。
Aファイル名:...は、この場所に既に存在します。
何をしますか?
私は-Confirm:$false
を入れようとしていましたが、間違っていなければなりません。 Add-FTPItem
foreach ($line in $FTPServer)
{
foreach ($item in (Get-ChildItem .\Upload))
{
Start-Transcript -Path $results
Write-Host -Object "ftp url: $line"
Set-FTPConnection -Credentials $FTPCredential -Server $line -Session MySession -UsePassive
$Session = Get-FTPConnection -Session MySession
Write-Host -Object "Uploading $FILE..."
Add-FTPItem -Session $Session -Path $FTPPlace -LocalPath .\Upload\$item -Confirm:$false
Stop-Transcript
}
}
申し訳ありませんが、それはPSFTP Modeule https://gallery.technet.microsoft.com/scriptcenter/PowerShell-FTP-Client-db6fe0cb – TraPS