Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function GetCurrentModelVer ($Model) {
- $DriversItems = Get-ChildItem "S:\MDT-Drivers\Windows 10 x64\Dell Inc" | Where-Object {$_.PSIsContainer -eq $true} | Sort-Object
- foreach ($i in $DriversItems)
- {
- If ($i -Like $Model) {
- $Cab = (Get-ChildItem $i.FullName -filter "*.cab").Name
- If($Cab -match '-A\d\d-') {
- Return $($Matches[0].Substring(1,$Matches[0].Length-2))
- }
- }
- }
- }
- Function GetDellDrivers($CABPage) {
- If ($(Get-CimInstance Win32_Operatingsystem | Select-Object -expand Caption) -Like "*Server*") {
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" -Name "IsInstalled" -Value 0
- Stop-Process -Name Explorer -Force
- Start Explorer
- }
- If( -Not $(Test-Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3')) {
- New-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3' -Name '1A10' -value '0' -PropertyType "DWORD" | Out-Null
- }
- Else {
- Set-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3' -Name '1A10' -value '0' | Out-Null
- }
- $WebResponse = Invoke-WebRequest $CABPage #-Usebasicparsing
- $counter = 0
- $WebResponse.AllElements | Where {$_.TagName -eq "td"} | Foreach {
- If ($counter -eq 0 -Or ($counter % 4) -eq 0) {
- $Label = $_.innerHTML.Replace("<div>","")
- $Label = $Label.Replace("</div>","")
- $Label = $Label.Replace("<br>","")
- $Label = $Label.Replace(" "," ")
- $Label = $Label -replace '<[^>]+>','' #remove HTML code
- $Label = $Label -replace '(^\s+|\s+$)','' -replace '\s+',' ' #remove all spaces at the beginning and end of the line
- }
- ElseIf ($counter -eq 1 -Or ($counter % 4) -eq 1) {
- $URL = $_.innerHTML
- $URL = $URL -replace '<[^>]>',''
- $URL = ((Select-String '(http[s]?)(:\/\/)([^\s,]+)(?=")' -Input $URL).Matches.Value)
- (Invoke-WebRequest -Uri $URL).Links.Href | Sort-Object | Get-Unique | Foreach {
- If ($_ -Like "*.CAB*") {
- $DirectURL = $_
- }
- }
- }
- ElseIf ($counter -eq 2 -Or ($counter % 4) -eq 2) {
- $Version = $_.innerText
- $Version = $Version -replace '<[^>]+>',''
- $Version = $Version -replace '(^\s+|\s+$)','' -replace '\s+',' '
- }
- ElseIf ($counter -eq 3 -Or ($counter % 4) -eq 3) {
- $DriverVersion = GetCurrentModelVer $Label
- If ($DriverVersion -ne $null) {
- If ($($Version -replace "[^0-9]" , '') -gt $($DriverVersion -replace "[^0-9]" , '')) {
- #Write-Host "Current Driver version : " $DriverVersion
- Write-Host $Label " " $Version " " $DirectURL
- }
- }
- }
- $counter++
- }
- $ErrorActionPreference = "SilentlyContinue";
- Get-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3' | Select-Object -ExpandProperty '1001' | Out-Null
- If ($?) {
- Remove-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3' -Name '1A10'
- }
- $ErrorActionPreference = "Continue";
- If ($(Get-CimInstance Win32_Operatingsystem | Select-Object -expand Caption) -Like "*Server*") {
- Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" -Name "IsInstalled" -Value 1
- Stop-Process -Name Explorer -Force
- Start Explorer
- }
- }
- GetDellDrivers "https://www.dell.com/support/kbdoc/fr-fr/000109893/packs-de-pilotes-dell-command-deploy-pour-mod%C3%A8les-latitude"
- #GetDellDrivers "https://www.dell.com/support/kbdoc/000109842/dell-command-deploy-driver-packs-for-precision-models"
- #GetDellDrivers "https://www.dell.com/support/kbdoc/000109959/dell-command-deploy-driver-packs-for-xps-models" #errors
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement