@@ -73,13 +73,13 @@ Function Confirm-rsWinGet {
7373 " X-GitHub-Api-Version" = " 2022-11-28"
7474 }
7575
76- # Collecting information from GitHub regarding latest version of WinGet
76+ # Collecting information from GitHub regarding latest version of WinGet.
7777 try {
7878 # If the computer is running PowerShell 7 or higher, use HTTP/3.0 for the GitHub API in other cases use HTTP/2.0
7979 [System.Object ]$GithubInfoRestData = Invoke-RestMethod - Uri $WinGetUrl - Method Get - Headers $GithubHeaders - TimeoutSec 10 - HttpVersion $SysInfo.HTTPVersion | Select-Object - Property assets, tag_name
8080
8181 [System.Object ]$GitHubInfo = [PSCustomObject ]@ {
82- Tag = $ ($GithubInfoRestData.tag_name.Substring (1 ))
82+ Tag = $ ($GithubInfoRestData.tag_name.Substring (1 )) -as [ version ]
8383 DownloadUrl = $GithubInfoRestData.assets | where-object { $_.name -like " *.msixbundle" } | Select-Object - ExpandProperty browser_download_url
8484 OutFile = " $ ( $env: TEMP ) \WinGet_$ ( $GithubInfoRestData.tag_name.Substring (1 )) .msixbundle"
8585 }
@@ -90,20 +90,20 @@ Function Confirm-rsWinGet {
9090 }
9191
9292 # Checking if the installed version of WinGet are the same as the latest version of WinGet
93- [version ]$vWinGet = [ string ] $SysInfo.WinGet
94- [version ]$vGitHub = [ string ] $GitHubInfo.Tag
93+ [version ]$vWinGet = $SysInfo.Software .WinGet
94+ [version ]$vGitHub = $GitHubInfo.Tag
9595 if ([Version ]$vWinGet -lt [Version ]$vGitHub ) {
96- Write-Output " WinGet has a newer version $ ( $vGitHub ) , downloading and installing it..."
96+ Write-Output " WinGet has a newer version $ ( $vGitHub | Out-String ) , downloading and installing it..."
9797 Write-Verbose " Downloading WinGet..."
9898 Invoke-WebRequest - UseBasicParsing - Uri $GitHubInfo.DownloadUrl - OutFile $GitHubInfo.OutFile
9999
100- Write-Verbose " Installing version $ ( $vGitHub ) of WinGet..."
101- Add-AppxPackage $ ($GitHubInfo.OutFile )
100+ Write-Verbose " Installing version $ ( $vGitHub | Out-String ) of WinGet..."
101+ Add-AppxPackage $ ($GitHubInfo.OutFile ) - ForceApplicationShutdown
102102 Write-Verbose " Deleting WinGet downloaded installation file..."
103103 Remove-Item $ ($GitHubInfo.OutFile ) - Force
104104 }
105105 else {
106- Write-Verbose " Your already on the latest version of WinGet $ ( $vWinGet ) , no need to update."
106+ Write-Verbose " Your already on the latest version of WinGet $ ( $vWinGet | Out-String ) , no need to update."
107107 Continue
108108 }
109109}
@@ -163,18 +163,18 @@ Function Get-rsSystemInfo {
163163 $SysInfo = [ordered ]@ {
164164 Software = [ordered ]@ {
165165 " Microsoft.VCLibs" = [ordered ]@ {
166- Version = $ (try { (Get-AppxPackage - AllUsers | Where-Object { $_.Architecture -eq $Arch -and $_.PackageFamilyName -like " Microsoft.VCLibs.140.00_8wekyb3d8bbwe" } | Sort-Object { $_.Version -as [version ] } - Descending | Select-Object Version - First 1 ).version } catch { " 0.0.0.0" })
166+ Version = $ (try { (Get-AppxPackage - AllUsers | Where-Object { $_.Architecture -eq $Arch -and $_.PackageFamilyName -like " Microsoft.VCLibs.140.00_8wekyb3d8bbwe" } | Sort-Object { $_.Version -as [version ] } - Descending | Select-Object Version - First 1 ).version } catch { " 0.0.0.0" }) -as [ version ]
167167 Url = " https://aka.ms/Microsoft.VCLibs.$ ( $Arch ) .14.00.Desktop.appx"
168168 FileName = " Microsoft.VCLibs.$ ( $Arch ) .14.00.Desktop.appx"
169169 }
170170 " Microsoft.UI.Xaml" = [ordered ]@ {
171- Version = $ (try { (Get-AppxPackage - AllUsers | Where-Object { $_.Architecture -eq $Arch -and $_.PackageFamilyName -like " Microsoft.UI.Xaml.2.8_8wekyb3d8bbwe" } | Sort-Object { $_.Version -as [version ] } - Descending | Select-Object Version - First 1 ).version } catch { " 0.0.0.0" })
171+ Version = $ (try { (Get-AppxPackage - AllUsers | Where-Object { $_.Architecture -eq $Arch -and $_.PackageFamilyName -like " Microsoft.UI.Xaml.2.8_8wekyb3d8bbwe" } | Sort-Object { $_.Version -as [version ] } - Descending | Select-Object Version - First 1 ).version } catch { " 0.0.0.0" }) -as [ version ]
172172 Url = " https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.$ ( $Arch ) .appx"
173173 FileName = " Microsoft.UI.Xaml.2.8.$ ( $Arch ) .appx"
174174 }
175175 " WinGet" = [ordered ]@ {
176- Version = $ (try { (Get-AppxPackage - AllUsers | Where-Object { $_.Architecture -eq $Arch -and $_.PackageFamilyName -like " Microsoft.DesktopAppInstaller_8wekyb3d8bbwe" } | Sort-Object { $_.Version -as [version ] } - Descending | Select-Object Version - First 1 ).version } catch { " 0.0.0.0" })
177- Url = " https://aka.ms/getwinget "
176+ Version = $ (try { (Get-AppxPackage - AllUsers | Where-Object { $_.Architecture -eq $Arch -and $_.PackageFamilyName -like " Microsoft.DesktopAppInstaller_8wekyb3d8bbwe" } | Sort-Object { $_.Version -as [version ] } - Descending | Select-Object Version - First 1 ).version } catch { " 0.0.0.0" }) -as [ version ]
177+ Url = " "
178178 FileName = " Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
179179 }
180180 " vsRedist" = [ordered ]@ {
@@ -354,18 +354,18 @@ Function Update-rsWinSoftware {
354354 }
355355
356356 # Register WinGet
357- Add-AppxPackage - RegisterByFamilyName - MainPackage " Microsoft.DesktopAppInstaller_8wekyb3d8bbwe"
357+ # Add-AppxPackage -RegisterByFamilyName -MainPackage "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe"
358358
359359 # Check if something needs to be installed or updated
360360 Confirm-RSDependency
361361
362362 # Checking if it's any softwares to update and if so it will update them
363363 Write-Output " Updating Wingets source list..."
364- WinGet.exe source update
364+ Start-Process - FilePath " WinGet.exe" - ArgumentList " source update" - Verb RunAS - NoNewWindow - Wait
365365
366366 Write-OutPut " Checks if any softwares needs to be updated..."
367367 try {
368- WinGet.exe upgrade -- all -- accept- package- agreements -- accept- source- agreements -- silent -- include- unknown -- uninstall-previous
368+ Start-Process - FilePath " WinGet.exe" - ArgumentList " upgrade --all --accept-package-agreements --accept-source-agreements --silent --include-unknown --uninstall-previous" - Verb RunAS - NoNewWindow - Wait
369369 }
370370 catch {
371371 Write-Error " Message: $ ( $_.Exception.Message ) `n Error Line: $ ( $_.InvocationInfo.Line ) `n "
0 commit comments