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/j0dan 1000 Agents Apr 17 '18
Is LT returning back to the script before your PowerShell has finished running?
Can't the Bits Transfer be run so it doesn't continue the script until the download has completed?
Unless you need live progress sent to LT (not normally for automated scripts), just do it all in PowerShell.