Created
April 25, 2017 16:04
-
-
Save SMSAgentSoftware/a378c316d8b7f939ed7a4c27047c9c58 to your computer and use it in GitHub Desktop.
Downloads the latest driver pack from Dell for any model or models you specify
This file contains 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
[CmdletBinding()] | |
Param | |
( | |
[Parameter(Mandatory=$true, | |
ValueFromPipelineByPropertyName=$true, | |
ValueFromPipeline=$true, | |
Position=0)] | |
[String[]]$Model, | |
[Parameter(Mandatory=$true, | |
Position=1)] | |
[ValidateSet("Windows 10","Windows 8.1","Windows 8","Windows 7")] | |
$OperatingSystem, | |
[Parameter(Mandatory=$true, | |
Position=2)] | |
[String]$DownloadDirectory | |
) | |
Begin | |
{ | |
function Get-LatestDellDriverPackURL { | |
[CmdletBinding()] | |
Param | |
( | |
[Parameter(Mandatory=$true, | |
ValueFromPipelineByPropertyName=$true, | |
Position=0)] | |
[String]$Model, | |
[Parameter(Mandatory=$true, | |
ValueFromPipelineByPropertyName=$true, | |
Position=1)] | |
[ValidateSet("Windows 10","Windows 8.1","Windows 8","Windows 7")] | |
$OperatingSystem | |
) | |
# Remove the "E" prefix character from Latitude models due to some dodgy Dell URLs... | |
If ($Model.ToCharArray()[0] -eq "E" -and $Model -notmatch "Embedded") | |
{ | |
$Model = $Model.Replace("E","") | |
} | |
# Find the specific wiki page for the model from the main wiki page | |
$URI = "http://en.community.dell.com/techcenter/enterprise-client/w/wiki/2065.dell-command-deploy-driver-packs-for-enterprise-client-os-deployment" | |
Try | |
{ | |
$HTML = Invoke-WebRequest -Uri $URI -ErrorAction Stop | |
If ($OperatingSystem -eq "Windows 8") | |
{ | |
# Filter out Windows 8.1 from the results if it's just Windows 8 | |
$Href = $HTML.AllElements | Where {$_.innerText -match ("$Model" + " W") -and $_.innerText -match $OperatingSystem -and $_.innerText -notmatch "8.1" -and $_.innerText -match "Driver" -and $_.tagName -eq "A"} | Select -ExpandProperty href | |
} | |
Else | |
{ | |
$Href = $HTML.AllElements | Where {$_.innerText -match ("$Model" + " W") -and $_.innerText -match $OperatingSystem -and $_.innerText -match "Driver" -and $_.tagName -eq "A"} | Select -ExpandProperty href | |
} | |
} | |
Catch | |
{ | |
$_ | |
Return | |
} | |
If (!$Href) | |
{ | |
Write-Error "No Wiki page found for $Model and $OperatingSystem." | |
Return | |
} | |
# Find the download URL from the model | |
$URI = "http://en.community.dell.com/$Href" | |
Try | |
{ | |
$HTML = Invoke-WebRequest -Uri $URI -ErrorAction Stop | |
$CabDownloadLink = $HTML.AllElements | Where {$_.innerHTML -match "Download Now" -and $_.tagName -eq "A"} | Select -ExpandProperty href | |
Return $CabDownloadLink | |
} | |
Catch | |
{ | |
$_ | |
Return | |
} | |
Write-Error "No download URL found for $Model." | |
} | |
# Start a timer | |
$Stopwatch = New-Object System.Diagnostics.Stopwatch | |
$Stopwatch.Start() | |
} | |
Process | |
{ | |
Foreach ($System in $Model) | |
{ | |
Write-Verbose "Finding the download URL for '$System' and '$OperatingSystem'" | |
Try | |
{ | |
# Get the download URL | |
$URL = Get-LatestDellDriverPackURL -Model $System -OperatingSystem $OperatingSystem -ErrorAction Stop | |
} | |
Catch | |
{ | |
$Stopwatch.Stop() | |
$_ | |
Return | |
} | |
Write-Verbose "Initiating download of URL '$URL' with BITS" | |
Try | |
{ | |
# Begin the download | |
Start-BitsTransfer -Source $URL -Destination $DownloadDirectory | |
} | |
Catch | |
{ | |
$Stopwatch.Stop() | |
$_ | |
Return | |
} | |
} | |
} | |
End | |
{ | |
$Stopwatch.Stop() | |
Write-Verbose "Completed in $($Stopwatch.Elapsed.Minutes) minutes and $($Stopwatch.Elapsed.Seconds) seconds" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Anyone can help with the error below
<TITLE>Access Denied<\TITLE> <\HEAD>Model[0]: "Latitude E7470"
Model[1]:
OperatingSystem: Windows 10
DownloadDirectory: C:\Temp
Start-BitsTransfer : Cannot find path 'C:\Windows\system32<HTML>
Access Denied<\H1>
You don't have permission to access "http://www.dell.com/support/article/SLN312414" on this server.
Reference #18.7461402.1675948037.3f0da219
<\BODY>
<\HTML>
' because it does not exist.
At line:116 char:13
<\HTML>
:String) [Start-BitsTransfer], ParentContainsErrorRecordException
Start-BitsTransfer : The operation being requested was not performed because the user has not logged on to the network. The specified service does not exist. (Exception from HRESULT: 0x800704DD)
At line:116 char:13
Tried to download the driver, but it failed.