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)
}
```
留言
張貼留言