$webclient.DownloadFile($uri,$targ et) return (550) File unavailable

This code works fine on my desktop but I get following exception on windows server 2008 R2...I am able to open this file using IE on the server. So it not permission issue and i am getting directory listing too. I can browse to absoluteuri I get in $uri with same credentials. Any idea?

Thank you for all the help.

Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)."

At C:\Users\Test\Desktop\PowerShell\Test.ps1

+         $webclient.DownloadFile($uri,$target)

+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : WebException 

Powershell Code:

Import-Module PSFTP $ftp = "ftp://testftpsite/" $user = 'username' $pass = ConvertTo-SecureString String "password" AsPlainText -Force $Credentials =New-Object TypeName System.Management.Automation.PSCredential ArgumentList $user, $pass Set-FTPConnection -Credentials $Credentials -Server $ftp -session 'MySession' -UsePassive $Session = Get-FTPConnection -Session MySession $Dirtest =Get-FTPChildItem -Session $Session -Path /CCTransfer -Recurse -Depth 2 $target = " test.txt" $webclient = New-Object System.Net.WebClient $webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass) $item = "TestFile.txt" $uri = New-Object System.Uri($ftp+$item) $webclient.DownloadFile($uri,$target)




  • Edited by TooKool19 16 hours 19 minutes ago
September 3rd, 2015 10:49am

Worth checking this link

https://support.microsoft.com/en-us/kb/2581719

Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2015 11:06am

I don't have any special characters or numbers in the path or file name. My desktop has Windows 7 and it works fine on the desktop.

Thanks...



  • Edited by TooKool19 13 hours 26 minutes ago
September 3rd, 2015 1:46pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics