-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathParseDellCab.ps1
46 lines (39 loc) · 1.95 KB
/
ParseDellCab.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<#
.SYNOPSIS
Download and Parse Dell Downloads from CAB V1.1 - To be used in conjunction with other code for Dell Deployment Solutions
.DESCRIPTION
Download and Parse Dell Downloads from CAB V1.1 - Created by Mark Godfrey @Geodesicz
.LINK
http://www.tekuits.com
#>
# Format Cab DL Path
$CabPath = "$PSScriptRoot\dellsdpcatalogpc.cab"
# Download Dell Cab File
Invoke-WebRequest -Uri "http://ftp.dell.com/catalog/dellsdpcatalogpc.cab" -OutFile $CabPath -Verbose
# Extract XML from Cab File
If(Test-Path "$PSScriptRoot\DellSDPCatalogPC.xml"){Remove-Item -Path "$PSScriptRoot\DellSDPCatalogPC.xml" -Force -Verbose}
<#
$shell = New-Object -Comobject shell.application
$Items = $shell.Namespace($CabPath).items()
$Extract = $shell.Namespace($PSScriptRoot)
$Extract.CopyHere($Items)
#>
Expand $CabPath "$PSScriptRoot\DellSDPCatalogPC.xml"
# Import and Create XML Object
[xml]$XML = Get-Content $PSScriptRoot\DellSDPCatalogPC.xml -Verbose
# Create Array of Downloads
$Downloads = $xml.SystemsManagementCatalog.SoftwareDistributionPackage
# Display List of Available Downloads
# $Names = $Downloads | ForEach {$PSItem.LocalizedProperties.Title}
# Find Target Download for Specific Desired Function (Example)
$Model = (Get-WmiObject win32_computersystem).Model
If(!($Model.EndsWith("AIO")) -or !($Model.EndsWith("M"))){
$Target = $Downloads | Where-Object -FilterScript {
$PSitem.LocalizedProperties.Title -match $model -and $PSitem.LocalizedProperties.Title -notmatch $model + " AIO" -and $PSitem.LocalizedProperties.Title -notmatch $model + "M"
}
}
Else{$Target = $Downloads | Where-Object -FilterScript {$PSitem.LocalizedProperties.Title -match $model}}
$TargetLink = $Target.InstallableItem.OriginFile.OriginUri
$TargetFileName = $Target.InstallableItem.OriginFile.FileName
Invoke-WebRequest -Uri $TargetLink -OutFile $PSScriptRoot\$TargetFileName -UseBasicParsing -Verbose
$TargetDownload = "$PSScriptRoot\$TargetFileName"