Skip to content

Commit bb1508d

Browse files
author
Robin Stolpe
authored
Merge pull request #14 from rstolpe/dev
Optimise version
2 parents e894bb2 + a323271 commit bb1508d

File tree

6 files changed

+25
-23
lines changed

6 files changed

+25
-23
lines changed

.src/private/function/Confirm-RSWinGet.ps1

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,16 @@
7474
# Checking if the installed version of WinGet are the same as the latest version of WinGet
7575
[version]$vWinGet = [string]$SysInfo.WinGet
7676
[version]$vGitHub = [string]$GitHubInfo.Tag
77+
if ($WinGet -ne "1.19.3531.0") {
78+
if ([Version]$vWinGet -lt [Version]$vGitHub) {
79+
Write-Output "WinGet has a newer version $($GitHubInfo.Tag), downloading and installing it..."
80+
Invoke-WebRequest -UseBasicParsing -Uri $GitHubInfo.DownloadUrl -OutFile $GitHubInfo.OutFile
7781

78-
if ([Version]$vWinGet -lt [Version]$vGitHub -or $WinGet -like "1.19.3531.0") {
79-
Write-Output "WinGet has a newer version $($GitHubInfo.Tag), downloading and installing it..."
80-
Invoke-WebRequest -UseBasicParsing -Uri $GitHubInfo.DownloadUrl -OutFile $GitHubInfo.OutFile
81-
82-
Write-Output "Installing version $($GitHubInfo.Tag) of WinGet..."
83-
Add-AppxPackage $($GitHubInfo.OutFile)
84-
}
85-
else {
86-
Write-OutPut "Your already on the latest version of WinGet $($WinGet), no need to update."
82+
Write-Output "Installing version $($GitHubInfo.Tag) of WinGet..."
83+
Add-AppxPackage $($GitHubInfo.OutFile)
84+
}
85+
else {
86+
Write-OutPut "Your already on the latest version of WinGet $($WinGet), no need to update."
87+
}
8788
}
8889
}

.src/private/function/Get-RSInstallInfo.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
# Collects everything in pscustomobject to get easier access to the information
5555
[System.Object]$SysInfo = [PSCustomObject]@{
5656
VCLibs = $(Get-AppxPackage -Name "Microsoft.VCLibs.140.00" -AllUsers | Where-Object { $_.Architecture -eq $Arch })
57-
WinGet = $(try { (Get-AppxPackage -AllUsers | Where-Object { $_.name -like "Microsoft.DesktopAppInstaller" } | Sort-Object { $_.Version -as [version] } -Descending | Select-Object Version -First 1).version } catch { "0.0.0.0" })
57+
WinGet = $(try { (Get-AppxPackage -AllUsers | Where-Object { $_.PackageFamilyName -like "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe" } | Sort-Object { $_.Version -as [version] } -Descending | Select-Object Version -First 1).version } catch { "0.0.0.0" })
5858
VisualCRedistUrl = $VisualCRedistUrl
5959
VCLibsUrl = $VCLibsUrl
6060
Arch = $Arch

RSModuleBuilder.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[string]$apiKey = ""
1010
#
1111
# Changes on every build
12-
[string]$Version = "0.1.2"
12+
[string]$Version = "0.1.3"
1313
[string]$PowerShellVersion = "5.1"
1414
[string]$Tags = '"windows", "maintenance", "autoupdate", "autoupdate-script", "psmodule", "update", "winget", "windows10", "windows11"'
1515
[string]$ProcessorArchitecture = ""

WinSoftwareUpdate/WinSoftwareUpdate.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
RootModule = '.\WinSoftwareUpdate.psm1'
3737

3838
# Version number of this module.
39-
ModuleVersion = '0.1.2'
39+
ModuleVersion = '0.1.3'
4040

4141
# Supported PSEditions
4242
# CompatiblePSEditions = @()

WinSoftwareUpdate/WinSoftwareUpdate.psm1

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,17 @@ Function Confirm-RSWinGet {
181181
# Checking if the installed version of WinGet are the same as the latest version of WinGet
182182
[version]$vWinGet = [string]$SysInfo.WinGet
183183
[version]$vGitHub = [string]$GitHubInfo.Tag
184+
if ($WinGet -ne "1.19.3531.0") {
185+
if ([Version]$vWinGet -lt [Version]$vGitHub) {
186+
Write-Output "WinGet has a newer version $($GitHubInfo.Tag), downloading and installing it..."
187+
Invoke-WebRequest -UseBasicParsing -Uri $GitHubInfo.DownloadUrl -OutFile $GitHubInfo.OutFile
184188

185-
if ([Version]$vWinGet -lt [Version]$vGitHub -or $WinGet -like "1.19.3531.0") {
186-
Write-Output "WinGet has a newer version $($GitHubInfo.Tag), downloading and installing it..."
187-
Invoke-WebRequest -UseBasicParsing -Uri $GitHubInfo.DownloadUrl -OutFile $GitHubInfo.OutFile
188-
189-
Write-Output "Installing version $($GitHubInfo.Tag) of WinGet..."
190-
Add-AppxPackage $($GitHubInfo.OutFile)
191-
}
192-
else {
193-
Write-OutPut "Your already on the latest version of WinGet $($WinGet), no need to update."
189+
Write-Output "Installing version $($GitHubInfo.Tag) of WinGet..."
190+
Add-AppxPackage $($GitHubInfo.OutFile)
191+
}
192+
else {
193+
Write-OutPut "Your already on the latest version of WinGet $($WinGet), no need to update."
194+
}
194195
}
195196
}
196197
Function Get-RSInstallInfo {
@@ -249,7 +250,7 @@ Function Get-RSInstallInfo {
249250
# Collects everything in pscustomobject to get easier access to the information
250251
[System.Object]$SysInfo = [PSCustomObject]@{
251252
VCLibs = $(Get-AppxPackage -Name "Microsoft.VCLibs.140.00" -AllUsers | Where-Object { $_.Architecture -eq $Arch })
252-
WinGet = $(try { (Get-AppxPackage -AllUsers | Where-Object { $_.name -like "Microsoft.DesktopAppInstaller" } | Sort-Object { $_.Version -as [version] } -Descending | Select-Object Version -First 1).version } catch { "0.0.0.0" })
253+
WinGet = $(try { (Get-AppxPackage -AllUsers | Where-Object { $_.PackageFamilyName -like "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe" } | Sort-Object { $_.Version -as [version] } -Descending | Select-Object Version -First 1).version } catch { "0.0.0.0" })
253254
VisualCRedistUrl = $VisualCRedistUrl
254255
VCLibsUrl = $VCLibsUrl
255256
Arch = $Arch

test/PSScriptAnalyzer_WinSoftwareUpdate.psm1_2023-01-18.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ RuleSuppressionID :
1111
SuggestedCorrections :
1212
IsSuppressed : False
1313

14-
Line : 311
14+
Line : 312
1515
Column : 10
1616
Message : Function 'Start-RSWinGet' has verb that could change system state. Therefore, the function has to support 'ShouldProcess'.
1717
Extent : Start-RSWinGet

0 commit comments

Comments
 (0)