Created
April 21, 2023 01:02
-
-
Save ecnepsnai/942ef3bba0bb43c99a665bb7bd8e669d to your computer and use it in GitHub Desktop.
Powershell Update Geforce Drivers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Download and install the latest Nvidia GeForce drivers | |
.PARAMETER SeriesID | |
The product series ID. Defaults to "GeForce RTX 20 Series" | |
.PARAMETER FamilyID | |
The product family ID. Defaults to "GeForce RTX 2080 Super" | |
.PARAMETER OSID | |
The operating system ID. Defaults to Windows 11. | |
.PARAMETER LanguageCode | |
The language code. Defaults to English (US). | |
#> | |
param ( | |
[Parameter(Mandatory=$true)] | |
[string] $SeriesID="107", | |
[Parameter(Mandatory=$true)] | |
[string] $FamilyID="904", | |
[Parameter(Mandatory=$true)] | |
[string] $OSID="135", | |
[Parameter(Mandatory=$true)] | |
[string] $LanguageCode="1033" | |
) | |
$drivers = Invoke-WebRequest "https://gfwsl.geforce.com/services_toolkit/services/com/nvidia/services/AjaxDriverService.php?func=DriverManualLookup&psid=$SeriesID&pfid=$FamilyID&osID=$OSID&languageCode=$LanguageCode&beta=null&isWHQL=0&dltype=-1&dch=1&upCRD=null&qnf=0&sort1=0&numberOfResults=10" | ConvertFrom-JSON | |
$latestRelease = $drivers.IDS[0].downloadInfo | |
$latestVersion = $latestRelease.Version | |
$videoController = Get-WmiObject -ClassName Win32_VideoController | Where-Object { $_.Name -match "NVIDIA" } | |
$installedVersion = ($videoController.DriverVersion.Replace('.', '')[-5..-1] -join '').insert(3, '.') | |
if ($installedVersion -eq $latestVersion) { | |
Write-Host "Installed version " -NoNewLine | |
Write-Host $installedVersion -NoNewLine -ForegroundColor Blue | |
Write-Host " is latest. " -NoNewLine | |
Write-Host "GeForce Drivers are up-to-date!" -ForegroundColor Green | |
return | |
} | |
Write-Host "Installed version: " -NoNewLine | |
Write-Host $installedVersion -ForegroundColor Yellow -NoNewLine | |
Write-Host " Latest version: " -NoNewLine | |
Write-Host $latestVersion -ForegroundColor Green | |
Write-Host -NoNewLine "Continue with update? [Y/N]: " | |
$x = $host.UI.RawUI.ReadKey("IncludeKeyDown") | |
if ($x.Character.ToString().ToLower() -ne "y") { | |
return | |
} | |
Write-Host "" | |
$tempDir = $env:TEMP + "\" + [System.Guid]::NewGuid() | |
mkdir $tempDir | Out-Null | |
mkdir $tempDir\install | Out-Null | |
Invoke-WebRequest $latestRelease.DownloadURL -OutFile "$tempDir\setup.exe" | |
$signature = Get-AuthenticodeSignature "$tempDir\setup.exe" | |
if ($signature.Status -ne "Valid") { | |
Write-Error "Digital signature verification failed" | |
return | |
} | |
& 'C:\Program Files\7-Zip\7z.exe' x -o"$tempDir\install" "$tempDir\setup.exe" | Out-Null | |
Start-Process -FilePath "$tempDir\install\setup.exe" -Verb runas -Wait | |
Remove-Item -Path "$tempDir" -Recurse -Force | |
$videoController = Get-WmiObject -ClassName Win32_VideoController | Where-Object { $_.Name -match "NVIDIA" } | |
$installedVersion = ($videoController.DriverVersion.Replace('.', '')[-5..-1] -join '').insert(3, '.') | |
if ($installedVersion -ne $latestVersion) { | |
Write-Host "GeForce Drivers did not update successfully" | |
return | |
} | |
Write-Host "GeForce Drivers updated to $installedVersion" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment