├── Download_NVidia_Driver.ps1 ├── LICENSE └── README.md /Download_NVidia_Driver.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Check for the latest NVIdia driver version, and if it's lower than the current one download 4 | 5 | .PARAMETER Clean 6 | Delete the old driver, reset settings and install the newest one 7 | 8 | .EXAMPLE 9 | UpdateNVidiaDriver 10 | 11 | .NOTES 12 | Supports Windows 10 x64 & Windows 11 only 13 | 14 | .NOTES 15 | Installer 2.0 Command Line Guide 16 | 17 | .NOTES 18 | https://docs.nvidia.com/sdk-manager/sdkm-command-line-install/index.html 19 | #> 20 | function UpdateNVidiaDriver 21 | { 22 | Clear-Host 23 | 24 | # Checking Windows version 25 | if ([System.Version][Environment]::OSVersion.Version.ToString() -lt [System.Version]"10.0") 26 | { 27 | Write-Verbose -Message "Your Windows is unsupported. Upgrade to Windows 10 or higher" -Verbose 28 | exit 29 | pause 30 | } 31 | 32 | # Checking Windows bitness 33 | if (-not [Environment]::Is64BitOperatingSystem) 34 | { 35 | Write-Verbose -Message "Your Windows architecture is x86. x64 is required" -Verbose 36 | exit 37 | pause 38 | } 39 | 40 | if (Test-Path -Path "$env:SystemRoot\System32\DriverStore\FileRepository\nv_*\nvidia-smi.exe") 41 | { 42 | # The NVIDIA System Management Interface (nvidia-smi) is a command line utility, based on top of the NVIDIA Management Library (NVML) 43 | $CurrentDriverVersion = nvidia-smi.exe --format=csv,noheader --query-gpu=driver_version 44 | } 45 | else 46 | { 47 | [System.Version]$Driver = (Get-CimInstance -ClassName Win32_VideoController | Where-Object -FilterScript {$_.Name -match "NVIDIA"}).DriverVersion 48 | $CurrentDriverVersion = ("{0}{1}" -f $Driver.Build, $Driver.Revision).Substring(1).Insert(3,'.') 49 | } 50 | 51 | Write-Verbose -Message "Current version: $CurrentDriverVersion" -Verbose 52 | Write-Information -MessageData "" -InformationAction Continue 53 | 54 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 55 | 56 | if ($Host.Version.Major -eq 5) 57 | { 58 | # Progress bar can significantly impact cmdlet performance 59 | # https://github.com/PowerShell/PowerShell/issues/2138 60 | $Script:ProgressPreference = "SilentlyContinue" 61 | } 62 | 63 | # Checking latest driver version from Nvidia website 64 | $Parameters = @{ 65 | Uri = "https://www.nvidia.com/Download/API/lookupValueSearch.aspx?TypeID=3" 66 | UseBasicParsing = $true 67 | } 68 | [xml]$Content = (Invoke-WebRequest @Parameters).Content 69 | $CardModelName = (Get-CimInstance -ClassName CIM_VideoController | Where-Object -FilterScript {($_.AdapterDACType -notmatch "Internal") -and ($_.Status -eq "OK")}).Caption.Split(" ") 70 | if (-not $CardModelName) 71 | { 72 | Write-Verbose -Message "There's no active videocard in system" -Verbose 73 | exit 74 | pause 75 | } 76 | 77 | # Remove the first word in full model name. E.g. "NVIDIA" 78 | $CardModelName = [string]$CardModelName[1..($CardModelName.Count)] 79 | $ParentID = ($Content.LookupValueSearch.LookupValues.LookupValue | Where-Object -FilterScript {$_.Name -match $CardModelName}).ParentID | Select-Object -First 1 80 | $Value = ($Content.LookupValueSearch.LookupValues.LookupValue | Where-Object -FilterScript {$_.Name -match $CardModelName}).Value | Select-Object -First 1 81 | 82 | # https://github.com/fyr77/EnvyUpdate/wiki/Nvidia-API 83 | # osID=57 — Windows x64/Windows 11 84 | # languageCode=1033 — English language 85 | # dch=1 — DCH drivers 86 | # https://nvidia.custhelp.com/app/answers/detail/a_id/4777/~/nvidia-dch%2Fstandard-display-drivers-for-windows-10-faq 87 | # upCRD=0 — Game Ready Driver 88 | $Parameters = @{ 89 | Uri = "https://gfwsl.geforce.com/services_toolkit/services/com/nvidia/services/AjaxDriverService.php?func=DriverManualLookup&psid=$ParentID&pfid=$Value&osID=57&languageCode=1033&beta=null&isWHQL=1&dltype=-1&dch=1&upCRD=0" 90 | UseBasicParsing = $true 91 | } 92 | $Data = Invoke-RestMethod @Parameters 93 | 94 | if ($Data.IDS.downloadInfo.Version) 95 | { 96 | $LatestVersion = $Data.IDS.downloadInfo.Version 97 | Write-Verbose -Message "Latest version: $LatestVersion" -Verbose 98 | Write-Information -MessageData "" -InformationAction Continue 99 | } 100 | else 101 | { 102 | Write-Warning -Message "Something went wrong" 103 | exit 104 | } 105 | 106 | # Comparing installed driver version to latest driver version from Nvidia 107 | if (-not $Clean -and ([System.Version]$LatestVersion -eq [System.Version]$CurrentDriverVersion)) 108 | { 109 | Write-Verbose -Message "The current installed NVidia driver is the same as the latest one" -Verbose 110 | exit 111 | pause 112 | } 113 | 114 | $DownloadsFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{374DE290-123F-4565-9164-39C4925E467B}" 115 | if (-not (Test-Path -Path "$DownloadsFolder\$LatestVersion-desktop-win10-win11-64bit-international-dch-whql.exe")) 116 | { 117 | # Downloading installer 118 | try 119 | { 120 | $Parameters = @{ 121 | Uri = $Data.IDS.downloadInfo.DownloadURL 122 | OutFile = "$DownloadsFolder\$LatestVersion-desktop-win10-win11-64bit-international-dch-whql.exe" 123 | UseBasicParsing = $true 124 | Verbose = $true 125 | } 126 | Invoke-WebRequest @Parameters 127 | } 128 | catch [System.Net.WebException] 129 | { 130 | Write-Warning -Message "Connection cannot be established" 131 | exit 132 | pause 133 | } 134 | } 135 | 136 | Write-Warning -Message "Downloading..." 137 | Write-Warning -Message $Data.IDS.downloadInfo.DownloadURL 138 | 139 | # Get the latest 7-Zip download URL 140 | try 141 | { 142 | $Parameters = @{ 143 | Uri = "https://sourceforge.net/projects/sevenzip/best_release.json" 144 | UseBasicParsing = $true 145 | Verbose = $true 146 | } 147 | $bestRelease = (Invoke-RestMethod @Parameters).platform_releases.windows.filename.replace("exe", "msi") 148 | } 149 | catch [System.Net.WebException] 150 | { 151 | Write-Warning -Message "Connection cannot be established" 152 | exit 153 | pause 154 | } 155 | 156 | # Download the latest 7-Zip x64 157 | try 158 | { 159 | $Parameters = @{ 160 | Uri = "https://unlimited.dl.sourceforge.net/project/sevenzip$($bestRelease)?viasf=1" 161 | OutFile = "$DownloadsFolder\7Zip.msi" 162 | UseBasicParsing = $true 163 | Verbose = $true 164 | } 165 | Invoke-WebRequest @Parameters 166 | } 167 | catch [System.Net.WebException] 168 | { 169 | Write-Warning -Message "Connection cannot be established" 170 | exit 171 | pause 172 | } 173 | 174 | # Expand 7-Zip 175 | $Arguments = @( 176 | "/a `"$DownloadsFolder\7Zip.msi`"" 177 | "TARGETDIR=`"$DownloadsFolder\7zip`"" 178 | "/qb" 179 | ) 180 | Start-Process "msiexec" -ArgumentList $Arguments -Wait 181 | 182 | # Delete the installer once it completes 183 | Remove-Item -Path "$DownloadsFolder\7Zip.msi" -Force 184 | 185 | # Extracting installer 186 | # Based on 7-zip.chm 187 | $Arguments = @( 188 | # Extracts files from an archive with their full paths in the current directory, or in an output directory if specified 189 | "x", 190 | # standard output messages. disable stream 191 | "-bso0", 192 | # progress information. redirect to stdout stream 193 | "-bsp1", 194 | # error messages. redirect to stdout stream 195 | "-bse1", 196 | # Overwrite All existing files without prompt 197 | "-aoa", 198 | # What to extract 199 | "$DownloadsFolder\$LatestVersion-desktop-win10-win11-64bit-international-dch-whql.exe", 200 | # Extract these files and folders 201 | "Display.Driver HDAudio NVI2 NVApp NVApp.MessageBus NVCpl PhysX EULA.txt ListDevices.txt setup.cfg setup.exe", 202 | # Specifies a destination directory where files are to be extracted 203 | "-o`"$DownloadsFolder\NVidia`"" 204 | ) 205 | $Parameters = @{ 206 | FilePath = "$DownloadsFolder\7zip\Files\7-Zip\7z.exe" 207 | ArgumentList = $Arguments 208 | NoNewWindow = $true 209 | Wait = $true 210 | } 211 | Start-Process @Parameters 212 | 213 | <# Remove unnecessary dependencies from setup.cfg 214 | [xml]$setup = Get-Content -Path "$DownloadsFolder\NVidia\setup.cfg" -Encoding UTF8 -Force 215 | ($setup.setup.manifest.file | Where-Object -FilterScript {@("`${{EulaHtmlFile}}", "`${{FunctionalConsentFile}}", "`${{PrivacyPolicyFile}}") -contains $_.name }) | ForEach-Object { 216 | $_.ParentNode.RemoveChild($_) 217 | } 218 | $setup.Save("$DownloadsFolder\NVidia\setup.cfg") 219 | #> 220 | 221 | $Parameters = @{ 222 | Path = "$DownloadsFolder\7zip", "$DownloadsFolder\$LatestVersion-desktop-win10-win11-64bit-international-dch-whql.exe" 223 | Recurse = $true 224 | Force = $true 225 | } 226 | Remove-Item @Parameters 227 | 228 | Invoke-Item -Path "$DownloadsFolder\NVidia" 229 | } 230 | 231 | UpdateNVidiaDriver 232 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Dmitry Nefedov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NVidia Driver Downloader 2 | 3 | Download the latest NVidia driver easily than ever 4 | 5 | ## Usage 6 | 7 | * Run `Download_NVidia_Driver.ps1` 8 | * If the script finds a newer version of NVidia driver it will inform you, download, and expand setup. 9 | * `-Clean` provides a clean driver installation by resetting all NVidia settings to the default ones. 10 | 11 | ## Addendum 12 | 13 | * The script provides the feature to determine your current NVidia videocard and searches for the latest available driver for your card only by parsing the NVidia cloud JSON—not only the latest driver version which is presented on the NVidia DB; 14 | * Downloads always latest 7-Zip version automatically by parsing the SourceForge cloud JSON, expands .MSI as a `portable app without installation` and run it. After creating NVidia setup, 7-Zip will be removed. 15 | 16 | ## Links 17 | 18 | [NVidia drivers](https://www.nvidia.ru/Download/index.aspx) 19 | 20 | [NVIDIA GPU UEFI Firmware Update Tool](https://nvidia.custhelp.com/app/answers/list/st/5/kw/NVIDIA%20GPU%20UEFI%20Firmware%20Update%20Tool/sort/4%2C2) 21 | 22 | [NVCleanstall](https://www.techpowerup.com/download/techpowerup-nvcleanstall/) 23 | --------------------------------------------------------------------------------