Abstract
It is sometime less efficient to write code and compile it only for checking capability of libraries. Scripting on PowerShell can also call libraries. Example, .Net Framework library can be called with command "Add-Type".
Add-Type
Standard library
If a required library is provided by Windows or .Net Framework, its class can be added to a PowerShell session with the next command and its assembly name.
Add-Type -Assembly "Assembly Name"
Example, the next command can call MessageBox in "System.Windows.Forms”.
Add-type -assembly "System.Windows.Forms" [System.Windows.Forms.MessageBox]::Show("!!!!")
Other library
Even DLL files from other libraries, if it is based on .Net Framework, is callable with specifying its path.
Add-Type -Path "path to a DLL file"
Example, most libraries are stored in Windows system folder, and its path is "%SystemRoot%\System32". Libraries only for certain projects would be stored in its project folder. The next command is example to call the method ”GetWikipedia” from ”MagicWandWin.DLL”.
add-type -path "D:\user temp\work\1min\packages\MagicWandWin.3.0.1\lib\net472\MagicWandWin.DLL" [MagicWand.Magic]::GetWikipedia("モリアーティ")
Get-Member - Looking inside of a library
The next post introduces how to look inside of unknown library with IL DASM.
How to look inside of unknown library or DLL with "ildasm" - Technically Impossible
If a library is based on .Net Framework, and a class name is identified, PowerShell can find it out more with the command ”Get-Member”. Execute object and command with pipe as below.
[MagicWand.Magic] | Get-Member
Example, the next command can get the list of method as Intellisense provides.
[MagicWand.Magic] | Get-Member -Static