Reputation: 29985
I have a .net framework dll file, and it has some classes.
I want to use powershell to get all the classes' name inside the .dll file, how can I do?
update:
when I tried using import-module "xxxxx"
, it has the following error.
Upvotes: 0
Views: 1267
Reputation: 24071
Another a way: import the DLL with Import-Module
and call assembly's GetTypes()
. Like so,
import-module '<your_path>\Microsoft.SqlServer.Smo.dll'
$smo = ([appdomain]::CurrentDomain.GetAssemblies()) |
where {$_.modules.name.contains('SqlServer')}
$smo.gettypes() | where {$_.isPublic -and $_.isClass}
Upvotes: 2
Reputation: 29003
I think you can do:
$Assembly = [System.Reflection.Assembly]::LoadFrom('c:\temp\file.dll')
$Assembly.DefinedTypes
$Assembly.GetExportedTypes()
$Assembly.GetLoadedModules()
Upvotes: 4