Archive for October, 2007

Normally I post responses as edits at the bottom of a post, but apparently Don Jones was offended by this post, so I figure, as a gesture of peace, I’ll post this as a fresh story, with just a link to the original post and the comments posted by Don and Karl. Apparently Don Jones heard about my blog (someone had to tell him, so apparently he hasn’t heard of the PowerShell Pipe), and he’s taken offense at my criticism …

The frustrating thing is that he’s upset at my post, and yet he lambastes me without even having the decency to mention me by name (or even by nickname :-P) . Although Don says in his blog that I didn’t make “much in the way of actionable, constructive comments” he actually fixed several of my largest concerns, and in his post he specifically addresses most of my remaining issues: specifically detailing the level of relationship between the common members of the community and its paying members, and adding a statement about the 501.3c incorporation. They’ve also fixed my biggest problems with the script repository, (although, the search is still broken — it turns out that it does work, if you click the “Go” button instead of hitting enter). There is a privacy statement at the top of their sign up page now, which I may have simply not noticed missed when I signed up — I’m used to seeing a link for the Terms of Service and Privacy Policy, rather than having a simple statement on the page. I commend Don for keeping that simple.

The clarification of ownership and the privacy statements are vital, ‘cause now I can encourage you to sign up. Actually, signing up is basically a prerequisite for getting anything out of the community, since unlike on this blog where there is an open comment form that anyone can fill out, the contents of which are emailed directly to me (yes, Don, I got your note this morning, thanks) — it really is impossible to provide any sort of feedback on the PowerShell Community site without first signing up. As a personal side note, considering I had already signed up on the community site (despite the lack of a privacy policy), and that he posted a comment on my blog, I’m rather surprised Don said I was so hard to get in touch with. :’(

Now, all of that said, I will repeat three of the things that I said before, which are still true.

I expect this to succeed

In fact, go, sign up now! ShellTools have jumped on board 100% since I last posted, actually shuttering many of their forums in such a way that half my Google searches last night returned hits on pages that no longer exist on PowerShellLive.com (kind of frustrating, by the way). Karl’s started a blog there (no content yet) and is moving everything he can to the new community.

It is a commercial junta

For those of you who don’t speak Spanish, the word junta comes from a Spanish word meaning ‘council’ and it’s use in English refers to governing councils which rule after taking power by force. Don said this:

The community is not a “commercial junta.” The members of the business league do not control community content, only broad direction through an advisory board.

I never said they would control content. In fact, it’s quite clear that those of us being asked to “help” (translation: give them our scripts and answer questions on the forums to build traffic for their website) are the ones expected to provide all of the content, in the form of blogs, taking the time to add links on the community site to any content outside the community, and writing scripts. Nevermind the fact that we were already providing this content on our blogs and various forums already … please come join the central one. We weren’t asked should be in charge. The “business league” sprang upon the scene without so much as a “do you think it’s a good idea” to the community at large (the only people clued in were the MVPs and financial sponsors which were felt to be crucial to it’s success) ... I think it’s quite fair to call it what it is. You tell me: am I wrong? (Oh, in case I’m not being clear, tell me means fill out the comment form at the bottom of this page).

To be clear (especially for those of you who aren’t familiar with Latin American politics and the implication of the word), a Junta isn’t necessarily a greedy dictatorship that interferes with personal liberties — usually you have a Junta as a transitional government with the idea that you will eventually have elections and democratic rule. Sadly, it doesn’t always work out that way — sometimes a Junta gives way to a military dictatorship instead … which eventually leads to another coup d‘état and another temporary military junta … who said politics are dull?

They launched it too early, and with too little content

Personally, I’ve been sort-of waiting for the site to mature before diving in. That’s the answer to the question Don asked: Will you help… or just sit back? When it comes to participatory websites, I prefer to wait until they have some of these glitches worked out and at least have the various sections working before I jump in. I think PowerShell Community (the website, and the amorphous collection of users and developers) could have benefited a lot from a short invitation-only stealth period during which they could have build up some content (scripts, links, imported blog posts … etc) and a structure with “civilian” moderators for the forums, etc. as well as ironed out some of the bugs. It seems to me that they sprang the site out barely formed in order to forestall any other efforts to create a central PowerShell site.

With that as background, I will add that the attitude of entitlement doesn’t help. There seems to be some expectation that since Microsoft and it’s other commercial partners have declared this to be the community site, not only will other sites shut down and join the community for the greater good (farewell PowerShellLive, so long Scripting Answers) but apparently we the users ought to be contributing as well, and ought not to put our opinions on our blogs without first submitting it to their forums. All I’m saying is: eventually this expectation of participation may be realistic, but you’re not there yet.

My point is: just because you pay a prominent MVP to run the site, and convince all of your partners to join a business league doesn’t automatically mean the site deserves effort from the rest of the community — particularly when it’s easier to continue doing what we have been doing. Honestly, I figure that posting my opinions on my blog is at least as helpful as posting in the community forums, since my review post will actually boost their PageRank™ ;-) My original post was a gut reaction on the first day the place opened, and honestly, I thought that they’d appreciate the link, even with negative feedback. I guess I was wrong.

More ideas

I’ve posted a comment on Don’s blog, but it’s the last time I’ll do that until they remove the captcha that asks me to prove I’m human every time I post a comment — even though I’m also required to log in as a member of the community first. That’s just adding annoyance on top of roadblocks, and makes me assume they don’t really want to get feedback on their blogs anyway.

Now that the script vault on the community site is improved, I’ll probably be submitting some of my scripts on their site too, just to help people out — although I take a bit of a dim view of the fact that scripts I post there have to wait for a moderator before they show up. So many roadblocks …

I’m unlikely to submit links to their links section just because quite honestly, I’m lazy, and I feel that putting links in my delicious and diigo sites (not to mention Furl, Blinklist, Simpy, etc) or linking them from my blog is more than enough effort to help people find things (after all, how many people browse community link lists instead of using Google when they’re really looking for something). I would be willing (if asked) to help develop a tool to automatically include links from delicious (which has a ton of links, but isn’t moderated) or from the Diigo PowerShell group which I already moderate (and would be more than willing to let Don or others also moderate) ... That seems like the best way to manage link collections to me — since Diigo has tools for moderation and for link submission that are built into the browser as extensions.

I have only one thing to say about coverflow.

The LOOK of coverflow, and it’s complete lack of integration into the LOOK of … well, anything else in finder, frankly…. just reminds me of Monty Python’s credits: “completed in an entirely different style at great expense and at the last minute.”

So, Brandon owes me for this one … he had a problem with the Start-Demo script posted by the PowerShell team because when you try to assign output to a variable (eg: $fileInfo = ls | gm) it would spew it to the host instead. At any rate, I fixed it up for him (for reasons that escape me now), and since I didn’t bill him for the work,[greedy] I might as well share it with all of you for free too, to spare you the same frustration [pullhair].

If you’re not familiar with Start-Demo, it’s a script which basically takes another script and steps through it with pauses. It lets you step forward and backward through the script and even suspend it so you can execute commands in a nested prompt. Now, it has a few more features, and a few more comments to make it a little easier for others to hack in the future.

I actually changed several of the shortcut keys, but they just made more sense to me this way. I also changed the way the input is handled to ReadKey rather than ReadHost so you don’t have to hit ENTER except to run the command … hopefully you’ll find this makes demo smoother to run. To make it less jarring on my setup with my custom prompt, I made the various colors used in the script settable. I also added a few options so that you can even run it fully automatic with a settable pause between commands.

Anyway, I posted the code to the PowerShell Central Scripts repository (where I’ll post any improvements I make in the future), but I’ll post the current version here as well. (more…)

I wrote a post last week about how to write functions for use in the PowerShell pipeline and I’ve been using the template I wrote in that post as the basis for several of my other scripts … and I’ve been gradually fleshing it out, and improving it, so I thought I’d drop it here with all of it’s inline comments. Hopefully that will be better than what you would get if I just trying to explain it in a blog post :).

Incidentally, this script is also on PowerShellCentral scripts Repository where I will probably post any future modifications … (more…)

The Microsoft-funded PowerShell community site was launched over the weekend, complete with 501.3c non-profit status and everything. Of course, in reality it’s a joint venture between Microsoft and Sapien, with Don Jones at the helm and Microsoft MVPs as the only other contributors at this point (where “contributors” is loosely put — they’ve made the mistake of not making sure they had lots of content available at launch, so the script repository has things like this one liner … Copy-Item $Profile "$(split-path $profile)profile-backup.$((Get-Date).ToString(’MMddyyHHmmss’))" with a five star rating ;).

There’s no community quite as easy to build as a commercial junta, I guess. Several major commercial players are on board — even the upstart ShellTools has lent their logo in support. One must assume this will succeed to some degree … especially since Microsoft has been MVP-deputizing all the big PowerShell bloggers who’s support will determine whether this will remain an empty site where these commercial backers can get some extra advertising, or will actually become a true “community” site with active involvement from people without financial incentives ;).

On the down side, PowerGadgets (among others?) is conspicuously missing, and it remains to be seen if these guys can all play nice with each other. They are, after all, competing in a couple of PowerShell-enhancement spaces, and I haven’t yet seen any sign that any of them are going to shut down their (Microsoft | ShellTools | Sapien) PowerShell forums and route traffic to the “community” site. I also can’t find an RSS feed except on the individual blogs (and so far, only Marco Shaw seems likely to actually blog there).

One last thing, which I was at first not going to say, but after surfing the “blog” section and forums and finding them decorated the same way, I can’t hold back: That is quite honestly the ugliest web site I’ve seen in a while. It’s roughly the color of the swirling brown stuff in the bottom of the toilet after you throw up, and there’s more bits of scrolling, pulsing, and throbbing flash and javascript than I’ve ever seen outside of MySpace.

Update

It turns out that Sapien (Don Jones’ company) is, in fact, going to close their PowerShell Forum and move their PowerShell-related blogging to throw their whole weight behind this new site. So that means all three of the Bloggers listed on PowerShellCommunity.org will be actually blogging there. Nevermind that this makes it look, for now, even more like a Sapien spin piece than an community-driven site, it’s certainly a guarantee of some success, since one presumes that some of the traffic on the sapien forum will actually move to the new location, and all of these guys have been fairly consistent bloggers.

Update

Well, just for the record … I’ve been flipping around on the “community” site and I have a few more gripes. :( There is a script repository, but it’s not searchable, it’s practically empty, has no download links, and displays scripts double-spaced and without highlighting. Plus, posting scripts requires registration — on a site which as yet has no privacy policy and appears to be partially owned by Microsoft ;-) (there was a rumor about a 501c non-profit, but there’s no trace of that on the site, even on the “About us” page which merely says it’s run by Don Jones —an MVP, author, speaker, blogger and corporate ).

Just for kicks, compare their scripts page to the PowerShell Central Scripts site (note that I help out with PowerShell Central, and it’s independently run by Brandon Shell (another MVP) and also has no privacy policy, but then, it doesn’t require you to sign up). Oh, and for now you can access the scripts interface directly … but don’t tell Brandon I told you about it ;-)

Feedback Works

They’ve fixed a lot of these problems

[new] Update, I created a better version of a pipeline function for powershell

Every once in a while the question of how to best use the process block of a function to process pipeline objects comes up on IRC, and although I’m sure others have already written this up on the web in the past, we’ve been polishing up this example sending it back and forth to each other for a couple of weeks, and it seems to me it’s about time to publish it a little more prominently.

The basic idea was to write a function that could be used to process a set of inputs from either the pipeline or an argument, while still allowing other arguments to be passed and processed. This is something that’s very easy for a cmdlet, because you can specify that a certain parameter will receive pipeline input (and even control which attribute of the objects on the pipeline will be used), but in a script it’s not really supported. In addition, we require that the function process items as they come in, rather than waiting until it’s received all input before processing them.


function Test-Pipeline([switch]$inputObject,$io) {
    BEGIN {
        if ($inputObject) {$io | &($MyInvocation.InvocationName) $args; break;}
      $args = @($io) + $args
        Write-host "Begin $args"
    }
    PROCESS {
        write-host "PROCESSME: $_"
    }
    END {
      $x = 0
      $args | % { $x++; "$x - $_" }
       Write-host "End"
    }
}
 

Some explanation

This is just an example method, it doesn’t really do much, except that it outputs exactly the same thing whether you call it like Test-Pipeline -inputObject "Foo","Bar","Baz" "Kill Each Process" or like: ""Foo","Bar","Baz" | Test-Pipeline "Kill Each Process".

It works by calling itself with the inputObject argument passed on the pipeline when you specify it as an argument, so that code is processed exactly right. This means that the first line you see in the process block must remain the first line, even if you add additional code to the block.

We use a trick to make sure that additional unnamed parameters work normally by using a switch parameter -inputObject followed by a second parameter $io which we treat as inputObject if inputObject is set. This works because switch parameters don’t expect values, so we’re able to sort-of hijack it to emulate the cmdlet behavior. Note that if it is not set, we move the value of the $in parameter into the $args array which contains any additional parameters. This arrangement allows it to behave rather like a cmdlet would, but it’s a little delicate: if you’re going to pass input objects, you must specify the switch as the first argument, and pass the $io (inputObjects) immediately following (as though they were the value of the inputObjects parameter). All of that is necessary so that we can optionally pass additional parameters.

You can also add additional named parameters — but you would need to either always specify their names when you called them, or carefully adjust the code so that they get shifted if -inputObject isn’t specified.

Here’s some sample output, in case you’re wondering:


PS> $foo = "Greetings","Earthling"
PS> $foo | Template-Pipeline "Hello" "World"
Begin Hello World
PROCESSME: Greetings
PROCESSME: Earthling
1 - Hello
2 - World
End
PS> Template-Pipeline -in $foo "Hello" "World"
Begin Hello World
PROCESSME: Greetings
PROCESSME: Earthling
1 - Hello
2 - World
End

 

Credit where it’s due

I wanted to officially acknowledge that /\/\o\/\/ and Gaurhoth and Oisin and Brandon have all contributed to the polishing and testing of this script in various forms … thanks to all ;-)

From last friday:

Acting on the advice of the License Approval Chair, the OSI Board today approved the Microsoft Public License (Ms-PL) and the Microsoft Reciprocal License (Ms-RL). The decision to approve was informed by the overwhelming (though not unanimous) consensus from the open source community that these licenses satisfied the 10 criteria of the Open Source definition, and should therefore be approved.

Not much to say about that, except: about time! (oh, and thank goodness Richard Stallinman isn’t in charge of the OSI).

The hard drive in my development box died last week, and although I’ll spare you the story of the replacement process, I thought it might be interesting to document the process of rebuilding my dev box, and provide color commentary while I’m at it.

  1. Install Windows Vista (Business)
  2. Get domain admin (my boss) to log in and connect my machine to the domain
  3. Add my domain account as an administrator
  4. Log out and log back in as my domain accout (it’s important to do this ASAP or I end up with shortcuts and things in the ‘root’ user account).
  5. Adjust Windows settings (via “Programs and Features”) to include the IIS Features required for SQL Reporting services (*). I had to add the “Basic Authentication” to this list, I think, and I changed a few other features while I was in there … this actually required a reboot for some reason (presumably not because I added minesweeper and solitaire).
  6. Install Windows PowerShell (in hopes of doing other things faster)
  7. Create User Account for Sql Server to use
  8. Install SQL Server (before Visual Studio, to avoid SQL Express and the resulting lack of SQL Manager)
  9. While waiting for that, slow it down by copying my Projects, Documents, and Pictures folders over from the backup … I need my PowerShell profile and wallpaper before the defaults drive me insane.
  10. Change my wallpaper and avatar (that orange flower is actually annoying).
  11. Install Notepad++ (and copy userDefineLang.xml from backup for PowerShell scripts)
  12. In order to finder Change Explorer settings to:
    1. Show Hidden files and folders
    2. NOT Hide extensions for known file types
    3. Hide protected operating system files (I leave this, because Vista has tons of hidden junction points (for compatability) in my user directory which are very distracting)
    4. Launch folder windows in a separate process (Explorer still crashes sometimes in Vista)

Some side notes:
I’m actually capable of compiling most of my projects (using MSBuild on the command line) without installing SQL Server, and the rest of them require third party controls which I will not install until after Visual Studio is installed. However, having installed SQL Client, Notepad++ and PowerShell I can actually edit, recompile, and run queries via PowerShell … so in an emergency, at this point I can start fixing bugs ;)

Windows Vista, SQL Server, Visual Studio, and MS Office all want me to go online and check for service patches as soon as I install them. Since I feel fairly secure sitting behind my firewall, I don’t bother with this until all of them are installed — Microsoft Update will find and install all of the service packs in one fell swoop.

SQL Server and Visual Studio are the only two apps I install which have installers which are so badly behaved that I don’t even try to install them in my usual sub-folders (C:\Programs\DevTools\ in this case).. SQL Server, for instance, will make a “C:\Program Files\Microsoft SQL Server\” folder no matter what you tell it during install, and nothing I’ve found can convince it to do otherwise, so I might as well install to that location, and not end up with multiple confusing folders (I’ll make junctions in C:\Programs\DevTools\ later to keep myself sane).

More Software (more…)

Brandon and I have been talking a lot about error handling in #PowerShell (on irc.freenode.net) the last few weeks, going back and forth (and dragging half the other channel participants into the discussion) with examples and counter examples and trying to make sense of how it’s supposed to work, and how it really does work. I’m sure he’s about to write about TRAP from the perspective of a sysadmin, but I thought I’d throw out this post as a complement to his — from the perspective of a programmer.

The biggest problem with error handling in PowerShell is an almost complete lack of documentation. Neither the trap statement or the throw statement even have about_ documents in the powershell help system, nor do they have pages on MSDN (that I can find). In fact, it’s so bad that I’ve been known on the IRC channel to accuse the PowerShell developers of deliberately not writing documentation so that they and the various MVPs could make some extra cash selling books about PowerShell. ;) Despite that, we’ve been able by trial and error to deduce how these things work, and hopefully this explanation will help some of you come to a better understanding of how you can use error handling in PowerShell. (more…)

This is just a short post to announce that I’ve created a Yahoo! “pipe” aggregating the latest PowerShell related posts (in chronological order) from a whole bunch of different PowerShell blogs. I won’t list them here, because they are listed on the pipe page, and I don’t want to have to maintain the list twice …

PowerShell Bloggers – The Yahoo! Pipe

If you know of a PowerShell blog which you think should be added to our list (even if posts on it are infrequent) please feel free to drop me a line using the comment box. In fact, if you think I’ve linked to the wrong feed for one of the ones I did include, or if you would like to have your blog removed from the list … feel free to drop me a line for that too.

By the way, for those of you who are interested in these sort of things: the rationale for creating and using a pipe rather than simply subscribing to each individual feed is pretty simple:

  1. The pipe filters out posts which aren’t about PowerShell, and lists at most two weeks worth of content
  2. The pipe merges posts into chronological order for use in web syndication
  3. Hypothetically, the pipe gives me the ability to include sites which don’t have RSS feeds (more on that some other time)