@@ -160,12 +160,10 @@ Function Confirm-RSWinGet {
160160 [System.Object ]$GithubInfoRestData = Invoke-RestMethod - Uri $GitHubUrl - Method Get - Headers $GithubHeaders - TimeoutSec 10 | Select-Object - Property assets, tag_name
161161 }
162162
163- [string ]$latestVersion = $GithubInfoRestData.tag_name.Substring (1 )
164-
165163 [System.Object ]$GitHubInfo = [PSCustomObject ]@ {
166- Tag = $latestVersion
164+ Tag = $ ( $GithubInfoRestData .tag_name.Substring ( 1 ))
167165 DownloadUrl = $GithubInfoRestData.assets | where-object { $_.name -like " *.msixbundle" } | Select-Object - ExpandProperty browser_download_url
168- OutFile = " $env: TEMP \WinGet_$ ( $latestVersion ) .msixbundle"
166+ OutFile = " $env: TEMP \WinGet_$ ( $GithubInfoRestData .tag_name.Substring ( 1 ) ) .msixbundle"
169167 }
170168 }
171169 catch {
@@ -177,7 +175,10 @@ Function Confirm-RSWinGet {
177175 }
178176
179177 # Checking if the installed version of WinGet are the same as the latest version of WinGet
180- if ([Version ]$WinGet -lt [Version ]$GitHubInfo.Tag ) {
178+ [version ]$vWinGet = [string ]$WinGet
179+ [version ]$vGitHub = [string ]$GitHubInfo.Tag
180+
181+ if ([Version ]$vWinGet -lt [Version ]$vGitHub ) {
181182 Write-Output " WinGet has a newer version $ ( $GitHubInfo.Tag ) , downloading and installing it..."
182183 Invoke-WebRequest - UseBasicParsing - Uri $GitHubInfo.DownloadUrl - OutFile $GitHubInfo.OutFile
183184
@@ -244,7 +245,7 @@ Function Get-RSInstallInfo {
244245 # Collects everything in pscustomobject to get easier access to the information
245246 [System.Object ]$SysInfo = [PSCustomObject ]@ {
246247 VCLibs = $ (Get-AppxPackage - Name " Microsoft.VCLibs.140.00" - AllUsers | Where-Object { $_.Architecture -eq $Arch })
247- WinGet = $ (try { (Get-AppxPackage - AllUsers | Where-Object { $_.name -like " Microsoft.DesktopAppInstaller" }).version } catch { " no" })
248+ WinGet = $ (try { (Get-AppxPackage - AllUsers | Where-Object { $_.name -like " Microsoft.DesktopAppInstaller" } | Sort-Object { $_ .Version -as [ version ] } - Descending | Select-Object Version - First 1 ).version } catch { " no" })
248249 VisualCRedistUrl = $VisualCRedistUrl
249250 $VCLibsUrl = $VCLibsUrl
250251 Arch = $Arch
0 commit comments