The specified module ‘DidiSoft.Pgp.PowerShell’ was not loaded because no valid module file was found in any module directory

When trying to use any of the PGP PowerShell functions provided with DidiSoft.Pgp.Powershell.dll, e.g.

PS>ConvertTo-PgpEncryptedFile 

you may encounter this error:
The specified module ‘DidiSoft.Pgp.PowerShell’ was not loaded because no valid module file was found in any module directory.

Why is PowerShell not loaded

The main reason why DidiSoft.Pgp.Powershell.dll is not loaded, is because PowerShell cannot find it although it was registered with

Import-Module DidiSoft.Pgp.PowerShell.dll

The reason for this is that PowerShell searches modules in the locations specified in PSModulePath environment variable.

How to include the part to PSModulePath

In order to include the file system path where DidiSoft.Pgp.PowerShell.dll resides, we must first check where is it. We can do that with the Get-module command

PS> Get-module -ListAvailable
and check where is DidiSoft.Pgp.PowerShell

Powershell path of DidiSoft.Pgp.PowerShell
The next step is to append this path to the Environment variable PSModulePath:

PSModulePath environment variable

Then we just have to restart the PowerShell console and all the OpenPGP related PowerShell commands will be available.

Credits to https://www.sharepointdiary.com/2020/01/import-module-specified-module-not-loaded-because-no-valid-module-file-found-in-any-module-directory.html