Question

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.

Was it helpful?

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).

OTHER TIPS

Did you place the module in $env:PSModulePath?

Import-Module will see modules placed at the above path only. Optionally, you can add the path of your module to $env:PSModulePath.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top