Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell Importing custom C# CMDlets, no available "ExportedCommands"

first question here :)

So I have to create a custom CMDLet for Powershell 2.0, using visual studio 2010 express. I have followed this seemingly simple tutorial : http://blogs.msdn.com/b/saveenr/archive/2010/03/08/how-to-create-a-powershell-2-0-module-and-cmdlet-with-visual-studio-2010-screencast-included.aspx

My code is almost the same (even tried copy pasting thier code) but after I call Import-Module "path_to_dll"

and then call Get-Module, i see my imported module, but no ExportedCommands are available.

ModuleType Name                      ExportedCommands
---------- ----                      ----------------
Binary     PowerShellCMDLetsLibrary  {}

C# Code:

namespace PowerShellCMDLetsLibrary
{
    [System.Management.Automation.Cmdlet(System.Management.Automation.VerbsCommon.Get,"RemedyXml")]
    public class Get_RemedyXml:System.Management.Automation.PSCmdlet
    {
    [System.Management.Automation.Parameter(Position = 0, Mandatory = true)]
    public string TicketID;

    protected override void ProcessRecord()
    {
    ...
    this.WriteObject(Result.InnerXml, true);
    }

Might be a blunder, I just can't see it

like image 1000
Daniel Avatar asked Dec 17 '25 20:12

Daniel


1 Answers

Two things jump out @ me:

  1. The TicketID is a field, not a Property.
  2. The overnamedspaced attribution makes the code hard to read.

I suspect it's #1 , but I can't see enough past #2 to be sure.

Hope this Helps

like image 132
Start-Automating Avatar answered Dec 19 '25 10:12

Start-Automating