Created
May 31, 2018 15:58
-
-
Save jkavanagh58/7f29ed8224b2c876555a3053cf6169df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function show-installedmodules { | |
<# | |
.SYNOPSIS | |
Lists Installed Modules and compares installed versions compared to online version | |
.DESCRIPTION | |
Uses list of installed modules via Get-InstalledModule, and compares them to current online version using | |
the Find-Module returned Version | |
.EXAMPLE | |
I ♥ PS > show-installedmodules | |
Example of how to use this Function | |
.NOTES | |
=========================================================================== | |
Created with: Visual Studio Code | |
Created on: 10.01.2017 | |
Created by: Kavanagh, John J. | |
Organization: KavanaghTech | |
Filename: system-functions.ps1 | |
=========================================================================== | |
05.29.2018 JJK: Done:Add script cleanup | |
#> | |
[CmdletBinding()] | |
Param( | |
$varModules = (get-installedmodule) | |
) | |
BEGIN { | |
"-" * 52 | |
"`tReporting on {0} modules" -f $varModules.Count | |
"-" * 52 | |
}# End Begin | |
PROCESS { | |
<# | |
$varModules | | |
sort-object -Property Name | | |
select-object -Property Name, | |
Version, | |
@{ | |
Label = "Online Version"; | |
Expression = {(find-module -Name $_.Name).Version} | |
} | | |
format-table -AutoSize | |
#> | |
ForEach ($varModule in $varmodules | Sort-Object -Property Name) { | |
Write-Verbose -Message "[ROCESS]Checking online Version for $($varModule.Name)" | |
[Version]$onlineVersion = (Find-Module -Name $varModule.Name).Version | |
[Version]$localVersion = $varModule.version | |
if ($onlineVersion -gt $localVersion) { | |
Write-Host "$($varModule.Name)" -NoNewLine | |
Write-Host "`t$($localVersion)" -ForegroundColor Yellow -NoNewline | |
Write-Host "`t$($onlineVersion) Consider updating" -ForegroundColor Green | |
} | |
<# | |
Else { | |
Write-Host "$($varModule.Name)" -NoNewLine | |
Write-Host "`t$($varModule.Version)" -ForegroundColor Yellow -NoNewline | |
Write-Host "`tCurrent version is: $($onlineVersion)" -ForegroundColor Red | |
} | |
#> | |
} | |
}# End Process | |
END { | |
Remove-Variable -Name varmodules | |
[System.GC]::Collect() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment