質問

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.

役に立ちましたか?

解決

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

他のヒント

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top