Invoke-WebRequest prequel alternative: System.Net.WebClient


The newest version of Powershell, 4.0, includes the Invoke-WebRequest cmdlet to retrieve data using the http protocol and its derivatives.
If you do not work for Microsoft and because of the systems you are facing to, need to be compatible with previous versions, the following one-liner can easily replace it for simple-regular downloads (GET requests)

The contents will be retrieved in a string. If you need to handle a binary file, the DownloadData method is then your friend.

Leave a comment

Your e-mail address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.