Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save SMSAgentSoftware/a378c316d8b7f939ed7a4c27047c9c58 to your computer and use it in GitHub Desktop.
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
[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"
}
@Jake2783
Copy link

Jake2783 commented Feb 9, 2023

Hi,

Anyone can help with the error below
Model[0]: "Latitude E7470"
Model[1]:
OperatingSystem: Windows 10
DownloadDirectory: C:\Temp
Start-BitsTransfer : Cannot find path 'C:\Windows\system32<HTML>

<TITLE>Access Denied<\TITLE> <\HEAD>

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

  •         Start-BitsTransfer -Source $URL -Destination $DownloadDir ...
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (C:\Windows\syst...\BODY>
      <\HTML>
      :String) [Start-BitsTransfer], ParentContainsErrorRecordException
    • FullyQualifiedErrorId : PathNotFound,Microsoft.BackgroundIntelligentTransfer.Management.NewBitsTransferCommand

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

  •         Start-BitsTransfer -Source $URL -Destination $DownloadDir ...
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Start-BitsTransfer], COMException
    • FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.BackgroundIntelligentTransfer.Management.NewBitsTransferCommand

Tried to download the driver, but it failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment