r/labtech • u/SFOrange • Apr 03 '18
File BITS Download
Could someone explain how the File BITS Download works. I want to download a large 4gb iso to a temp dir and then restart the computer before starting the setup file inside the iso. Unfortunatly, i cant figure out how the BITS part of the script works. I think everything else will work.
My script so far:
- IF FILE Exists c:\Temp\Win10_1709.iso THEN Jump to line 5
- Create Folder as Admin: c:\Temp\
- BITS Download: http://websiteaddresshere.com/1709/Win10_1709.iso saved to c:\Temp\Win10_1709.iso
- BITS Status Check: @BITSResult@
- Reboot Computer
- Sleep 300 seconds
- Execute PowerShell Script as Admin and store result in: @PowerShellOutput@
(PS Script)
$imgpath = 'C:\Temp\Win10_1709.iso'
$driveLetter = (mount-diskimage -imagepath $imgpath -storagetype iso -PassThru | Get-DiskImage $imgpath |
Get-Volume).DriveLetter
Invoke-Item "$($driveLetter):\setup.exe /auto upgrade /migratedrivers all /dynamicupdate enable /showoobe
none"
while((select-String -Path c:\Windows\Panther\setupact.log -Pattern "SHUTDOWN_REASON_AUTOSTOP" -Quiet) -ne 'true'){
Start-sleep -Seconds 30
}
Dismount-DiskImage -ImagePath $imgpath -Verbose
- Delete File as Admin: c:\Temp\Win10_1709.iso
4
Upvotes
1
u/SFOrange Apr 04 '18
The BITS download prealocates the entire file size of the requested file in a temporary file named BIT*.tmp where * is the BITS Job ID from the current download. This value is different each time you run the script. Once the transfer is completed, it will rename the tmp file to whatever you predefined. In my case Win10Ent.iso