Wednesday, July 18, 2007

PowerShell and the lack of providers

To quote myself and many others: PowerShell is great.

But as additions are popping up all over the place, I think we are heading in the wrong direction.

PowerShell is designed after the Verb-Noun model. E.g. New-Item. If more or less everything was available with a provider - e.g. in a file system like name space - only very few commands are needed. If there were a name space for processes, New-Item could be used to start a process, Remove-Item to stop one etc.

As we are short of provides, the Verb-Noun model gets - let's called it - stretched and names like Get-ADObject (PowerShell Community Extension) and Start-ElevatedProcess (my own script) starts to appear. I call this the Verb-ClassNoun model. Another example: I have created scripts like New-VirtualMachine when I would have preferred to use New-Item on a Virtual Server name space.

Reducing the number of Verb-Noun combinations is important as it makes it easier to learn and use PowerShell.

This situation is much like what happened in DCL (OpenVMS). It started out pretty clean, but as existing command could not easily be overlaid/extended, newer commands got worse and worse. We should prevent that from happening in PowerShell.

So what can we do about it - and is it so big a problem after all?

Let me answer the latter, first: Well, as provides starts to appear, we will change behavior and un-learn Verb-ClassNoun commands. But having to learn a new command to un-learn it later is hardly efficient. Even worse perhaps, will be the need for backwards support for Verb-ClassNoun commands or risk that existing scripts would break when changing to a provider.

So what can we do about it? The obvious is just to go ahead and get those providers created. Luckily, a lot of skilled people are doing that - but that is not a simple thing to do. So how about a generic-scriptable provider, so all the scripters can create providers without having to code?

Can anyone out there create a generic provider that can be implemented in script?

2 comments:

Jay Bazuzi said...

"PowerShell is designed after the Noun-Verb model. "

Don't you mean "Verb-Noun"?

"Get-ADObject " isn't Noun-ClassVerb, it's Verb-ClassNoun.

Anyway, I agree with your concern. Another example is James Manning's cmdlets for TF access, such as Get-TfHistory (http://blogs.msdn.com/jmanning/archive/2007/02/07/simplest-tfs-cmdlet-history-of-a-local-file.aspx).

You're right that the right thing to do is to make writing providers easier. I'd love to see code generators / libraries / guidance / tools that do that.

Per Østergaard said...

LOL - Sure, fixed it.

Thanks for the comment.