Skip to content

Instantly share code, notes, and snippets.

@aetos382
Last active October 28, 2019 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aetos382/eb9543af259e38346acde5f1440b8b74 to your computer and use it in GitHub Desktop.
Save aetos382/eb9543af259e38346acde5f1440b8b74 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>InstalledModulesGroupedTableView</Name>
<ViewSelectedBy>
<TypeName>System.Management.Automation.PSObject#InstalledModuleInfo</TypeName>
</ViewSelectedBy>
<GroupBy>
<ScriptBlock>Split-Path -Parent -Path ( Split-Path -Parent -Path $_.InstalledLocation )</ScriptBlock>
<Label>Installed Location</Label>
</GroupBy>
<TableControl>
<TableHeaders>
<TableColumnHeader>
<Label>Name</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Version</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Description</Label>
</TableColumnHeader>
</TableHeaders>
<TableRowEntries>
<TableRowEntry>
<TableColumnItems>
<TableColumnItem>
<PropertyName>Name</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Version</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>Description</PropertyName>
</TableColumnItem>
</TableColumnItems>
</TableRowEntry>
</TableRowEntries>
</TableControl>
</View>
</ViewDefinitions>
</Configuration>
Update-FormatData -AppendPath (Join-Path -Path $PSScriptRoot -ChildPath '.\InstalledModule.format.ps1xml')
Import-Module -Name 'PowerShellGet'
function Get-InstalledModule {
<#
.ForwardHelpTargetName PowerShellGet\Get-InstalledModule
#>
[CmdletBinding()]
[OutputType('System.Management.Automation.PSObject#InstalledModuleInfo')]
param(
[Parameter(
Position = 0,
ValueFromPipelineByPropertyName)]
[ValidateNotNullOrEmpty()]
[string[]] $Name,
[Parameter(ValueFromPipelineByPropertyName)]
[ValidateNotNull()]
[string] $MinimumVersion,
[Parameter(ValueFromPipelineByPropertyName)]
[ValidateNotNull()]
[string] $RequiredVersion,
[Parameter(ValueFromPipelineByPropertyName)]
[ValidateNotNull()]
[string] $MaximumVersion,
[switch] $AllVersions,
[switch] $AllowPrerelease,
[switch] $Raw)
begin {
try {
$wrappedCmd = Get-Command 'PowerShellGet\Get-InstalledModule'
$PSBoundParameters.Remove('Raw') > $null
if ($Raw) {
$scriptBlock = { & $wrappedCmd @PSBoundParameters }
}
else {
$scriptBlock = {
& $wrappedCmd @PSBoundParameters |
Sort-Object -Property 'InstalledLocation', 'Name' |
Add-Member -TypeName 'System.Management.Automation.PSObject#InstalledModuleInfo' -PassThru
}
}
$pipeline = $scriptBlock.GetSteppablePipeline($MyInvocation.CommandOrigin)
$pipeline.Begin($PSCmdlet)
}
catch {
throw
}
}
process {
try {
$pipeline.Process($_)
}
catch {
throw
}
}
end {
try {
$pipeline.End()
}
catch {
throw
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment