Am copying file from remote server and saving in my local machine using PowerShell. But after I copied filed from remote server while I open that file in Notepad, it's not opening in proper format (alignment). But if I copying using FTP command manually its alignment is proper in Notepad.
Please find my PowerShell script:
$File = "D:\copiedfile.txt"
$ftp = "ftp://remote_machine_name//tmp/text.txt"
$ftprequest = [System.Net.FtpWebRequest]::Create($ftp)
$ftprequest.UseBinary = $true
"ftp url: $ftp"
$webclient = New-Object System.Net.WebClient
$uri = New-Object System.Uri($ftp)
"Downloading $File..."
$webclient.DownloadFile($uri, $File)
Please find attached screenshot after copying file using PowerShell script (not in proper alignment).
Please find attached screenshot after copying file using FTP manually (proper alignment).
Am getting this alignment issue due to the cross-platform. Am copying file from HP-UX to Windows. Not sure, how to solve this problem.
While am copying file via FTP manually (commandline) its transfer mode is ASCII. But am not sure how to set transfer mode for ASCII in my powershell script.