Created
December 1, 2016 10:24
-
-
Save Sarafian/2c614cb18bd38dffa1208fbeddc294cb to your computer and use it in GitHub Desktop.
Show powershell module's (loaded and available) organized by Name, Version and Location
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
<# | |
.Synopsis | |
Reports modules | |
.DESCRIPTION | |
Reports modules | |
.EXAMPLE | |
Show-ModuleVersion | |
.EXAMPLE | |
Show-ModuleVersion -ListAvailable | |
.EXAMPLE | |
Show-ModuleVersion -ListAvailable -Name Pester | |
#> | |
function Global:Show-ModuleVersion | |
{ | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$false)] | |
[string]$Name=$null, | |
[Parameter(Mandatory=$false)] | |
[switch]$ListAvailable=$false | |
) | |
if($Name) | |
{ | |
$modules=Get-Module -Name $Name -ListAvailable:$ListAvailable | |
} | |
else | |
{ | |
$modules=Get-Module -ListAvailable:$ListAvailable | |
} | |
$groups=$modules |Sort-Object -Property Name|Group-Object -Property Name | |
$groups|ForEach-Object { | |
$_.Group | Sort-Object -Property Version -Descending | Select-Object Name,Version,@{Name="Profile";Expression={ | |
switch ($_.ModuleBase) | |
{ | |
{$_ -like "$($env:SystemRoot)*" } { | |
"System" | |
break | |
} | |
{$_ -like "$($env:USERPROFILE)*" } { | |
"Profile" | |
break | |
} | |
{$_ -like "$(${env:ProgramFiles(x86)})*" } { | |
"Program Files (x86)" | |
break | |
} | |
{$_ -like "$($env:ProgramFiles)*" } { | |
"Program Files" | |
break | |
} | |
Default {"Unknown"} | |
} | |
}},ModuleBase | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For example on my client I've update the Pester module. This is how it would look