header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

We have a new sponsor!  Introducting Pragma Systems.  See the home page for details.

cmdlet development in other than C# and VB
Last Post 30 Jun 2009 05:20 PM by Poshoholic. 5 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
chris.1234.nyUser is Offline
New Member
New Member
Posts:5
Avatar

--
29 Jun 2009 05:30 AM  
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
ShayUser is Offline
Veteran Member
Veteran Member
Posts:1136
Avatar

--
29 Jun 2009 07:36 AM  
Answered here:
http://www.powershellcommunity.org/Forums/tabid/54/aff/1/aft/3991/afv/topic/afpgj/1/Default.aspx#5485

Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Community Toolbar
Twitter: @ShayLevy
marco.shawUser is Offline
Site Moderator
Advanced Member
Advanced Member
Posts:653
Avatar

--
29 Jun 2009 04:46 PM  
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
chris.1234.nyUser is Offline
New Member
New Member
Posts:5
Avatar

--
29 Jun 2009 10: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.shawUser is Offline
Site Moderator
Advanced Member
Advanced Member
Posts:653
Avatar

--
30 Jun 2009 02:04 AM  
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
New Member
New Member
Posts:94
Avatar

--
30 Jun 2009 05:20 PM  
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.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 footer
footer