Public/Get-DownDellDriverPack.ps1
<#
.SYNOPSIS Downloads Dell Driver Packs .DESCRIPTION Downloads Dell Driver Packs Requires BITS for downloading the Downloads Requires Internet access for downloading the Downloads .LINK https://delldriverpack.osdeploy.com/functions/get-downdelldriverpack .PARAMETER InputObject Paired with Get-DellFamilyPack or Get-DellModelPack (future) Get-DellFamilyPack | Get-DownDellDriverPack -DownloadPath C:\Temp .PARAMETER DownloadPath Directory to save the downloaded Driver Packs .PARAMETER PackLOB Dell Pack Line of Business (LOB) of the Driver Pack .PARAMETER DriverOS Supported Operating System of the Driver Pack #> function Get-DownDellDriverPack { [CmdletBinding()] Param ( [Parameter(ValueFromPipeline = $true)] [Object[]]$InputObject, [Parameter(Mandatory = $true)] [string]$DownloadPath, [ValidateSet ('Latitude','OptiPlex','Precision','Venue','Vostro','XPS')] [string]$PackLOB, [ValidateSet ('Win10','Win8.1','Win7')] [string]$DriverOS #[switch]$GridView, #[switch]$ShowSuperseded ) Begin { #=================================================================================================== # DownloadPath #=================================================================================================== if (-not(Test-Path "$DownloadPath")) { try {New-Item -Path "$DownloadPath" -ItemType Directory -Force -ErrorAction Stop | Out-Null} catch {Write-Error "Could not create the DownloadPath at $DownloadPath" -ErrorAction Stop} } #=================================================================================================== } Process { #=================================================================================================== # Get-DriverPackDownloads #=================================================================================================== $DriverPackDownloads = @() if ($InputObject) { $GridView = $false $DriverPackDownloads = $InputObject } else { $GridView = $true $DriverPackDownloads = Get-DellFamilyPack } #=================================================================================================== # ShowSuperseded #=================================================================================================== if ($ShowSuperseded.IsPresent) { #Do Nothing } else { $DriverPackDownloads = $DriverPackDownloads | Where-Object {$_.Superseded -eq $false} } #=================================================================================================== # DriverOS #=================================================================================================== if ($PackLOB) {$DriverPackDownloads = $DriverPackDownloads | Where-Object {$_.PackLOB -eq "$PackLOB"}} #=================================================================================================== # DriverOS #=================================================================================================== if ($DriverOS) {$DriverPackDownloads = $DriverPackDownloads | Where-Object {$_.DriverOS -eq "$DriverOS"}} #=================================================================================================== # Get Downloaded Files #=================================================================================================== foreach ($Download in $DriverPackDownloads) { $FullDownloadPath = "$DownloadPath\$($Download.DownloadFileName)" if (Test-Path $FullDownloadPath) { Rename-Item -Path $FullDownloadPath -NewName "$($Download.DownloadFileName)" $Download.DriverStatus = 'Downloaded' } } #=================================================================================================== # GridView #=================================================================================================== $DriverPackDownloads = $DriverPackDownloads | Sort-Object LastUpdate -Descending if ($GridView) {$DriverPackDownloads = $DriverPackDownloads | Out-GridView -PassThru -Title "Select Downloads"} #=================================================================================================== # Download #=================================================================================================== $DriverPackDownloads = $DriverPackDownloads | Where-Object {$_.DriverStatus -ne 'Downloaded'} foreach ($Download in $DriverPackDownloads) { $DownloadSource = $Download.DriverUrl $DownloadFile = $Download.DownloadFileName $FullDownloadPath = "$DownloadPath\$DownloadFile" Write-Host "$FullDownloadPath" -ForegroundColor Cyan Write-Host "$($Download.DriverUrl)" -ForegroundColor Gray Start-BitsTransfer -Source $DownloadSource -Destination $FullDownloadPath } } End {} } |