powershell Ftp 脚本
程序员文章站
2022-04-29 15:54:07
...
Powershell Ftp 上传:
$ftp = [System.Net.FtpWebRequest]::Create("ftp://hostdomain/filename")
$ftp = [System.Net.FtpWebRequest]$ftp
$ftp.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile
$ftp.Credentials = new-object System.Net.NetworkCredential("UserName","Password")
$ftp.UseBinary = $true
$ftp.UsePassive = $true
$content = [System.IO.File]::ReadAllBytes("The file path to be upload in local computer")
$ftp.ContentLength = $content.Length
$rs = $ftp.GetRequestStream()
$rs.Write($content, 0, $content.Length)
$rs.Close()
$rs.Dispose()