header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
cmdlet development in other than C# and VB
Last Post 30 Jun 2009 09:20 AM by Poshoholic. 5 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
ChrisUser is Offline
New Member
New Member
Posts:5
Avatar

--
28 Jun 2009 09:30 PM
    Hi Guys

    I want to know if it is possible to create a cmdlet in any language other than C# or VB.

    Is it possible to develop in powershell itself?

    Thanks

    Chris
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    28 Jun 2009 11:36 PM

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    Marco Shaw (MVP)User is Offline
    Veteran Member
    Veteran Member
    Posts:1641
    Avatar

    --
    29 Jun 2009 08:46 AM
    Can you be more specific on what you might want to do?

    You're hoping to do something in C, for example? Apparently you can do .NET programming in C, but I'm not experience enough to know if this can be extended to PowerShell and whether there may be limitations.
    Marco

    *Microsoft MVP - Windows PowerShell
    https://mvp.support.microsoft.com/profile/Marco.Shaw
    *Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
    *Blog - http://marcoshaw.blogspot.com
    ChrisUser is Offline
    New Member
    New Member
    Posts:5
    Avatar

    --
    29 Jun 2009 02:47 PM
    I want to develop commandlets that would make WMI calls to get some disk management tasks. Since there is a good support for WMI in powershell, I was thinking of doing things in powershell itself.
    Marco Shaw (MVP)User is Offline
    Veteran Member
    Veteran Member
    Posts:1641
    Avatar

    --
    29 Jun 2009 06:04 PM
    Well, you have a few options with WMI... You can use the PowerShell API, or make your own direct calls to either WMI via managed code or through COM.

    For example, Hyper-V is managed completely via a WMI API...
    Marco

    *Microsoft MVP - Windows PowerShell
    https://mvp.support.microsoft.com/profile/Marco.Shaw
    *Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
    *Blog - http://marcoshaw.blogspot.com
    PoshoholicUser is Offline
    PowerShell MVP, Community Director
    Basic Member
    Basic Member
    Posts:110
    Avatar

    --
    30 Jun 2009 09:20 AM
    Chris,

    Wrapping WMI calls in PowerShell functions (or in advanced functions in v2) is a great practice. Using Marco's Hyper-V example, in the Hyper-V PowerPack for PowerGUI I have written over 30 functions to make working with Hyper-V as easy as working with any well designed cmdlet. Those functions are all visible in PowerGUI so you can feel free to take a look and see how I do that today using v1.

    Actually, so far I have stuck with my decision to write any extension I write for PowerShell in PowerShell itself. That has helped me learn how the language works and I still take that approach today. So far this has been exclusively using functions in PowerShell v1, and while v1 functions are not quite the same as cmdlets you can do a ton with them and get the same experience as you get when working with cmdlets. I'll be converting those functions over to advanced functions for the next little while and that will make them be a little closer to the cmdlet experience. Plus using functions gives people access to source code, lets them step through it and find and report bugs, etc, making it more of a community effort. I highly recommend it.
    Kirk Munro [MVP]
    Poshoholic

    My blog: http://poshoholic.com
    Follow me on Twitter: http://twitter.com/poshoholic
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer