It looks like there is no return or confirmation from DownloadFile. You will have to use DownloadFileAsync and watch for the DownloadFileCompleted event to fire.
Here is a post giving some examples of how to implement system.net.webclient with powershell: http://stackoverflow.com/questions/4926060/powershell-runspace-problem-with-downloadfileasync hope that helps! Matt From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On Behalf Of Orlebeck, Geoffrey Sent: Friday, May 30, 2014 10:35 AM To: powershell@lists.myITforum.com Subject: [powershell] Logging Question Hello Group I'm pretty new to PowerShell, and while I have figured out logging in most situations, I'm trying to log a web download success/failure when using "New-Object System.Net.WebClient DownloadFile". Is this possible? I've been able to get output files created, but they are always blank. Like I said, I'm pretty new to PowerShell so just a little help would be greatly appreciated. I'm attempting to download multiple files, but the gist of the script looks like this: --------------------------------- $file1 = "URL" $dir1 = "\\Share\Folder<file:///\\Share\Folder>" $file2 = "URL2" $dir2 = "\\Share\Folder2<file:///\\Share\Folder2>" $wc = New-Object System.Net.WebClient $wc.DownloadFile($file1, $dir1) $wc.DownloadFile($file2, $dir2) -------------------------------- I wasn't sure if it has to do with using objects on the command (don't think that makes a difference). I've tried out-file, start-transcript, verbose in various attempts but each command has resulted in the same blank text file. Just wondering if there is a better way. The goal is to get basic "file downloaded success" and the path it downloaded to, just so we can confirm if/when review is necessary. The script works to grab the files and place them in the appropriate folders, just want log output so other people can see it, too. Thanks. -Geoff Confidentiality Notice: This is a transmission from Community Hospital of the Monterey Peninsula. This message and any attached documents may be confidential and contain information protected by state and federal medical privacy statutes. They are intended only for the use of the addressee. If you are not the intended recipient, any disclosure, copying, or distribution of this information is strictly prohibited. If you received this transmission in error, please accept our apologies and notify the sender. Thank you. ================================================ Did you know you can also post and find answers on PowerShell in the forums? http://www.myitforum.com/forums/default.asp?catApp=1 ********************************************************** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues ================================================ Did you know you can also post and find answers on PowerShell in the forums? http://www.myitforum.com/forums/default.asp?catApp=1