Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

rmcclung is back with more powershell questions!

$
0
0
Powershell
$sourceuri="ftp://x.x.x.x/New Text Document.txt"$username="xxxxx"$password='xxxxx'# Create a FTPWebRequest object to handle the connection to the ftp server$ftprequest=[System.Net.FtpWebRequest]::create($sourceuri)$credentials=New-ObjectSystem.Net.NetworkCredential($username,$password)# set the request's network credentials for an authenticated connection$ftprequest.Credentials=$credentials$ftprequest.Method=[System.Net.WebRequestMethods+Ftp]::UploadFile$ftprequest.UseBinary=1$ftprequest.KeepAlive=0# read in the file to upload as a byte array$content=gc-enbyte'C:\Temp\New Text Document.txt'$ftprequest.ContentLength=$content.Length# get the request stream, and write the bytes into it$rs=$ftprequest.GetRequestStream()$rs.Write($content,0,$content.Length)# be sure to clean up after ourselves$rs....

Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>