Search code examples
c#powershellpowershell-module

Powshell Binary Module


I have a powershell module with a base class that derives from cmdlet and all of my cmdlets derive from that. Import-module cannot see any of my classes that indirectly derive from cmdlet. Do I need to add a manifest to support this structure.


Solution

  • It's likely one of both of the following problems:

    • The classes are not public
    • The classes are not decorated with [CmdletAttribute]

    Here's a minimal, functioning cmdlet:

    [Cmdlet(Verb = VerbsCommon.Get, Noun = "Answer")]
    public class GetAnswerCommand : PSCmdlet {
        public override void EndProcessing() {
            WriteObject(42);
        }
    }
    

    Use import-module with -verbose to see information about what's visible. For binary modules, you do not need a manifest (psd1).