Advertisement
Combreal

Get-LatestCab-Info.ps1

Nov 24th, 2021
1,315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. If( -Not $(Test-Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3')) {
  2.     New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3' -Name '1A10' -value '0' -PropertyType "DWORD" | Out-Null
  3. }
  4. Else {
  5.     Set-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3' -Name '1A10' -value '0' | Out-Null
  6. }
  7.  
  8. $WebResponse = Invoke-WebRequest "https://www.dell.com/support/kbdoc/fr-fr/000109893/packs-de-pilotes-dell-command-deploy-pour-mod%C3%A8les-latitude"
  9. $counter = 0
  10. $WebResponse.AllElements | Where {$_.TagName -eq "td"} | Foreach {
  11.     If ($counter -eq 0 -Or ($counter % 4) -eq 0) {
  12.         $Label = $_.innerHTML.Replace("<div>","")
  13.         $Label = $Label.Replace("</div>","")
  14.         $Label = $Label.Replace("<br>","")
  15.         $Label = $Label.Replace("&nbsp;"," ")
  16.         $Label = $Label -replace '<[^>]+>','' #remove HTML code
  17.         $Label = $Label -replace '(^\s+|\s+$)','' -replace '\s+',' ' #remove all spaces at the beginning and end of the line
  18.     }
  19.     ElseIf ($counter -eq 1 -Or ($counter % 4) -eq 1) {
  20.         $URL = $_.innerHTML
  21.         $URL = $URL -replace '<[^>]>',''
  22.         $URL = ((Select-String '(http[s]?)(:\/\/)([^\s,]+)(?=")' -Input $URL).Matches.Value)
  23.         (Invoke-WebRequest -Uri $URL).Links.Href | Sort-Object | Get-Unique | Foreach {
  24.             If ($_ -Like "*.CAB*") {
  25.                 $DirectURL = $_
  26.             }
  27.         }
  28.     }
  29.     ElseIf ($counter -eq 2 -Or ($counter % 4) -eq 2) {
  30.         $Version = $_.innerText
  31.         $Version = $Version -replace '<[^>]+>',''
  32.         $Version = $Version -replace '(^\s+|\s+$)','' -replace '\s+',' '
  33.     }
  34.     ElseIf ($counter -eq 3 -Or ($counter % 4) -eq 3) {
  35.         Write-Host $Label "  " $Version "  " $DirectURL
  36.     }
  37.     $counter++
  38. }
  39.  
  40. Remove-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3' -Name '1A10'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement