Schedule a download

Windows 7 schedule job now able to support Power Shell script which you can code in more complicated C# logic. I have a requirement want to download a source file (i.e. price list) from internet to my desktop everyday for some comparison or other purpose. It can be also download just a pure html file for reading novel episode everyday, hehe.. So, you must download the file then rename to other just in case overwrite the previous file.

//if you are behind proxy
$credentials = new-object System.Net.NetworkCredential('username','password');
$proxy = new-object System.Net.WebProxy('http://your-proxy:80');
$proxy.Credentials = $credentials;
$client = new-object System.Net.WebClient;
$client.Proxy = $proxy;
$file = 'filename'+(get-date).ToString('yyyyMMdd')+'.pdf';
ren 'G:\desktop\filename.pdf' $file

**join all lines into one line as the parameter input in schedule screen, and caution, the single line not recognize double quote, please use single quote in all your string input**


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s