Skip to content

Commit

Permalink
Merge pull request #28 from rstolpe/dev
Browse files Browse the repository at this point in the history
beta3
  • Loading branch information
rstolpe authored Apr 26, 2024
2 parents 491f6e3 + e320028 commit 54dfc68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion WinSoftwareUpdate/WinSoftwareUpdate.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
ReleaseNotes = 'https://github.com/rstolpe/WinSoftwareUpdate/releases'

# Prerelease string of this module
Prerelease = 'beta2'
Prerelease = 'beta3'

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
RequireLicenseAcceptance = $false
Expand Down
30 changes: 15 additions & 15 deletions WinSoftwareUpdate/WinSoftwareUpdate.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ Function Confirm-rsWinGet {
"X-GitHub-Api-Version" = "2022-11-28"
}

# Collecting information from GitHub regarding latest version of WinGet
# Collecting information from GitHub regarding latest version of WinGet.
try {
# If the computer is running PowerShell 7 or higher, use HTTP/3.0 for the GitHub API in other cases use HTTP/2.0
[System.Object]$GithubInfoRestData = Invoke-RestMethod -Uri $WinGetUrl -Method Get -Headers $GithubHeaders -TimeoutSec 10 -HttpVersion $SysInfo.HTTPVersion | Select-Object -Property assets, tag_name

[System.Object]$GitHubInfo = [PSCustomObject]@{
Tag = $($GithubInfoRestData.tag_name.Substring(1))
Tag = $($GithubInfoRestData.tag_name.Substring(1)) -as [version]
DownloadUrl = $GithubInfoRestData.assets | where-object { $_.name -like "*.msixbundle" } | Select-Object -ExpandProperty browser_download_url
OutFile = "$($env:TEMP)\WinGet_$($GithubInfoRestData.tag_name.Substring(1)).msixbundle"
}
Expand All @@ -90,20 +90,20 @@ Function Confirm-rsWinGet {
}

# Checking if the installed version of WinGet are the same as the latest version of WinGet
[version]$vWinGet = [string]$SysInfo.WinGet
[version]$vGitHub = [string]$GitHubInfo.Tag
[version]$vWinGet = $SysInfo.Software.WinGet
[version]$vGitHub = $GitHubInfo.Tag
if ([Version]$vWinGet -lt [Version]$vGitHub) {
Write-Output "WinGet has a newer version $($vGitHub), downloading and installing it..."
Write-Output "WinGet has a newer version $($vGitHub | Out-String), downloading and installing it..."
Write-Verbose "Downloading WinGet..."
Invoke-WebRequest -UseBasicParsing -Uri $GitHubInfo.DownloadUrl -OutFile $GitHubInfo.OutFile

Write-Verbose "Installing version $($vGitHub) of WinGet..."
Add-AppxPackage $($GitHubInfo.OutFile)
Write-Verbose "Installing version $($vGitHub | Out-String) of WinGet..."
Add-AppxPackage $($GitHubInfo.OutFile) -ForceApplicationShutdown
Write-Verbose "Deleting WinGet downloaded installation file..."
Remove-Item $($GitHubInfo.OutFile) -Force
}
else {
Write-Verbose "Your already on the latest version of WinGet $($vWinGet), no need to update."
Write-Verbose "Your already on the latest version of WinGet $($vWinGet | Out-String), no need to update."
Continue
}
}
Expand Down Expand Up @@ -163,18 +163,18 @@ Function Get-rsSystemInfo {
$SysInfo = [ordered]@{
Software = [ordered]@{
"Microsoft.VCLibs" = [ordered]@{
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" })
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]
Url = "https://aka.ms/Microsoft.VCLibs.$($Arch).14.00.Desktop.appx"
FileName = "Microsoft.VCLibs.$($Arch).14.00.Desktop.appx"
}
"Microsoft.UI.Xaml" = [ordered]@{
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" })
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]
Url = "https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.$($Arch).appx"
FileName = "Microsoft.UI.Xaml.2.8.$($Arch).appx"
}
"WinGet" = [ordered]@{
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" })
Url = "https://aka.ms/getwinget"
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]
Url = ""
FileName = "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
}
"vsRedist" = [ordered]@{
Expand Down Expand Up @@ -354,18 +354,18 @@ Function Update-rsWinSoftware {
}

# Register WinGet
Add-AppxPackage -RegisterByFamilyName -MainPackage "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe"
# Add-AppxPackage -RegisterByFamilyName -MainPackage "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe"

# Check if something needs to be installed or updated
Confirm-RSDependency

# Checking if it's any softwares to update and if so it will update them
Write-Output "Updating Wingets source list..."
WinGet.exe source update
Start-Process -FilePath "WinGet.exe" -ArgumentList "source update" -Verb RunAS -NoNewWindow -Wait

Write-OutPut "Checks if any softwares needs to be updated..."
try {
WinGet.exe upgrade --all --accept-package-agreements --accept-source-agreements --silent --include-unknown --uninstall-previous
Start-Process -FilePath "WinGet.exe" -ArgumentList "upgrade --all --accept-package-agreements --accept-source-agreements --silent --include-unknown --uninstall-previous" -Verb RunAS -NoNewWindow -Wait
}
catch {
Write-Error "Message: $($_.Exception.Message)`nError Line: $($_.InvocationInfo.Line)`n"
Expand Down

0 comments on commit 54dfc68

Please sign in to comment.