does anyone have an idea how to upload files in ASCII mode to a FTP server (Mainfraim / z/OS) with powershell?
Also, mainframe FTP “quote site” commands should be passed to the FTP server.
I can’t use WinSCP or FTP client…
- Powershell (>=5.x )
- an FTP client cannot be used (system restrictions)
- FTP “quote site” commands must be passed to the ftp (mainframe/z/os) server
Any idea ?
I’ve seen system.net.webclient objects used to ftp in PS. I’m not sure of the ASCII mode but you might want to check out this:
Hi thanks for the answere but it uploads in binary mode…because he use System.Net.WebClient …and the webClient is always in binary mode…and it is not posible to switch.
System.Net.FTPWebRequest is possible with .copyTo()…something like this
$FTPRequest = [System.Net.FtpWebRequest]::Create("$File")
$FTPRequest = [System.Net.FtpWebRequest]$FTPRequest
$FTPRequest.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile
$FTPRequest.Credentials = New-Object System.Net.NetworkCredential ("$UserID","$UserPWD")
$FTPRequest.UseBinary = $false
$FileContent = [System.IO.File]::OpenRead("$("$File_Path" + "$File_Name")")
$Stream = $FTPRequest.GetRequestStream()
But i don’t know how to send the ftp “qoute site” parameter to the remote FTP
The Qoute site is a special Mainfraim parameter.
The question is how to send command to the FTP server via Powershell…it could also be a LIST, QUIT command or something like that.
Any other suggestions?