Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 4.0 » Add-Type

Add-Type - Powershell 4.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »

Add-Type

Short description
Adds a Microsoft .NET Framework type (a class) to a Windows PowerShell session.

Syntax


Description
The Add-Type cmdlet lets you define a .NET Framework class in your Windows PowerShell session. You can then 
instantiate objects (by using the New-Object cmdlet) and use the objects, just as you would use any .NET Framework 
object. If you add an Add-Type command to your Windows PowerShell profile, the class is available in all Windows 
PowerShell sessions.


You can specify the type by specifying an existing assembly or source code files, or you can specify the source code 
inline or saved in a variable. You can even specify only a method and Add-Type will define and generate the class. You 
can use this feature to make Platform Invoke (P/Invoke) calls to unmanaged functions in Windows PowerShell. If you 
specify source code, Add-Type compiles the specified source code and generates an in-memory assembly that contains the 
new .NET Framework types.


You can use the parameters of Add-Type to specify an alternate language and compiler (CSharp is the default), compiler 
options, assembly dependencies, the class namespace, the names of the type, and the resulting assembly.