Last active
October 28, 2019 06:28
-
-
Save aetos382/eb9543af259e38346acde5f1440b8b74 to your computer and use it in GitHub Desktop.
This file contains 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
<?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> |
This file contains 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
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