Skip to content

Commit

Permalink
Merge pull request #14 from rstolpe/dev
Browse files Browse the repository at this point in the history
Optimise version
  • Loading branch information
rstolpe authored Jan 18, 2023
2 parents e894bb2 + a323271 commit bb1508d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 deletions.
19 changes: 10 additions & 9 deletions .src/private/function/Confirm-RSWinGet.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@
# 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
if ($WinGet -ne "1.19.3531.0") {
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

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

Write-Output "Installing version $($GitHubInfo.Tag) of WinGet..."
Add-AppxPackage $($GitHubInfo.OutFile)
}
else {
Write-OutPut "Your already on the latest version of WinGet $($WinGet), no need to update."
Write-Output "Installing version $($GitHubInfo.Tag) of WinGet..."
Add-AppxPackage $($GitHubInfo.OutFile)
}
else {
Write-OutPut "Your already on the latest version of WinGet $($WinGet), no need to update."
}
}
}
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" } | Sort-Object { $_.Version -as [version] } -Descending | Select-Object Version -First 1).version } catch { "0.0.0.0" })
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" })
VisualCRedistUrl = $VisualCRedistUrl
VCLibsUrl = $VCLibsUrl
Arch = $Arch
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.1.2"
[string]$Version = "0.1.3"
[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.1.2'
ModuleVersion = '0.1.3'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
21 changes: 11 additions & 10 deletions WinSoftwareUpdate/WinSoftwareUpdate.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,17 @@ 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
if ($WinGet -ne "1.19.3531.0") {
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

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

Write-Output "Installing version $($GitHubInfo.Tag) of WinGet..."
Add-AppxPackage $($GitHubInfo.OutFile)
}
else {
Write-OutPut "Your already on the latest version of WinGet $($WinGet), no need to update."
Write-Output "Installing version $($GitHubInfo.Tag) of WinGet..."
Add-AppxPackage $($GitHubInfo.OutFile)
}
else {
Write-OutPut "Your already on the latest version of WinGet $($WinGet), no need to update."
}
}
}
Function Get-RSInstallInfo {
Expand Down Expand Up @@ -249,7 +250,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" } | Sort-Object { $_.Version -as [version] } -Descending | Select-Object Version -First 1).version } catch { "0.0.0.0" })
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" })
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 : 311
Line : 312
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

0 comments on commit bb1508d

Please sign in to comment.