我正在尝试使用PowerShell将文件上传到FTP,这会给我以下错误:
使用2个参数“无法连接到远程服务器”的异常调用“ uploadfile”。
$dir = “dir”
$ftp = “ftp”
$user = ...
$password = ...
$webclient = New-Object System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredentials($user, $password)
foreach ($item in (dir $dir “*”)) {
$uri = New-Object System.Uri($ftp + $item.Name)
$webclient.UploadFile($uri, $item.FullName)
}