I am trying to automate the download and installation of a large application that is several hundreds of MB to a few GB in size. I am looking into using BITS and powershell to asynchronously download the application and then launch the setup.
Using the deprecated bitsadmin
command there is a /SETNOTIFYCMDLINE
option that would allow me to chain the execution of the setup once the download completes. How can I perform this with powershell?
This will be my first powershell script, so if you have any links to examples that would be great. Thanks
I would suggest using the BitsTransfer module as it exposes native PowerShell methods for working with BITS jobs. To get started, you simply instruct PowerShell to load the BITS module:
Running Get-Command to see what new BITS cmdlets have been added shows:
The one you will most likely be interested in would be Start-BitsTransfer:
The cmdlet will show a progress bar on the screen and wait for the download to finish - the next command in your script won't execute until the download has finished.
For async tasks, you can add the
-Asynchronous
parameter to the Start-BitsTransfer cmdlet, which will queue up the download and let it run in the background. You can manage those downloads with the Get-BitsTransfer and Complete-BitsTransfer cmdlets.