Skip to content
Merged

Dev #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .src/private/function/Confirm-RSWinGet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
[Parameter(Mandatory = $true, HelpMessage = "The headers and API version for the GitHub API")]
[hashtable]$GithubHeaders,
[Parameter(Mandatory = $false, HelpMessage = "Information about the installed version of WinGet")]
[string]$WinGet
$WinGet
)

if ($WinGet -eq "No") {
Expand All @@ -57,12 +57,10 @@
[System.Object]$GithubInfoRestData = Invoke-RestMethod -Uri $GitHubUrl -Method Get -Headers $GithubHeaders -TimeoutSec 10 | Select-Object -Property assets, tag_name
}

[string]$latestVersion = $GithubInfoRestData.tag_name.Substring(1)

[System.Object]$GitHubInfo = [PSCustomObject]@{
Tag = $latestVersion
Tag = $($GithubInfoRestData.tag_name.Substring(1))
DownloadUrl = $GithubInfoRestData.assets | where-object { $_.name -like "*.msixbundle" } | Select-Object -ExpandProperty browser_download_url
OutFile = "$env:TEMP\WinGet_$($latestVersion).msixbundle"
OutFile = "$env:TEMP\WinGet_$($GithubInfoRestData.tag_name.Substring(1)).msixbundle"
}
}
catch {
Expand All @@ -74,7 +72,10 @@
}

# Checking if the installed version of WinGet are the same as the latest version of WinGet
if ($WinGet -lt $GitHubInfo.Tag) {
[version]$vWinGet = [string]$WinGet
[version]$vGitHub = [string]$GitHubInfo.Tag

if ([Version]$vWinGet -lt [Version]$vGitHub) {
Write-Output "WinGet has a newer version $($GitHubInfo.Tag), downloading and installing it..."
Invoke-WebRequest -UseBasicParsing -Uri $GitHubInfo.DownloadUrl -OutFile $GitHubInfo.OutFile

Expand Down
2 changes: 1 addition & 1 deletion .src/private/function/Get-RSInstallInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
# Collects everything in pscustomobject to get easier access to the information
[System.Object]$SysInfo = [PSCustomObject]@{
VCLibs = $(Get-AppxPackage -Name "Microsoft.VCLibs.140.00" -AllUsers | Where-Object { $_.Architecture -eq $Arch })
WinGet = $(try { (Get-AppxPackage -AllUsers | Where-Object { $_.name -like "Microsoft.DesktopAppInstaller" }).version } catch { "no" })
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" })
VisualCRedistUrl = $VisualCRedistUrl
$VCLibsUrl = $VCLibsUrl
Arch = $Arch
Expand Down
4 changes: 2 additions & 2 deletions Help/Confirm-RSWinGet.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SYNOPSIS


SYNTAX
Confirm-RSWinGet [-GitHubUrl] <String> [-GithubHeaders] <Hashtable> [[-WinGet] <String>] [<CommonParameters>]
Confirm-RSWinGet [-GitHubUrl] <String> [-GithubHeaders] <Hashtable> [[-WinGet] <Object>] [<CommonParameters>]


DESCRIPTION
Expand All @@ -35,7 +35,7 @@ PARAMETERS
Accept pipeline input? false
Accept wildcard characters? false

-WinGet <String>
-WinGet <Object>

Required? false
Position? 3
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ This module will let you update your installed software with WinGet, many of the
This module is perfect for people like me that are to lazy to update every singel software all the time, it's much easier to just run a PowerShell Script.
I have added the result from PSScriptAnalyzer in [test folder](https://github.com/rstolpe/WinSoftwareUpdate/tree/main/test) I have some ShouldProcess warnings in this module but that's nothing to worry about really.

# Note
This module are only supported with PowerShell 5.1 because of limitation for the Appx module.

## This module can do the following
- Check what platform your currently running and adapt the downloads for that, if your running x86, amd64, arm64.
- Make sure that you have WinGet installed and up to date, if it's not the module will install / update it for you to the latest version.
Expand Down
2 changes: 1 addition & 1 deletion RSModuleBuilder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[string]$apiKey = ""
#
# Changes on every build
[string]$Version = "0.0.9"
[string]$Version = "0.1.0"
[string]$PowerShellVersion = "5.1"
[string]$Tags = '"windows", "maintenance", "autoupdate", "autoupdate-script", "psmodule", "update", "winget", "windows10", "windows11"'
[string]$ProcessorArchitecture = ""
Expand Down
2 changes: 1 addition & 1 deletion WinSoftwareUpdate/WinSoftwareUpdate.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
RootModule = '.\WinSoftwareUpdate.psm1'

# Version number of this module.
ModuleVersion = '0.0.9'
ModuleVersion = '0.1.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
15 changes: 8 additions & 7 deletions WinSoftwareUpdate/WinSoftwareUpdate.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Function Confirm-RSWinGet {
[Parameter(Mandatory = $true, HelpMessage = "The headers and API version for the GitHub API")]
[hashtable]$GithubHeaders,
[Parameter(Mandatory = $false, HelpMessage = "Information about the installed version of WinGet")]
[string]$WinGet
$WinGet
)

if ($WinGet -eq "No") {
Expand All @@ -160,12 +160,10 @@ Function Confirm-RSWinGet {
[System.Object]$GithubInfoRestData = Invoke-RestMethod -Uri $GitHubUrl -Method Get -Headers $GithubHeaders -TimeoutSec 10 | Select-Object -Property assets, tag_name
}

[string]$latestVersion = $GithubInfoRestData.tag_name.Substring(1)

[System.Object]$GitHubInfo = [PSCustomObject]@{
Tag = $latestVersion
Tag = $($GithubInfoRestData.tag_name.Substring(1))
DownloadUrl = $GithubInfoRestData.assets | where-object { $_.name -like "*.msixbundle" } | Select-Object -ExpandProperty browser_download_url
OutFile = "$env:TEMP\WinGet_$($latestVersion).msixbundle"
OutFile = "$env:TEMP\WinGet_$($GithubInfoRestData.tag_name.Substring(1)).msixbundle"
}
}
catch {
Expand All @@ -177,7 +175,10 @@ Function Confirm-RSWinGet {
}

# Checking if the installed version of WinGet are the same as the latest version of WinGet
if ($WinGet -lt $GitHubInfo.Tag) {
[version]$vWinGet = [string]$WinGet
[version]$vGitHub = [string]$GitHubInfo.Tag

if ([Version]$vWinGet -lt [Version]$vGitHub) {
Write-Output "WinGet has a newer version $($GitHubInfo.Tag), downloading and installing it..."
Invoke-WebRequest -UseBasicParsing -Uri $GitHubInfo.DownloadUrl -OutFile $GitHubInfo.OutFile

Expand Down Expand Up @@ -244,7 +245,7 @@ Function Get-RSInstallInfo {
# Collects everything in pscustomobject to get easier access to the information
[System.Object]$SysInfo = [PSCustomObject]@{
VCLibs = $(Get-AppxPackage -Name "Microsoft.VCLibs.140.00" -AllUsers | Where-Object { $_.Architecture -eq $Arch })
WinGet = $(try { (Get-AppxPackage -AllUsers | Where-Object { $_.name -like "Microsoft.DesktopAppInstaller" }).version } catch { "no" })
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" })
VisualCRedistUrl = $VisualCRedistUrl
$VCLibsUrl = $VCLibsUrl
Arch = $Arch
Expand Down
2 changes: 1 addition & 1 deletion test/PSScriptAnalyzer_WinSoftwareUpdate.psm1_2023-01-18.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RuleSuppressionID :
SuggestedCorrections :
IsSuppressed : False

Line : 306
Line : 307
Column : 10
Message : Function 'Start-RSWinGet' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'.
Extent : Start-RSWinGet
Expand Down