Share via


PowerShell search for available class/method/property within imported assembly

This is article discusses how to import an assembly and search for available Classes and methods, properties.

For example, import this DLL. 

> Import-Module "C:\Program Files (x86)\Fiddler2\Xceed.Zip.v5.4.dll"

Get-Module will tell you that import was successful but there are no available Commands.

> Get-Module

 

ModuleType Version    Name                                ExportedCommands

---------- -------    ----                                ----------------

Binary     15.0.0.0   Microsoft.Exchange.WebServices

Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Cont

Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type,

Binary     5.4.135... Xceed.Zip.v5.4

Now search through the assemblies within the current domain.

> $XCEED = ([appdomain]::CurrentDomain.GetAssemblies())|?{$_.Modules.name.contains("Xceed.Zip.v5.4.dll")}

 

Following will tell you the Public Classed available in Xceed.Zip.v5.4

> $XCEED.GetModules().gettypes()|?{$_.isPublic -AND $_.isClass}

 

IsPublic IsSerial Name                                     BaseType

-------- -------- ----                                     --------

True     False    DiskRequiredEventArgs                    Xceed.FileSystem.FileSystemEventArgs

True     False    ZipEventsSession                         Xceed.FileSystem.FileSystemEventsSession

True     False    AbstractQuickAction                      System.Object

True     False    AbstractQuickActionItem                  System.Object

True     False    MultipleItemListFolder                   Xceed.FileSystem.AbstractFolder

True     False    QuickZip                                 System.Object

True     False    QuickZipItem                             Xceed.FileSystem.Quick.AbstractQuickActionItem

True     False    ZipReaderException                       System.Exception

For example, lets look further into DiskRequiredEventArgs class.

> $DRE = $XCEED.GetModules().gettypes()|?{$_.Name.equals("DiskRequiredEventArgs")}

Following will tell you the Constructer.

> ($DRE.DeclaredConstructors.GetParameters())[0]|ft member -AutoSize

 

Member

------

Void .ctor(Xceed.Zip.DiskRequiredReason, Xceed.FileSystem.AbstractFile, Int32, Int64, Xceed.Zip.DiskRequiredAction)

Following will tell you available methods and properties.

> $DRE.GetMembers()|ft memberType,Name -auto

 

MemberType Name

---------- ----

    ``Method get_Reason

    ``Method get_ZipFile

    ``Method set_ZipFile

    ``Method get_DiskNumber

    ``Method get_SplitSize

    ``Method set_SplitSize

    ``Method get_Action

    ``Method set_Action

    ``Method get_UserData

    ``Method set_UserData

    ``Method get_CurrentItem

    ``Method set_CurrentItem

    ``Method get_TargetItem

    ``Method set_TargetItem

    ``Method ToString

    ``Method Equals

    ``Method GetHashCode

    ``Method GetType

  ``Property Reason

  ``Property ZipFile

  ``Property DiskNumber

  ``Property SplitSize

  ``Property Action

  ``Property UserData

  ``Property CurrentItem

  ``Property TargetItem