Last active
April 27, 2016 13:46
-
-
Save rchaganti/d241d21f4e2ea20a684813951394c909 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| param ( | |
| [Parameter()] | |
| [ValidateSet('VMM','OM','DPM','SCORH','SM','All')] | |
| [String] $Component = 'All', | |
| [Parameter()] | |
| [String] $Destination = $env:TEMP | |
| ) | |
| Begin { | |
| $vmmBaseUrl = 'https://download.microsoft.com/download/9/5/2/952FEBE7-114D-49E6-965A-4BEBE09CA414' | |
| $omBaseUrl = 'https://download.microsoft.com/download/3/0/B/30BF5312-835F-4E92-8235-DEBE3560953F' | |
| $scorhBaseUrl = 'https://download.microsoft.com/download/B/A/B/BAB3BB0D-D6E2-4A7F-B1B3-898DA726121F' | |
| $dpmBaseUrl = 'https://download.microsoft.com/download/7/7/8/7789ACFE-F6A5-49DA-BF0B-DF4D7EE7C50B' | |
| $smBaseUrl = 'https://download.microsoft.com/download/2/5/4/25444F19-EF47-4AD2-AD97-91A6D40FC6F4' | |
| $vmmFiles = @( | |
| 'SCTP5_SCVMM_VHD.exe','SCTP5_SCVMM_VHD-1.bin','SCTP5_SCVMM_VHD-2.bin', | |
| 'SCTP5_SCVMM_VHD-3.bin','SCTP5_SCVMM_VHD-4.bin','SCTP5_SCVMM_VHD-5.bin', | |
| 'SCTP5_SCVMM_VHD-6.bin','SCTP5_SCVMM_VHD-7.bin','SCTP5_SCVMM_VHD-8.bin', | |
| 'SCTP5_SCVMM_VHD-9.bin','SCTP5_SCVMM_VHD-10.bin','SCTP5_SCVMM_VHD-11.bin', | |
| 'SCTP5_SCVMM_VHD-12.bin','SCTP5_SCVMM_VHD-13.bin','SCTP5_SCVMM_VHD-14.bin', | |
| 'SCTP5_SCVMM_VHD-15.bin','SCTP5_SCVMM_VHD-16.bin','SCTP5_SCVMM_VHD-17.bin', | |
| 'SCTP5_SCVMM_VHD-18.bin' | |
| ) | |
| $omFiles = @( | |
| 'SCTP5_SCOM_VHD.exe','SCTP5_SCOM_VHD-1.bin','SCTP5_SCOM_VHD-2.bin', | |
| 'SCTP5_SCOM_VHD-3.bin','SCTP5_SCOM_VHD-4.bin','SCTP5_SCOM_VHD-5.bin', | |
| 'SCTP5_SCOM_VHD-6.bin','SCTP5_SCOM_VHD-7.bin','SCTP5_SCOM_VHD-8.bin', | |
| 'SCTP5_SCOM_VHD-9.bin','SCTP5_SCOM_VHD-10.bin','SCTP5_SCOM_VHD-11.bin', | |
| 'SCTP5_SCOM_VHD-12.bin','SCTP5_SCOM_VHD-13.bin','SCTP5_SCOM_VHD-14.bin' | |
| ) | |
| $scorhFiles = @( | |
| 'SCTP5_SCO_VHD.exe','SCTP5_SCO_VHD-1.bin','SCTP5_SCO_VHD-2.bin', | |
| 'SCTP5_SCO_VHD-3.bin','SCTP5_SCO_VHD-4.bin','SCTP5_SCO_VHD-5.bin', | |
| 'SCTP5_SCO_VHD-6.bin','SCTP5_SCO_VHD-7.bin','SCTP5_SCO_VHD-8.bin', | |
| 'SCTP5_SCO_VHD-9.bin','SCTP5_SCO_VHD-10.bin','SCTP5_SCO_VHD-11.bin', | |
| 'SCTP5_SCO_VHD-12.bin' | |
| ) | |
| $dpmFiles = @( | |
| 'SCTP5_SCDPM_VHD.exe','SCTP5_SCDPM_VHD-1.bin','SCTP5_SCDPM_VHD-2.bin', | |
| 'SCTP5_SCDPM_VHD-3.bin','SCTP5_SCDPM_VHD-4.bin','SCTP5_SCDPM_VHD-5.bin', | |
| 'SCTP5_SCDPM_VHD-6.bin','SCTP5_SCDPM_VHD-7.bin','SCTP5_SCDPM_VHD-8.bin', | |
| 'SCTP5_SCDPM_VHD-9.bin','SCTP5_SCDPM_VHD-10.bin','SCTP5_SCDPM_VHD-11.bin', | |
| 'SCTP5_SCDPM_VHD-12.bin','SCTP5_SCDPM_VHD-13.bin','SCTP5_SCDPM_VHD-14.bin', | |
| 'SCTP5_SCDPM_VHD-15.bin','SCTP5_SCDPM_VHD-16.bin' | |
| ) | |
| $smFiles = @( | |
| 'SCTP5_SCSM_VHD.exe','SCTP5_SCSM_VHD-1.bin','SCTP5_SCSM_VHD-2.bin', | |
| 'SCTP5_SCSM_VHD-4.bin','SCTP5_SCSM_VHD-5.bin','SCTP5_SCSM_VHD-6.bin', | |
| 'SCTP5_SCSM_VHD-7.bin','SCTP5_SCSM_VHD-8.bin','SCTP5_SCSM_VHD-9.bin', | |
| 'SCTP5_SCSM_VHD-10.bin','SCTP5_SCSM_VHD-11.bin','SCTP5_SCSM_VHD-12.bin' | |
| ) | |
| } | |
| Process | |
| { | |
| Switch ($Component) | |
| { | |
| 'VMM' { | |
| $jobs = $vmmFiles | ForEach-Object { Start-BitsTransfer -Source "${vmmBaseUrl}/$_" -Destination D:\TP5 -Asynchronous } | |
| } | |
| 'OM' { | |
| $jobs = $omFiles | ForEach-Object { Start-BitsTransfer -Source "${omBaseUrl}/$_" -Destination $Destination -Asynchronous } | |
| } | |
| 'SCO' { | |
| $jobs = $scorhFiles | ForEach-Object { Start-BitsTransfer -Source "${scorhBaseUrl}/$_" -Destination $Destination -Asynchronous } | |
| } | |
| 'DPM' { | |
| $jobs = $dpmFiles | ForEach-Object { Start-BitsTransfer -Source "${dpmBaseUrl}/$_" -Destination $Destination -Asynchronous } | |
| } | |
| 'SM' { | |
| $jobs = $smFiles | ForEach-Object { Start-BitsTransfer -Source "${smBaseUrl}/$_" -Destination $Destination -Asynchronous } | |
| } | |
| 'All' { | |
| $url = ($vmmFiles | ForEach-Object { "${vmmBaseUrl}/$_" }) + | |
| ($omFiles | ForEach-Object { "${omBaseUrl}/$_" }) + | |
| ($scorhFiles | ForEach-Object { "${scorhBaseUrl}/$_" }) + | |
| ($dpmFiles | ForEach-Object { "${dpmBaseUrl}/$_" }) + | |
| ($smFiles | ForEach-Object { "${smBaseUrl}/$_" }) | |
| $jobs = $url | ForEach-Object { Start-BitsTransfer -Source $_ -Destination $Destination -Asynchronous -Verbose } | |
| } | |
| } | |
| Write-Host 'Waiting for downloads to complete ...' | |
| While ($jobs.JobState -eq 'Transferring') | |
| { | |
| foreach ($job in $jobs){ | |
| if ($job.JobState -eq 'Transferred') | |
| { | |
| Complete-BitsTransfer -BitsJob $job | |
| } | |
| elseif ($job.JobState -eq 'Failed') | |
| { | |
| Write-Error -Message $job.InternalErrorCode | |
| Remove-BitsTransfer -BitsJob $job | |
| } | |
| } | |
| Start-Sleep -Seconds 10 | |
| } | |
| #just in case something is left | |
| Get-BitsTransfer | Complete-BitsTransfer | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment