Tuesday 15 June 2010

powershell - Trying to download a file to a directory on a remote server -


I am getting this error

Call "DownloadFile" with "2" argument Exception to S): "An exception occurred during a web client request."

From this script

  $ username = "administrator" $ password = "password" $ Secstr = New object-type name system. Security. Sequestring $ password Kocharayre () | For the e-object ($ secstr.AppendChar ($ _)} $ cred = new-object -typename system.management.pscdential -streamentlist $ username, $ secstr $ url = "http://www.website.com / File .zip "$ path =" c: \ file.zip "$ client = new-object System.Net.WebClient $ client.DownloadFile ($ url, $ path) Invoke-Command -ComputerName 69.69.69.69 -ScriptBlock {$ Client} is running on Windows Web Server 2008  

The script purpose is to download file.zip to a remote server (there are hundreds of servers so I '

any thoughts?

Try it $ username = "administrator" $ password = "PASSWORD" $ secstr = New object - Type name system. Secstr.AppendChar ($ _)} $ cred = new-object -typename system.management.pscdnsial -remnentList $ username, $ secstr $ command = {$ url = "http://www.website.com / file. Zip "$ path =" c: \ file.zip "$ client = new-object System.Net.WebClient $ client.DownloadFile ($ url, $ path)} Ask-command-computer name 69.69.69.69 - Scriptblocks $ order - Credential $ cred

No comments:

Post a Comment