Impressions of PowerShell: Taking Buck Woody’s EventLog example further.

This is not quite a PowerShell first impressions article. I’ve toyed with PowerShell a few times before previously. Most notably, I toyed with the PowerShell TFS cmdlets that come with Team Foundation Server Power Toys a little under a year ago. However, I never stuck with it long enough to retain any of the syntax. Recently, I discovered a one liner by chance in Buck Woody’s blog. This lead me to do some serious PowerShell tinkering today. I’m not quite a seasoned PowerShell novice, but I believe I am now on my way there.

So here is the script in question:

Get-EventLog System | Where-Object { $_.EntryType -eq “Error” }

It is a simple one liner to get all the errors in your event log. The main work horse is the Get-EventLog cmdlet. I spent a good chunk of time playing with it.  I came up with a few iterations:

  • Get-EventLog -Log System -EntryType ‘Error’ # Skip the step of piping through the event logs
  • Get-EventLog -Log System -EntryType ‘Error’ -After (Get-Date).Date.AddDays(-5) # Errors From the past 5 days
  • Get-EventLog -Log System | Where-Object { $_.EntryType -eq ‘Error’ -and $_.TimeGenerated -gt (Get-Date).Date.AddDays(-5) } # Alternate one liner to get errors from the past 5 days with Where-Object

I tried several other permutations, most of which did nothing. I will make note of one thing here, which I will delve into more in a followup post. That something is the pipe “|” character. It works almost exactly as any windows or unix command line guru would expect. Namely, it “pipes” the output from the program on the left into the input of the program on the right. However, PowerShell is object based, unlike unix, dos and windows shells, which are based on streams of text. Therefore, you can pipe objects as well as strings with PowerShell. When piping to and from cmdlets, you are piping objects. The examples above that use the Where-Object cmdlet makes the implications of this clear.

One thing to note here is speed of return. One would think that the event log is indexed by date, and that I could reduce my query time by only returning recent entries. Searching the whole event log should be expected when using the Where-Object cmdlet,  since all log entries are being queried and piped to another program. However, one would think that the Event Log would be indexed and the Get-EventLog command written in such a way that only a subset of the log entries would have to be traversed when you specified the -After parameter. However, when you run both examples, the command “hangs” for a bit between the last row output and the command prompt being displayed.

In my next article we will throw grep and less into the mix, and see what happens when we mix object piping with text piping.

Further Reading

Links that will be useful to play around with this stuff.

Charitable development for Unemployed/Under Employed OSS developer.

Microsoft MVP Arnie Rowland was given some MSDN licenses to distribute as he saw fit. He decided to use them to encourage people to give back by doing development projects for non-profit organizations. He also got others to step up to the plate to provide additional prizes. Books, exam vouchers, training, and third party software licenses will be awarded to some of the participants in addition to the MSDN licenses.

Overall, this is a very positive thing. I’m especially excited by the fact that the project criteria states “additional consideration given projects that will be posted on Codeplex with a GPL license.” Its good to know some of this code will have secondary uses.

What bothers me about this program is the primary incentives are software licenses. Don’t get me wrong, I’m not against closed source software. I program on windows professionally, and most of my open source contributions are windows related. I’m aware an open/closed source hybrid ecosystem can be healthy, although I think the industry will tend to go more open source rather than less.  The thing that really bothers me is that you have an entire closed source incentive package that would have no open source equivilant. Here is why:

  • Open source software is free. Even with a model like RedHat, there is little difference between CentOS and RHEL for development. If you gave me a RHEL update subscription for free I’d say, “gee thanks. . .”
  • The books are nice. However books are cheap. No one is going to do a decent sized project for a few books. Books also take up space (unless they are electronic) and time to read. Therefore the answer is not “more books”
  • The only way third party software licenses mean anything is if the software is closed source. There are some closed source software packages for open source operating systems. However, you’re back to closed source providing the incentives.
  • Training and cert vouchers have some potential, but there are also problems I will discuss below.

I see three problem with offering training and certification vouchers for OSS software. First of all, there is not as much advanced formal training in the open source world as in the closed source world. Secondly, the certification costs are cheaper. Beyond the RHCE and BSD certifications, there are no advanced Open Source certifications. Thirdly, the Open Source world doesn’t tend to have as many consultants that offer advanced training. Paul Randal, the author of much of the code in the SQL Server administrative command DBCC, travels around the globe offering advanced training. Linus, Monty, Larry, Guido, etc are not know for offering the opportunity for classroom intensives on the usages of their products. I’d go as far as stating the Paul spends more time leading classrooms then all of them combined.

So offering training might work for the open source community. However, unless you are offering basic certification, you’d be making a custom certification package that you could not objectively put a retail price on, since its not normally available.

Self Motivated Charitable Development

You certainly do not need some kind of software and training stipend to do charitable development if you are unemployed. If you are properly motivated you could find a charity that needs the help, and might even be able to get incidentals like travel and meals reimbursed, and a desk in their office space. That could be important to someone that is unemployed than software licenses.

However, some people, like me, are not the entrepreneurial types. We don’t know how to take our skillsets and frame a pitch of how we can solve a problem to a non technical person. Some people are hard working, but want to be told, “Show up here at 9am. Do this. We get paid Friday’s.” I’m one of those people and the only consulting I do is when it lands on my lap.

Now allow me a moment to present a counter intuitive idea. If these hard working unemployed people are like me, their real motivation is self-education and something to put on the resume. Long term they’d rather support charities by paying $200 for a rubber chicken dinner.  So they want to do work that others will perceive as important, notable and impressive. They will pick a pro bono program which will require them to use expensive professional grade tools, and give them advanced training, as opposed to “done on a shoestring budget using OSS.” They will do this because they want to say, “Look I did this big project that used these expensive tools that were donated because it was such an important cause!”

So closed source wins over open source for charitable development in these cases because of “human nature.”

An evening with a Solaris 10 Appliance on Virtual Box

I have a tolerate/hate relationship with Solaris. I’ve played with it occasionally, and I always seem to spend too much time administering Solaris, giving me less time to solve the problem I intended to use Solaris for.

Recently, I was called in to troubleshoot some mod_perl scripts for a client. The troubleshooting was done over email and I never actually had access to the machine the code ran on. I was asked to do some follow-up, and I wanted to more accurately reproduce the client’s environment. So I asked for the specific OS and perl version. As you might have guessed by the title, the perl code was running on Solaris 10.

So I fired up my trusty Dell Studio XPS, googled around, and found that Sun^H^H^HOracle makes a Solaris VirtualBox Appliance. I already use Virtual Box on my laptop so this saved me some time. Installation was simple, but a few things annoyed me about the process.

Virtual Box Guest Additions

I had to manually install the Virtual Box Guest Additions. The main advantage of this package is to allow your guest OS to run in full screen mode, or be resized to an arbitrary resolution. Oracle owns all the code for the Virtual Box and the Guest OS. There is no reason, legal or otherwise, for them to not distribute their Solaris VM appliance with the Guest Additions already installed.

Security Defaults

My biggest beef here is that the Solaris installer asks you for a root password, and does not allow you to make a non-privileged local user. I prefer the “no direct root login” model of OSX and Ubuntu where all administration is done through sudo. However, Solaris does not ship with sudo installed. Instead, Solaris has something called RBAC that is superior to sudo. I look forward to learning more about this if I am forced to deal with Solaris again.

Lack of /root

In Solaris, roots home directory is / as opposed to /root. This means there is a /Desktop. and other folders in the root of the file system. In retrospect I could have avoided their creation by doing a console login as root after installing the appliance, and making a non-privileged user to log into X with. However, those steps could be avoided with one more install screen for adding users to the system.

Desktop Experience

There was some desktop software preinstalled. Most notably Star Office 8, Mozilla 1.7 and Firefox Star Office 8 is the previous version of what is now Oracle Open Office, the “value added” closed sorce version of Open Office. I can understand being a version behind with Star Office, since it was probably the latest version when Solaris 10 was released. Firefox 2 was probably new when Solaris first came out as well, but I don’t see the need for the old Mozilla suite. There was some good news though. Flash was preinstalled.

I went to youtube to test flash. I discovered that audio did not work. The internet told me there was no Virtual Box sound driver for Solaris and I should install Open Sound System. The audio isn’t perfect, but it works. While most people are not running Solaris as a Desktop, it seems odd to distribute a VM appliance with a browser and flash, and not include sound support. Hopefully Oracle will develop their own sound driver or distribute the Open Sound System one in the future.

Package Management

Solaris comes with a package management system. There is a decent amount of software installed by default. However, certain things linux users would expect like vim are not included. As a FreeBSD person I’ve come to expect my OS to come with a vi that is not vim. Luckily, there is a comprehensive third party repository for Solaris at I followed the directions to install pkgutil, and soon I was using vim.

Service Management

Historically, Solaris has had an rc.d system thats is, in my humble opinion, weirder than the linux and BSD ones. In its defense, it better captures the UNIX “worse is better” Zen simplicity than the linux and BSD init scripts do. However, apparently all good things must be deprecated in the name of progress. While some services still exist in /etc/rc[0-5].d/, many were moved the the Solaris Service Management Facility in Solaris 10. These services are administrered by svcadm and svcs. While I was tweaking the apache config, I became intimately familiar with these commands. Overall I’m quite happy with this innovation. However, I need to develop more competency with it.


Solaris has improved from years past in terms of administrative experience. However it is still as weird as ever. However, its something that has grown on me in years. I acknowledge my conclusion that Solaris is weird is based on the bias that FreeBSD is “normal.”

Analyzing Google Analytics

I though it would be interesting to disclose and discuss some web stats from google analytics. They are taken from 2010-07-04 to 2010-08-04. The numbers themselves are low, but enough to indicate that there seems to be some value in a few of the posts I write. So without further ado:

Page Pageviews
/ 60
/2010/01/28/using-the-registry-to-resolve-visual-studio-reference-paths/ 46
/2010/03/31/jquery-collapsiblepanel-a-collapsable-panel-plugin-for-jquery/ 41
/2010/01/16/sprintf-for-jquery/ 23
/2010/06/21/my-new-favorite-tool-the-far-file-manager/ 21
/2010/07/03/storing-files-in-sql-server-2008-with-filestream/ 15
/outgoing/ 10
/2010/04/05/cassini-is-now-on-github/ 8
/2010/06/29/appcmd-exe-and-his-amazing-superfriends-in-systemrootsystem32inetsrv/ 8
/outgoing/ 7

If you look at my stats from past time periods, the same trends exist.

So the first thing of not is my home page is the most popular page.  The second thing to note is that the next three “just the facts” posts deal with what I consider to be somewhat obscure topics. The third is no one seems to care about the posts where I pontificate. The fourth is that the two outgoing links that show up on the radar both deal with jquery plugins.

I’ve drawn the following conclusions. First, is that jquery plugins are a popular topic. The second is my “just the facts” posts tend to be the most popular. Of course this means I am currently writing an article that few people will read. Third I need to blog more.

Bad Twitter Parodies Imitate the Art the Original Parodied

You have not experienced Shakespeare until you have read him in the original Klingon — Star Trek VI: The Undiscovered Country

I made parodied reference to the above quote in a twitter post I didn’t bother to proofread. Since I have more than 140 characters here I can explain the obtuse reference. I was attempting to 1-up Michael Graziano‘s talk of the bad days of ssh clients on windows before putty. I happened to have filed a bug today with bitvise about WinSSHD‘s sftp behavior when you connect to it with farmanager‘s winscp plugin. Farmanager happens to be developed by Russians, and many of its users are Russian. So the obtuse reference seemed appropriate .

Since I happened to be working on this blog, it seemed like a good idea to expand this into a blog post.  I wanted to verify the original reference and discovered that the Star Trek Quote was a reference to a literary work called Prin. This is in and of itself not remarkable, other than being another example of the literary references in the Star Trek movies. What ties it back to my corny tweet is that the original quote is that Shakespeare must be appreciated in the original Russian. I cannot find the quote, but I want to read the book now. Sometimes I amuse myself by coincidences.