As of version 1.7.15 we provide a PowerShell ready module installed and imported in Windows PowerShell with the library. A complete tutorial chapter is available here.
1. Referencing the library
In order to access the classes exposed by the library in PowerShell we need to introduce them to the PowerShell environment. This is achieved with the Add-Type -Path command.
PS C:\Users\Me> Add-Type -Path 'C:\Program Files (x86)\OpenPGP Library for .NET 1.7.7\Bin\BouncyCastle.CryptoExt.dll' PS C:\Users\Me> Add-Type -Path 'C:\Program Files (x86)\OpenPGP Library for .NET 1.7.7\Bin\DidiSoft.Pgp.dll'
2. Invoking methods
The method invocation is analogous to the invocation of the built-in .NET classes. Below is an example that shows how to OpenPGP encrypt a string message. Of course the library must have been referenced previously.
PS C:\Users\Me> $pgp = New-Object DidiSoft.Pgp.PGPLib PS C:\Users\Me> $pgp.EncryptString("Hello World", "c:\OpenPGPKeys\public_key.asc")
The result from the above commands will be the encrypted string in ASCII armored format.
This chapter is just an introduction how to use DidiSoft OpenPGP Library for .NET in Windows PowerShell.
You may also be interested in examining the PowerShell module provided by the library.