Last active
December 30, 2016 08:33
-
-
Save bielawb/2280408b4c6fa08b4988b73a4af2fe73 to your computer and use it in GitHub Desktop.
Just an attempt to get info about classes defined by a given module.
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
[CmdletBinding()] | |
[OutputType([hashtable])] | |
param ( | |
[string]$Path, | |
[string]$ClassName = '*' | |
) | |
$moduleBase = Split-Path -Path $Path -Parent | |
Write-Verbose "Module name - $fileName" | |
$scriptBody = @' | |
using module {0} | |
'@ -f $Path | |
$out = [ordered]@{} | |
$script = [scriptblock]::Create($scriptBody) | |
. $script | |
$assembly = Get-Module | | |
Where-Object { $_.ModuleBase -eq $moduleBase } | | |
ForEach-Object ImplementingAssembly | | |
ForEach-Object GetTypes | | |
Where-Object { | |
$_.IsPublic -and | |
$_.Name -like $ClassName | |
} | | |
Sort-Object Name | | |
ForEach-Object { | |
$out.Add( | |
$_.Name, | |
$_::new() | |
) | |
} | |
$out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment