PowerShell Usability: Cmdlet design

So I basically haven’t slept in two weeks. I thought it would be a good idea to pick up the torch, and contribute on the NetApp Ontap SDK to PowerShell. I’m sure you’ve seen the Codeplex project by now if not here. I have a couple of personal issues with this first swing, and initially I set out to help. Two weeks later I have completely rewrote the whole cha-bang. I’m not a dev, and I don’t pretend to know as much as Adam. I am however an Administrator who uses PowerShell and NetApp’s every day. From that perspective I’m writing what I need the cmdlets to do. Very quickly I ran into a style issue… My question to the mob is simple of the three examples below, what would be your preference?

[1]PS > Get-NaDisk –disk v0.20| Fail-NaDisk –force

[2]PS > (Get-NaDisk –disk v0.20).FailDisk()

[3]PS > Get-NaDisk –disk v0.20 | set-NaDisk –Fail -confirm:$false

What do you think? One is the most intuitive, but will lead to over 500 cmdlets! Option two is the least intuitive, but would produce the tightest code. Finally option 3 per the PowerShell team documentation option 3 is the “correct way of doing it”…  I wan’t to use option 1 but It requires the use of an illegal unaproved verb “Fail”.



UPDATE: My basis for not using Fail-NaDisk. Although, I believe that Fail-NaDisk is more in line with the spirit of powershell.

2 thoughts on “PowerShell Usability: Cmdlet design”

  1. [1]PS > Get-NaDisk –disk v0.20| Fail-Disk –force

    It follows the cmdlet paradigm that Jeffery Snover set out in his blog, and how most existing cmdlets work.


  2. Glenn,

    I like option #3. The one thing I would change is that the switch for confirm should not need to be set to false. In keeping with how the other cmdlets work, $Confirm should be a switch parameter and its presence be what would set the value to $true.
    I haven’t looked at your code yet, but you should be able to get the -confirm and -whatif built in by setting the ShouldProcess attribute equal to true, e.g. [Cmdlet(VerbsCommon.Set, “NaDisk”, SupportsShouldProcess = true)].

    Good luck!


Leave a Reply