PowerShell send file to FTP

PowerShell send file to FTP

如何使用 Powershell 傳送檔案至 FTP site

Code:

$ftp = "ftp address"
$user = "anonymous" 
$pass = "anonymous"  
$Dir = "C:\test"
foreach($item in (dir $Dir "*.txt")){
 $webclient = New-Object System.Net.WebClient
 $webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)
 $uri = New-Object System.Uri($ftp+$item.Name) 
 $webclient.UploadFile($uri, $item.FullName) 
}

留言

這個網誌中的熱門文章

Easy Triangle Calculator

Swift Sprite Kit easy to create bullet

Powershell transfert UPS Worldship address book to csv file for UPS web import