Sometimes it would be nice to be able to download some files from the internet or intranet during deployments. Maybe to get some updated tools like bginfo.exe or store some configuration or wizard files outside of your boot image etc.
This is quite easy to achieve for files that are located on a network share, as MDT has some built-in support for this since quite some time already and I’ve recently blogged about the available functions for File-handling (see Extending the MDT Documentation - Some goodies from ZTIUtility.vbs – String and File handling for more information). There are also a couple scripts available, that can do this for you and take away the need to script this yourself. One sample would be the ZTICustomConfiguration script, that I published recently.
However all of them only cover typical file/folder operations on the same computer or from a network share. None of them support you to download something via http or ftp from the internet. But with MDT 2012 it finally also got some (basic) support for this scenario as well.
In the Utility class, which is globally available using “oUtility”, you can find a new function called “InternetFileDownload”. This function takes two parameters. First is the path to the file to download (e.g. “http://live.sysinternals.com/Bginfo.exe”) and the path to the target location, where the file shall be placed. Just be aware, that it requires the full path including the filename. So to download the mentioned BGInfo and store them e.g. in the temp directory locally on the computer you can call the following line within one of your scripts:
oUtility.InternetFileDownload "http://live.sysinternals.com/Bginfo.exe", "%TEMP%\Bginfo.exe"
As this is just some basic implementation, it’s a bit limited. It doesn’t support username and password, like the web service calls do. It requires you to specify the path and filename for the target, so it doesn’t re-use the original file name from the download if only the folder is specified. There is not much error handling, so if something fails, it will just tell you that it failed, but not really why. And finally, you have to implement this function in your own script.
For your convenience, I’ve published a simple wrapper file to CodePlex (Download ZTIDownloadInternetFile.wsf) that will allow you to call this function from within your task sequence. It takes the same parameters as described above. It will also have the same limitations as described, as I didn’t wanted to rewrite this core function, just give you easier access to it. But I’m pretty sure, that the MDT team will continue to work on this functionality and give us some more features.
So to download the same file as shown above, you could now simply add a new “Run Command Line” step to your Task Sequence (after you dropped the ZTIDownloadInternetFile.wsf script in your MDT Scripts folder) that executes the following command:
cscript.exe "%ScriptRoot%\ZTIDownloadInternetFile.wsf" "http://live.sysinternals.com/Bginfo.exe" "%Temp%\Bginfo.exe"
It doesn’t really support more complex scenarios, but works quite well to quickly get one or a few files from the internet or a local web server.