Last active
November 16, 2020 23:39
-
-
Save aetos382/73656511de70cb79cd19743816183f89 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
| Import-Module -Name PowerShellGet | |
| Update-FormatData -AppendPath (Join-Path -Path $PSScriptRoot -ChildPath '.\InstalledModule.format.ps1xml') | |
| function Get-InstalledModule { | |
| <# | |
| .ForwardHelpTargetName PowerShellGet\Get-InstalledModule | |
| #> | |
| [CmdletBinding()] | |
| [OutputType('System.Management.Automation.PSObject#InstalledModule')] | |
| 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] $NoGrouping) | |
| begin { | |
| try { | |
| $PSBoundParameters.Remove('NoGrouping') > $null | |
| $outBuffer = $null | |
| if ($PSBoundParameters.TryGetValue('OutBuffer', [ref] $outBuffer)) | |
| { | |
| $PSBoundParameters['OutBuffer'] = 1 | |
| } | |
| $wrappedCmd = Get-Command 'PowerShellGet\Get-InstalledModule' | |
| if ($NoGrouping) { | |
| $scriptBlock = { & $wrappedCmd @PSBoundParameters } | |
| } | |
| else { | |
| $scriptBlock = { | |
| & $wrappedCmd @PSBoundParameters | | |
| Sort-Object -Property 'InstalledLocation', 'Name' | | |
| Add-Member -TypeName 'System.Management.Automation.PSObject#InstalledModule' -PassThru | |
| } | |
| } | |
| $pipeline = $scriptBlock.GetSteppablePipeline($MyInvocation.CommandOrigin) | |
| $pipeline.Begin($PSCmdlet) | |
| } | |
| catch { | |
| throw | |
| } | |
| } | |
| process { | |
| try { | |
| $pipeline.Process($_) | |
| } | |
| catch { | |
| throw | |
| } | |
| } | |
| end { | |
| try { | |
| $pipeline.End() | |
| } | |
| catch { | |
| throw | |
| } | |
| } | |
| } |
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
| <?xml version="1.0" encoding="utf-8" ?> | |
| <Configuration> | |
| <ViewDefinitions> | |
| <View> | |
| <Name>InstalledModulesGroupedTableView</Name> | |
| <ViewSelectedBy> | |
| <TypeName>System.Management.Automation.PSObject#InstalledModule</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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment