Skip to content

Commit

Permalink
see changelog for v1.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhitsolutions committed Jan 4, 2019
1 parent c8743ad commit 9861fbe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Binary file modified PSScriptTools.psd1
Binary file not shown.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log for PSScriptTools

## v1.8.1

+ minor corrections to `Compare-Module` (Issue #21)

## v1.8.0

+ fixed typo in `Write-Detail` (Thanks @AndrewPla)
Expand Down
25 changes: 13 additions & 12 deletions functions/Compare-Module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Function Compare-Module {
$fmoParams.Add("Name", $Name)
}
Try {
$online = Find-Module @fmoParams
$online = @(Find-Module @fmoParams)
}
Catch {
Write-Warning "Failed to find online module(s). $($_.Exception.message)"
Expand All @@ -67,7 +67,7 @@ Function Compare-Module {
$progParam.percentComplete = 80
Write-Progress @progParam

$data = $online | Where-Object {$installed.name -contains $_.name} |
$data = ($online).Where( {$installed.name -contains $_.name}) |
Select-Object -property Name,
@{Name = "OnlineVersion"; Expression = {$_.Version}},
@{Name = "InstalledVersion"; Expression = {
Expand All @@ -78,15 +78,17 @@ Function Compare-Module {
PublishedDate,
@{Name = "UpdateNeeded"; Expression = {
$name = $_.Name
#there could me multiple versions installed
$installedVersions = $installed.Where( {$_.name -eq $name}).Version | Sort-Object
foreach ($item in $installedVersions) {
If ($_.Version -gt $item) {
$result = $True
}
else {
$result = $False
}
#there could be multiple versions installed
#only need to compare the last one
$mostRecentVersion = $installed.Where( {$_.name -eq $name}).Version |
Sort-Object -Descending | Select-Object -first 1

#need to ensure that PowerShell compares version objects and not strings
If ([version]$_.Version -gt [version]$mostRecentVersion) {
$result = $True
}
else {
$result = $False
}
$result
}
Expand All @@ -102,7 +104,6 @@ Function Compare-Module {
else {
Write-Warning "No local module or modules found"
}

} #Progress

End {
Expand Down

0 comments on commit 9861fbe

Please sign in to comment.