Private/Drivers/Get-HPModelPack.txt

<#
.SYNOPSIS
Returns a PowerShell Object of the Dell Model Packs
 
.DESCRIPTION
Returns a PowerShell Object of the Dell Model Packs by parsing the Dell Driver Pack Catalog from http://downloads.dell.com/catalog/DriverPackCatalog.cab"
 
.PARAMETER DownloadPath
Directory containing the downloaded Dell Model Packs. This allows the function to validate if the Driver Pack was downloaded by updating OSDStatus
 
.LINK
https://osddrivers.osdeploy.com/functions/get-dellmodelpack
#>
function Get-HPModelPack {
    [CmdletBinding()]
    Param (
        [string]$DownloadPath
    )
    #===================================================================================================
    # DownloadPath
    #===================================================================================================
    if (-not($DownloadPath)) {$DownloadPath = $env:TEMP}
    Write-Verbose "DownloadPath: $DownloadPath"
    #===================================================================================================
    # Dell Variables
    #===================================================================================================
    # Define Dell Download Sources
    $HpDownloadsListUrl = "http://downloads.dell.com/published/Pages/index.html"
    $HpDownloadsBaseUrl = "http://downloads.dell.com"
    $HpDriverListUrl = "http://en.community.dell.com/techcenter/enterprise-client/w/wiki/2065.dell-command-deploy-driver-packs-for-enterprise-client-os-deployment"
    $HpCommunityUrl = "http://en.community.dell.com"
    $Hp64BiosUtilityUtl = "http://en.community.dell.com/techcenter/enterprise-client/w/wiki/12237.64-bit-bios-installation-utility"
     
    # Define Dell Download Sources
    $DriverPackCatalog = "https://ftp.hp.com/pub/caps-softpaq/cmit/HPClientDriverPackCatalog.cab"
    $HpCatalogPcUrl = "http://downloads.dell.com/catalog/CatalogPC.cab"
     
    # Define Dell Cabinet/XL Names and Paths
    $HpCabFile = [string]($DriverPackCatalog | Split-Path -Leaf)
    $HpCatalogFile = [string]($HpCatalogPcUrl | Split-Path -Leaf)
    #===================================================================================================
    # DriverPackCatalog
    #===================================================================================================
    if (-not(Test-Path "$DownloadPath")) {New-Item "$DownloadPath" -ItemType Directory -Force | Out-Null}
    (New-Object System.Net.WebClient).DownloadFile($DriverPackCatalog, "$DownloadPath\DriverPackCatalog.cab")
 
    Expand "$DownloadPath\DriverPackCatalog.cab" "$DownloadPath\DriverPackCatalog.xml" | Out-Null
 
    if (Test-Path "$DownloadPath\DriverPackCatalog.cab") {
        Remove-Item -Path "$DownloadPath\DriverPackCatalog.cab" -Force | Out-Null
    }
 
    [xml]$DriverPackageCatalog = Get-Content "$DownloadPath\DriverPackCatalog.xml" -ErrorAction Stop
    $HpDriverPackCatalog = $DriverPackageCatalog.NewDataSet.HPClientDriverPackCatalog.SoftPaqList.SoftPaq
    #===================================================================================================
    # ForEach
    #===================================================================================================
    $ErrorActionPreference = 'SilentlyContinue'
    $DriverResults = @()
    $DriverResults = foreach ($DriverPackage in $HpDriverPackCatalog) {
        #===================================================================================================
        # Skip
        #===================================================================================================
        if ($DriverPackage.Name -match 'IOT') {Continue}
        #===================================================================================================
        # Defaults
        #===================================================================================================
        $OSDVersion = $(Get-Module -Name OSDDrivers | Sort-Object Version | Select-Object Version -Last 1).Version
        $LastUpdate = [datetime] $DriverPackage.DateReleased
        $OSDStatus = $null
        $OSDType = 'ModelPack'
        $OSDGroup = 'HPModel'
 
        $DriverName = $null
        $DriverVersion = $DriverPackage.Version.Trim()
        $DriverReleaseId = $null
        $DriverGrouping = $null
 
        $OperatingSystem = @()
        $OsVersion = $null
        $OsArch = $null
        $OsBuildMax = @()
        $OsBuildMin = @()
 
        $Make = 'HP'
        $MakeNe = @()
        $MakeLike = @()
        $MakeNotLike = @()
        $MakeMatch = @()
        $MakeNotMatch = @()
 
        $Generation = $null
        $SystemFamily = $null
 
        $Model = $null
        $ModelNe = @()
        $ModelLike = @()
        $ModelNotLike = @()
        $ModelMatch = @()
        $ModelNotMatch = @()
 
        $SystemSku = @()
        $SystemSkuNe = @()
 
        $SystemBaseband = $null
        $SystemBasebandNe = $null
 
        $DriverBundle = $null
        $DriverWeight = 100
 
        $DownloadFile = $DriverPackage.Url | Split-Path -Leaf
        $SizeMB = ($DriverPackage.Size.Trim() | Select-Object -Unique) / 1024
        $DriverUrl = $DriverPackage.Url
        $DriverInfo = $DriverPackage.CvaFileUrl
        $DriverDescription = $DriverPackage.ReleaseNotesUrl
        $Hash = $DriverPackage.MD5.Trim()
        $OSDGuid = $(New-Guid)
        #===================================================================================================
        # Get Values
        #===================================================================================================
        if ($DriverPackage.Name -match 'x64') {$OsArch = 'x64'}
        if ($DriverPackage.Name -match 'x86') {$OsArch = 'x86'}
        if ($null -eq $OsArch) {$OsArch = 'x64'}
        if ($DriverPackage.Name -match 'Win7') {$OsVersion = '6.1'}
        if ($DriverPackage.Name -match 'Win 7') {$OsVersion = '6.1'}
        if ($DriverPackage.Name -match 'Window 7') {$OsVersion = '6.1'}
        if ($DriverPackage.Name -match 'Windows 7') {$OsVersion = '6.1'}
        if ($DriverPackage.Name -match 'Win8') {$OsVersion = '6.3'}
        if ($DriverPackage.Name -match 'Win 8') {$OsVersion = '6.3'}
        if ($DriverPackage.Name -match 'Windows 8') {$OsVersion = '6.3'}
        if ($DriverPackage.Name -match 'Win10') {$OsVersion = '10.0'}
        if ($DriverPackage.Name -match 'Win 10') {$OsVersion = '10.0'}
        if ($DriverPackage.Name -match 'Windows 10') {$OsVersion = '10.0'}
 
 
        $DriverReleaseId = $DriverPackage.Name.Trim()
        $DriverType = $DriverPackage.type.Trim()
        $VendorVersion = $DriverPackage.vendorVersion.Trim()
        $OperatingSystem = $DriverPackage.SupportedOperatingSystems.OperatingSystem.Display.'#cdata-section'.Trim() | Select-Object -Unique
        $OsArch = $DriverPackage.SupportedOperatingSystems.OperatingSystem.osArch.Trim() | Select-Object -Unique
        $OsCode = $DriverPackage.SupportedOperatingSystems.OperatingSystem.osCode.Trim() | Select-Object -Unique
        $OsType = $DriverPackage.SupportedOperatingSystems.OperatingSystem.osType.Trim() | Select-Object -Unique
        $OsVendor = $DriverPackage.SupportedOperatingSystems.OperatingSystem.osVendor.Trim() | Select-Object -Unique
        $OsMajor = $DriverPackage.SupportedOperatingSystems.OperatingSystem.majorVersion.Trim() | Select-Object -Unique
        $OsMinor = $DriverPackage.SupportedOperatingSystems.OperatingSystem.minorVersion.Trim() | Select-Object -Unique
        $ModelBrand = $DriverPackage.SupportedSystems.Brand.Display.'#cdata-section'.Trim() | Select-Object -Unique
        $ModelBrandKey = $DriverPackage.SupportedSystems.Brand.Key.Trim() | Select-Object -Unique
        $ModelId = $DriverPackage.SupportedSystems.Brand.Model.Display.'#cdata-section'.Trim() | Select-Object -Unique
        $Generation = $DriverPackage.SupportedSystems.Brand.Model.Generation.Trim() | Select-Object -Unique
        $Model = $DriverPackage.SupportedSystems.Brand.Model.Name.Trim() | Select-Object -Unique
        $ModelRtsDate = [datetime] $($DriverPackage.SupportedSystems.Brand.Model.rtsdate.Trim() | Select-Object -Unique)
        $SystemSku = $DriverPackage.SupportedSystems.Brand.Model.systemID.Trim() | Select-Object -Unique
        $ModelPrefix = $DriverPackage.SupportedSystems.Brand.Prefix.Trim() | Select-Object -Unique
        #===================================================================================================
        # DriverFamily
        #===================================================================================================
        if ($ModelPrefix -Contains 'IOT') {
            $SystemFamily = 'IOT'
            $IsDesktop = $true
        }
        if ($ModelPrefix -Contains 'LAT') {
            $SystemFamily = 'Latitude'
            $IsLaptop = $true
        }
        if ($ModelPrefix -Contains 'OP') {
            $SystemFamily = 'Optiplex'
            $IsDesktop = $true
        }
        if ($ModelPrefix -Contains 'PRE') {$SystemFamily = 'Precision'}
        if ($ModelPrefix -Contains 'TABLET') {
            $SystemFamily = 'Tablet'
            $IsLaptop = $true
        }
        if ($ModelPrefix -Contains 'XPSNOTEBOOK') {
            $SystemFamily = 'XPS'
            $IsLaptop = $true
        }
        #===================================================================================================
        # Corrections
        #===================================================================================================
        #===================================================================================================
        # Customizations
        #===================================================================================================
        if ($OsCode -eq 'XP') {Continue}
        if ($OsCode -eq 'Vista') {Continue}
        #if ($OsCode -eq 'Windows8') {Continue}
        #if ($OsCode -eq 'Windows8.1') {Continue}
        if ($OsCode -match 'WinPE') {Continue}
        #$OsVersion = "$($OsMajor).$($OsMinor)"
        $DriverName = "$OSDGroup $DriverReleaseId $DriverVersion"
        $DriverGrouping = "$Generation $Model $OsVersion"
        if (Test-Path "$DownloadPath\$DownloadFile") {
            $OSDStatus = 'Downloaded'
        }
        #===================================================================================================
        # Create Object
        #===================================================================================================
        $ObjectProperties = @{
            OSDVersion = [string]$OSDVersion
            LastUpdate = [datetime] $LastUpdate
            OSDStatus = $OSDStatus
            OSDType = $OSDType
            OSDGroup = $OSDGroup
 
            DriverName = $DriverName
            DriverVersion = $DriverVersion
            DriverReleaseId = $DriverReleaseID
 
            OperatingSystem = $OperatingSystem
            OsVersion = $OsVersion
            OsArch = $OsArch
            OsBuildMax = $OsBuildMax
            OsBuildMin = $OsBuildMin
 
            Make = $Make
            MakeNe = $MakeNe
            MakeLike = $MakeLike
            MakeNotLike = $MakeNotLike
            MakeMatch = $MakeMatch
            MakeNotMatch = $MakeNotMatch
 
            Generation = $Generation
            SystemFamily = $SystemFamily
 
            Model = $Model
            ModelNe = $ModelNe
            ModelLike = $ModelLike
            ModelNotLike = $ModelNotLike
            ModelMatch = $ModelMatch
            ModelNotMatch = $ModelNotMatch
 
            SystemSku = $SystemSku
            SystemSkuNe = $SystemSkuNe
 
            DriverGrouping = $DriverGrouping
            DriverBundle = $DriverBundle
            DriverWeight = [int] $DriverWeight
 
            DownloadFile = $DownloadFile
            SizeMB = [int] $SizeMB
            DriverUrl = $DriverUrl
            DriverInfo = $DriverInfo
            DriverDescription = $DriverDescription
            Hash = $Hash
            OSDGuid = $OSDGuid
        }
        New-Object -TypeName PSObject -Property $ObjectProperties
    }
    #===================================================================================================
    # Select-Object
    #===================================================================================================
    $DriverResults = $DriverResults | Select-Object OSDVersion, LastUpdate,`
    OSDStatus, OSDType, OSDGroup,`
    DriverName, DriverVersion, DriverReleaseId,`
    OsVersion, OsArch,` #OperatingSystem
    Generation,`
    Make,` #MakeNe, MakeLike, MakeNotLike
    SystemFamily,`
    Model,` #ModelNe, ModelLike, ModelNotLike, ModelMatch, ModelNotMatch
    SystemSku,` #SystemSkuNe
    DriverGrouping,`
    DownloadFile, SizeMB, DriverUrl, DriverInfo, DriverDescription,
    Hash, OSDGuid
    #===================================================================================================
    # Sort Object
    #===================================================================================================
    $DriverResults = $DriverResults | Sort-Object LastUpdate -Descending
    #===================================================================================================
    # Return
    #===================================================================================================
    Return $DriverResults
    #===================================================================================================
}