Reputation: 294
Get-Module -Name Microsoft.PowerShell.Utility
ModuleType Version Name ExportedCommands
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
I want to expand ExportedCommands and print Name by each one.
Name ExportedCmdlets
Microsoft.PowerShell.Utility Add-Member
Microsoft.PowerShell.Utility Add-Type
Microsoft.Powershell.Utility Clear-Variable
Microsoft.Powershell.Utility Compare-Object
Upvotes: 2
Views: 318
Reputation: 8878
You can use a nested foreach loop to iterate over the exported cmdlets. If you look at the type of object that property is, you'll see it's a dictionary.
Get-Module -Name Microsoft.PowerShell.Utility | ForEach-Object {
$_.ExportedCmdlets | Get-Member
}
TypeName: System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Management.Automation.CmdletInfo, System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]
Since the keys and the names are the same in this case, you can use either.
Get-Module -Name Microsoft.PowerShell.Utility | ForEach-Object {
foreach($cmdlet in $_.ExportedCmdlets.keys){
[PSCustomObject]@{
Name = $_.Name
Cmdlet = $cmdlet
}
}
}
Output (truncated)
Name Cmdlet
---- ------
Microsoft.PowerShell.Utility Add-Member
Microsoft.PowerShell.Utility Add-Type
Microsoft.PowerShell.Utility Clear-Variable
Microsoft.PowerShell.Utility Compare-Object
Upvotes: 3