Playing iTunes .m4a Files on a Squeezebox2

May 30, 2010

I encountered a problem playing iTunes .m4a files on Squeezebox2 devices. It was interesting that from the same Squeezebox Server the files played fine on a Squeezebox3, but when attempting to play on a Squeezebox2 an error appeared on the Squeezebox Server’s Web interface, “Problem: Can’t open file for: <file>.m4a”. Other files, such as .mp3 filetypes, played fine.

I validated that the .m4a file existed in the music directory and there were no permission issues. To troubleshoot the problem I activated debug logging for os.files, os.paths, player.source, player.streaming, and scan.scanner and then restarted the Squeezebox Server; the logging messages were recorded in the server.log file. The problem was straightforward:

Slim::Player::TranscodingHelper::checkBin (242)   Found command: [faad] -q -w -f 1 $FILE$ | [lame] –silent -q $QUALITY$ $BITRATE$ – –
Slim::Utils::Misc::findbin (100) Looking for executable: [lame]
Slim::Utils::Misc::findbin (111) Checking for lame in /usr/share/squeezeboxserver/Bin/i386-linux/lame
Slim::Utils::Misc::findbin (111) Checking for lame in /usr/share/squeezeboxserver/Bin/lame
Slim::Utils::Misc::findbin (111) Checking for lame in /usr/kerberos/bin/lame
Slim::Utils::Misc::findbin (111) Checking for lame in /usr/local/bin/lame
Slim::Utils::Misc::findbin (111) Checking for lame in /bin/lame
Slim::Utils::Misc::findbin (111) Checking for lame in /usr/bin/lame
Slim::Utils::Misc::findbin (111) Checking for lame in /usr/bin/lame
Slim::Utils::Misc::findbin (111) Checking for lame in /usr/local/bin/lame
Slim::Utils::Misc::findbin (111) Checking for lame in /usr/libexec/lame
Slim::Utils::Misc::findbin (111) Checking for lame in /usr/sbin/lame
Slim::Utils::Misc::findbin (130) Didn’t find binary for lame
Slim::Player::TranscodingHelper::checkBin (265)    couldn’t find binary for: lame
Slim::Player::TranscodingHelper::getConvertCommand2 (421) Error: Didn’t find any command matches for type: mp4

So it seems that lame is needed to stream music data from an m4a file to a Squeezebox2 device. (But lame is not used when streaming music data to a Squeezebox3. That’s interesting too.)

I needed lame for Redhat Linux, it’s an open source project maintained on SourceForge here. After downloading the source, run a ./configure, make, and make install. And that fixed the problem.

Move Messages to Folders with Outlook VBA

March 27, 2010

Let’s say your email management approach is to save important messages to a folder other than your Outlook Inbox. You might save messages from outside vendors to a folder named “Vendor Documents” or messages related to corporate policy to a “Policies” folder. Here’s an Outlook VBA macro that helps to file those messages from your Inbox in a single click:

Sub MoveToFolder(folderName)

 mailboxNameString = "Mailbox - Firstname Lastname"

 Dim olApp As New Outlook.Application
 Dim olNameSpace As Outlook.NameSpace
 Dim olCurrExplorer As Outlook.Explorer
 Dim olCurrSelection As Outlook.Selection

 Dim olDestFolder As Outlook.MAPIFolder
 Dim olCurrMailItem As MailItem
 Dim m As Integer

 Set olNameSpace = olApp.GetNamespace("MAPI")
 Set olCurrExplorer = olApp.ActiveExplorer
 Set olCurrSelection = olCurrExplorer.Selection

 Set olDestFolder = olNameSpace.Folders(mailboxNameString).Folders(folderName)

 For m = 1 To  olCurrSelection.Count
    Set olCurrMailItem = olCurrSelection.Item(m)
    Debug.Print "[" & Date & " " & Time & "] moving #" & m & _
                ": folder = " & folderName & _
                "; subject = " & olCurrMailItem.Subject & "..."
    olCurrMailItem.Move olDestFolder
 Next m

End Sub

Some customizations are necessary to make this all work for your email system. First, copy-and-paste the program to the Visual Basic Editor in Outlook (which you can open with Alt-F11). You’ll need to create a new VB Module (use the Insert->Module menu choice) to hold the macro if you don’t already have custom Outlook macros defined.

Second, the text highlighted in the blue bold font needs to be edited for the name of your Exchange mailbox; you can usually find the name of your mailbox on the left side of the Outlook window at the top, it starts with “Mailbox” like in the example above.

Third, you’ll need to add other VBA macros which call the MoveToFolder() macro with the correct folder name passed as  a parameter. For example, we might create two additional macros one each for the Vendor Documents and the Policies folders; the macro for Vendor Documents might be called MTV() and the Policies folder macro MTP():

Sub MTV()
 MoveToFolder ("Vendor Documents")
End Sub

Sub MTP()
 MoveToFolder ("Policies")
End Sub

(Note, the destination folders should already exist in your Outlook folder list.)

The last step is to assign the macros to Outlook toolbar buttons so you can move the selected messages in your Inbox to the appropriate folders with a click. If you’re managing multiple destination folders, and you created multiple macros (one for each folder), you can also create a new toolbar to organize all your MoveToFolder() macros. Here’s a Microsoft Knowledge Base article that describes how to assign Outlook VBA macros to toolbar buttons: How to Assign a Macro to a Toolbar Button.

The MoveToFolder() macro will work on a single selected message, or a group of messages selected in a sequential range (with a Shift-Click), or a non-sequential range (with Ctrl-Clicks). Also, an activity message will be written to the VBA Editor’s Immediate Window (which is opened with Ctrl-G) so you can go-back and view MoveToFolder() activity. A total win for email convenience, give it a try.

Corporate Practice

November 1, 2009

As managers we work hard at choosing the best individuals for a job. We write job descriptions, conduct searches, and choose the best people we can find (the best educated, the most experienced, the best trained) for the roles in our groups. But having the best individuals doesn’t automatically create better teams. Managers are constantly challenged with the inefficient and inferior results that develop by people working as individuals, not sharing information, and not collaborating with colleagues. Conducting work in silos ultimately hurts innovation.

Why is collaboration so hard, why is it an unnatural way of working for most individuals? Kent Beck has a perspective on the situation in his book Extreme Programming Explained: Embrace Change. As Beck views it, the influences for individual performance start with our very early academic training and the typical reward systems found in the work environment:

It’s hard to collaborate. Our whole education system is tuned to individual achievement. If you work with someone on a project, the teacher calls it cheating and punishes you. The reward systems in most companies, with individual evaluations and raises (often cast as a zero sum game), also encourages individual thinking.

(Quoted from page 152 in the first edition of the book.)

The analogy (or thought experiment) that I sometimes like to use is about a professional baseball team. In the Majors players are selected to be the best in their positions. The process of scouting players, training them through the minors, and bringing them up to the Major League teams has been very well developed over multiple decades. The players chosen for the Majors are the best and the most skilled in their individual positions; the best pitchers, catchers, fielders, etc. You can’t find better individual players than those that are chosen to play in the Major Leagues.

Yet, the manager of a baseball team requires practice. Then the question that develops is, if the players are the best and the most skilled, why is practice necessary? And the answer, which isn’t immediately obvious to many people, is that practice is necessary to make a better team. Practice is working together, collaborating, allowing a second baseman to know the throwing habits of a catcher when trying to throw-out a runner stealing base, for example. Practice is when a first baseman learns the nuances in the step of a pitcher when he is about to throw to first base. Or when a shortstop learns to cover for the second baseman who is fielding a right-side grounder. The perspective on practice and what teams do during practice is what makes a baseball manager great, what creates great teams, and ultimately what distinguishes one team from another in the Major Leagues.

If you connect with that analogy, if you find that you are dwelling on the idea more as a thought experiment, there is one last question to consider to tie it together with the corporate world: What is the analogy to “practice” in a company made-up of knowledge workers?

“Meetings” in a corporate setting are the equivalent of practice. Meetings imply collaboration because they require more than one person. Meetings are where perspective develops across teams, where information is shared and judgment is improved across individuals, where people learn the nuances in the capabilities (or limitations) of other individuals. Meetings, even if viewed as ad-hoc discussions between two individuals, are where better teams are ultimately created. And like practice in baseball, meetings are a manager’s best tool to drive collaboration, to create higher performing teams, and ultimately to develop excellence in an organization.

Note, this posting was motivated by Issac Sacolick and the Social, Agile, and Transformation Blog. See Issac’s post and the dialog that developed in the comments section for additional background:

When Ogranizational Silos Hurt Innovation

Communicating for Quality

October 12, 2009

While in Los Cabos, Mexico we stayed at an excellent hotel named the Hoteles Marquis. Like all memorable hotels the Marquis has a terrific location right on the Pacific coast, it’s buildings are beautifully architected, and their service is top-notch and high quality.

Decisions of location and architecture are strategic and discrete; those decisions are made upfront and you go with them through the life of the hotel’s property and business. Service, however, is different. It is obviouly hard to develop a high quality service and service is on-going, it’s something that you constantly work on.

One morning at the Marquis we were waiting around in the hotel’s outdoor lobby for a bus to take us to an ATV adventure through the Mexican desert and coast. I was having coffee at the top of a short flight of stairs that led to a stone and tile landing connecting another flight of stairs. A young man working for the hotel and sweeping the landing part caught my attention.

At first the floor didn’t appear dirty to me. He was using a wide angled broom to collect the dirt and sand into small piles that he later swept into a stand-up dust pan that had a long handle. He worked meticulously, using the longer part of the broom to clean the corners where the landing met an adjacent wall. And he worked thoroughly, sweeping each area multiple times until he was sure that part of the floor was completely clean. He was also organized and he was methodical covering every square inch. I was impressed.

For a moment I wondered how his managers at the hotel might have trained him to be such a great sweeper. They could have shown him to use the angled edge for corners and to think in patterns so he got the best coverage. Maybe his manager worked with him a few times and then periodically watches him work to make sure he’s keeping-up with the service quality standards of the hotel. But in fact I don’t think that’s the way they do it. That young man was too detailed and too passionate about the way he was going about his work. Instead I think the only direction he got from his managers was to make the floors beautiful for the hotel’s customers and guests. And the young man tirelessly dedicated himself to deliver the best quality he possibly could to his job.

Unstressing Your Life, Wirelessly and in Stereo

July 3, 2009

I bought a Jeep Liberty in 2006 and toward the very end of deciding its color and the features I wanted (and didn’t want), and almost on a whim, I asked the salesperson to throw-in the Bluetooth wireless hands-free connection. It was about a $250 option that I actually didn’t feel was necessary at the time but I like technology and gadgets and adding it didn’t break the bank. I expected that it would be a fun feature to play around with, but I wasn’t really too hopeful about its usefulness; I figured it would end-up being a novelty.

So now after more than three years of driving the car and using the Bluetooth hands-free feature I can report to you from experience that it’s a life changer (or at least for the part of the time that I spend my life in the car). With Bluetooth, Jeep/Chrysler calls it UConnect, you can setup your hands-free capable cell phone, Blackberry, iPhone, etc to automatically connect to the car whenever you turn the key. Gone are the days of untangling wired headsets while driving, searching pockets, or bags, or dashboards for your cell phone when it rings, or worrying about the police when you’re talking on the phone without a headset. You can answer a call without touching the phone, and you can make a call without having to take your eyes off the road to dial a number. (Although I’ve gotten quite good at drive-typing over the years, I think I can thumb-out about 25 words/minute on a Blackberry while steering with a knee.) Having UConnect has definitely changed my driving experience in a positive way, and I mean that with all seriousness since I cruised more than 25K miles/year on average in the Jeep so far.

I recently upgraded my original version (2G) iPhone to the latest iPhone 3GS and I connected the new iPhone to the UConnect in the Jeep and it works great, just like the old iPhone did. But the new iPhone, and really the latest version of the iPhone software, version 3.0, includes a Bluetooth capability that supports wireless stereo headsets. (The technical name of the Bluetooth stereo headset feature is called Advanced Audio Distribution Profile, usually abbreviated A2DP. It’s not proprietary to the iPhone and you might find A2DP on your whatever-model phone if you have a newer one that supports it.)

Based on my experience using Bluetooth hands-free in the car, the wireless stereo headset feature just might be one of the most underpublicized and undervalued features of the iPhone 3.0 software. To check it out I bought a low cost (about $29) Bluetooth stereo headset from Insignia; here’s a link to the model:

Connecting (which the Bluetooth process calls “pairing”) the Insignia headset to the iPhone was a little tricky because you have to press a button, wait for some beep sounds, then some red and blue blinks, and enter a security code into the iPhone, but I followed the directions that came with the headset and it all worked out Ok.

So the cool thing about this now is that you get a wireless stereo headset to listen to your iPod. When I’m commuting (which is over 2 hours/day), or at the gym (which is probably less than 2 hours a week), or other times I use an iPod (listening to audio books or podcasts), it’s wireless and it’s in stereo, and just like in the car there is no more frustration with juggling/finding/untangling or yanking out wired headsets. And the audio quality is really good (especially considering it’s wireless).

Unfortunately the UConnect in my Jeep doesn’t have the right version Bluetooth to do A2DP, but wouldn’t that be awesome to play music wirelessly and in stereo in your car right from your iPhone or iPod. Or wouldn’t it be cool to stream music by Bluetooth directly from your iPod to your stereo at home. I guess that will all be coming in the future.

Although A2DP doesn’t work on an original 2G iPhone, it’s supposed to work on the standard 3G iPhone with the 3.0 software version, so if you have that model try it out.

If you’re wanting to unstress your life in a similar way, here is some more information for you. MacWorld Magazine published a thorough review of A2DP support in the iPhone software update which you can read here at this hyperlink:

And here’s some technical background on the A2DP Bluetooth capability:

A Creative Look at Pair Programming

March 15, 2009

I follow John Mayer the singer and songwriter on Twitter. Besides being a fan of his music, on Twitter Mayer (@johncmayer) is creative, funny, and he provides some transparency into his musical projects which are interesting. Mayer also writes the Battle Studies Mid-Action Report blog where he uploads videos and photos that are referenced in his Twitter postings.

A few days ago Mayer made a statement on Twitter, in @reply to a question from a follower, which I found intriguing. He replied:

I still write in front of a mirror.

You can view the full post, which also includes the original question here.

I was struck by the statement since, for me, it is completely counterintuitive to what you would expect the creative writing process to be. Writing is a very intellectually internal process. You typically hear of writers having a quiet workplace in the woods, or in an attic, separated from people and activity in order to create an environment to be alone with yourself and your thoughts. The process of creating words from thoughts, emotions, or feelings (whatever they may be) is usually considered to be a very individual process requiring deep introspection and contemplation achieved by developing an ability to see yourself from within.

So, I would think that writing in front of a mirror is opposite to being introspective. To me it seems as close as you can get to introducing a second person into the process without having someone else in the room. The mirror then is a tool to externalize the creative process, to forcefully move creativity outside of yourself, or possibly an attempt to see yourself as someone else in order to develop a collaborative process when there is only one person involved. That scenario is so contradictory to the way that I think about creative writing, it is so out-of-the-box and unexpected, that I frankly find it brilliant.

There is also a creative process that occurs in software development and programming. I’ve always related to the description that Fred Brooks gives of the software development process in his book The Mythical Man-Month. Brooks, referring to the book The Mind of the Maker by Dorothy Sayers who identifies creativity with three stages, the idea, the implementation, and the interaction, says:

A book, then, or a computer, or a program comes into existence first as an ideal construct, built outside time and space, but complete in the mind of the author. It is realized in time and space, by pen and ink, and paper, or by wire, silicon, and ferrite. The creation is complete when someone reads the book, uses the computer, or runs the program, thereby interacting with the mind of the maker.

Brooks then goes on to describe computer programming using the short phrase:

The programmer builds from pure thought-stuff.

The statement describes a computer program being built (or developed, created, written) from the thoughts (or ideas, concepts) of a single individual.

Several years ago, and together with a close colleague, we implemented the eXtreme Programming (XP) software development methodology at The methodology was popularized by its author, Kent Beck, in the book eXtreme Programming Explained: Embrace Change. The premise behind XP is to take all the things that people generally consider to be good for creating quality software and to do those things to the extreme. For example, everyone generally considers testing to be directly related to quality; the more you can test a program the fewer errors it is likely to have. So in XP testing is done to the extreme by writing the tests for a program before the program is actually written. The “test first” approach, or sometimes called “test driven development,” can be viewed as being radical by someone who is used to working in a more traditional software development methodology where tests are written after the program is created.

Another principle of XP usually considered to be radical is “pair programming.” When pair programming two people sit together to write a program. In XP Explained Beck describes pair programming as follows:

Pair programming is a dialog between two people trying to simultaneously program (and analyze and design and test) and understand together how to program better. It is a conversation at many levels, assisted by and focused on a computer.

When I was first learning about XP I clearly remember having a deep and surprising reaction to the concept of pair programming: How can something as personal as writing software, transcribing my thoughts, my concepts, and my ideas, my pure thought-stuff, be shared with someone else simultaneously? How is it possible that writing a program, which can be an intimately creative process for an individual, can be accomplished by working with someone else? For programmers who haven’t done it before, the concept of pair programming can be radical, out-of-the-box, and counterintuitive, which was exactly my initial reaction to Mayer’s statement about writing in front of a mirror.

Pair programming introduces a second party into the creative process. It’s an activity that forces you to communicate, to share and verbalize your thoughts and ideas, and to collaborate in a completely different way. When pair programming, someone else, a second person, is there with you while you’re going through the activity of creative expression. Both people experience intellectual and personal benefits as a result of that collaboration and there are significant benefits to the overall quality of the product, the computer program or the software application, they produce together.

If writing in front of a mirror, as Mayer does, has a similar effect to introducing a second person into the creative process, then the mirror becomes the tool that enables Mayer to “pair program” with himself. Mayer is generally considered to be a gifted artist and it would seem that he is leveraging the pairing concept to make himself, and his art (his music), better.

Knowing that Mayer uses a mirror in the writing process makes the pair programming concept appear less radical. Perhaps when we work alone we limit the expression of our creativity to our own individual experiences. Perhaps collaboration with another person, the second person effect, is required to really broaden the possibilities of our own individual creativity. And perhaps when we pair program to create computer software the second person is really the mirror.

The Most Overlooked Feature of Twitter

February 22, 2009

Often times when someone new follows me on Twitter I’ll usually spend a few minutes going through their timeline to learn about their background and interests. I’ll also read timelines for new people I encounter in @replies or retweeted messages. In addition to a person’s timeline, I recently started reading through Favorites which, in some cases it seems, is a better way to learn about someone.

But the information you’ll find in Favorites is sort of hit-or-miss. I did a quick (and very ad hoc) survey of how Favorites are used by the people I’m following. My observations are that Twitter “celebrities” (ie, those people who have a very large follower base and generate hundreds of tweets) have a very low percentage of Favorites compared to their total tweets. Which is understandable, I guess, since tagging a tweet as a Favorite takes time and their purpose in using Twitter is most likely broad communication for marketing- or evangelizing-type purposes. The reputations of the people in the celebrity group usually proceeds them anyways, so it would seem that their Favorites would be less useful for learning more about who they are.

For the non-celebrity group, say those people with a few hundred followers and who tweet with much less frequency, I found that it’s 50-50 on whether you’ll find Favorites of any value. It seems that most people have tried Favorites as a feature but don’t keep-up with the idea. That’s too bad since I think Favorites can offer a lot of potential if used in the right way.

Twitter has developed Favorites so that it’s public; people can see your list of Favorite tweets even if they’re not logged into the service. Therefore, it’s important to think about how you’re using Favorites. Do you favorite tweets so you can remember or archive them? Have you thought about the tweets that you’re tagging as Favorites from the perspective of someone visiting your Twitter profile, and how that information might be useful to summarize your interests? Or maybe you’re not effectively using the Favorites feature and there’s really nothing meaningful for anyone to see; if that’s the case then you could be getting a lot more value out of the Twitter service by rethinking your approach.

Favorites is a much less talked about feature of Twitter but its potential, when it’s used properly, could be significant. Your Twitter Favorites can summarize your interests and can highlight to your followers and the Twitter public those ideas, concepts, and thoughts expressed through Twitter, by you and by the people you’re following, that you find meaningful and important.

Favorites are a very important part of the Twitter feature set and to leverage it you’ll need to take a little extra time to pick appropriate tweets for your Favorites list. In addition, think about linking to your Twitter Favorites page from your Website or blog so that people in your community can have a convenient way to find the information that you’ve flagged as important; I created a link to my Twitter Favorites on this blog page to make that information more accessible. And if you’re looking for ways to make Twitter more useful, improve the way you’re currently using the Favorites feature.

What’s the Difference Between Development and IT?

January 25, 2009

For anyone in the technology management business that should be a very obvious and simple question to answer: Development is about programming and creating software applications and IT is about installing and managing servers and networks. While those are true and accurate differences, there is less value in obvious and simple answers and what we really want is something more meaningful. What if we’re looking to understand the nature of the processes used to manage development and IT functions and how those processes are different? What if we’re looking for the influences that make an application developer’s job different from a system administrator’s? How would you respond from that perspective?

Broad and open questions are really meant to be debated, but let’s try to put a stake in the ground and consider a response; so here’s one perspective. When Developers interact with end users it’s to define a new feature in an application. Usually a single end user or a single business group owns the definition. Once the feature is understood and defined, a developer creates the feature and delivers it to the end user after some period, usually on the order of days, weeks, or in some cases longer. When the feature is delivered, the process starts over again to define the next new feature which is always different from any of the previous ones.

When IT managers interact with end users it’s to deliver something that’s already defined. For example, an end user may need a new desktop, a faster notebook, a replacement Blackberry, or a new fileserver share to store documents. Since what they’re asking for is already defined, the end user expects that the request will be delivered quickly, in hours or in a few days (at most) and it will be delivered in working order exactly the same as the previous times (which is not at all unreasonable from the end user’s point of view).

So Development is in the business to deliver new things over-and-over again, and IT is in the business to deliver the same thing over-and-over again quickly.

And that’s one way to answer the question in a single and meaningful discrete statement. But be careful not to underestimate the differences. In software development there is a one-to-one relationship between the definition of a feature to its delivery. For example, an end user wants a new button on a screen to perform a function. An end user will define the button and the function and a software developer delivers the new button and its associated function. That’s one-to-one, one definition to the delivery of one feature.

On the other hand, in IT there is one definition that is applied to many deliveries. For example, an end user wants a specific set of software applications to be included on desktop computers and an IT manager configures and delivers the desktops to multiple end users in a department. That’s one-to-many, one definition to the delivery of many desktops. And unlike Development, in IT the deliveries are not distinct and usually occur over an extended time period.

There are additional differences. In Development there is typically a single business owner who defines the feature, however, in IT, definitions usually have to satisfy multiple business owners sometimes across multiple departments that are operating different business functions.

In an IT function it’s easy for the definition behind a delivery to be become out-of-date, stale, and sometimes inaccurate as hardware is upgraded, software updates change features of vendor-based applications, or when feedback from multiple end user groups change the definitions in small incremental ways over time.

IT groups also have the challenge of keeping the already deployed systems in-sync. When Blackberry releases a software upgrade, for example, in some cases new hardware devices may require the new software version to function, and in others the new software may not work on older devices, which results in a deployed base of devices that can work differently from one another. However, from the end user’s perspective they provided a definition for a mobile email device and a Blackberry is a Blackberry and each one should work the same way.

An organized IT group will maintain definitions for end user requirements in the form of Build Documents and attempt to keep them up-to-date. However, as business groups grow, objectives change, and collaboration scenarios between business teams expand, end users aren’t oriented to inform IT of the changes and in many cases it becomes the responsibility of IT to initiate dialog with end users to update requirements (rather than end users initiating the dialog which is generally the case when new application features are needed from Development teams). In addition, IT frequently has to manage, and sometimes rationalize, conflicting requirements from multiple end user departments that may come up over time. Since a Development function delivers one feature to one requirement, the dialog with end users is usually more current with the request.

Also be aware of the analogy between the “source code” of an application and the “configuration” of a product (such as a desktop, server, or network device). End user groups generally have an understanding that developers need time to change and test source code. But since end users expect IT to deliver the same thing over-and-over again quickly, there is not a similar understanding that IT needs time to change and test configurations. And making matters more difficult for IT, there are many good versioning systems to help manage changes to source code, but system “configurations” in many cases are disjointed and can’t really be versioned and controlled like applications’ source code.

So what can be done to improve the situation and avoid problems? Well first, IT managers and others responsible for an IT function should be aware of the underlying nature of Development vs IT processes. IT managers should maintain a collaborative and productive process with business groups and keep-up with requirement definitions in a Build Document type format that captures any differences between end user groups. IT managers should also attempt to make the nature of their function transparent so business-side teams have a basis to understand the processes that are used to manage infrastructure-based deliveries.

Lower Your OO Expectations for the Windows PowerShell

December 28, 2008

For programmers who are used to leveraging object oriented techniques, even within modern scripting languages, don’t expect too much from the Windows PowerShell. Here’s a quote from the PowerShell Online Help file:


Definition: Declares the name of a class, as well as a definition of the variables, properties, and methods that comprise the class.

Although it is possible to create a class in Windows PowerShell, its not a very straightforward process and definitely goes beyond the scope of this introductory manual. So, for the time being, forget we even mentioned it.

Yep, that’s a verbatim quote. PowerShell is still a verision 1.0 product so hopefully the situation will improve in future versions of the software.

If you’re looking for more documentation for the Windows PowerShell, here are some references.

The Windows PowerShell 1.0 Documenation Pack includes a getting started guide, a user guide/primer, a quad-fold reference card, and release notes for version 1.0.

Microsoft has a .chm Help file for PowerShell which is a convenient (and searchable) reference to supplement the PowerShell online Get-Help CommandLet. They refer to the .chm Help file as the “Graphical Help File” which you can download by clicking here.

O’Reilly publishes a pocket reference which is a very good source of information for the Windows PowerShell if you are an experienced programmer. They also publish the Windows PowerShell Cookbook for the language which is in the standard O’Reilly Cookbook format that is available for other programming languages.

The Windows PowerShell Technology Center has many other helpful resources if you are getting involved in PowerShell Programming.

The next version of PowerShell, version 2.0, is available in a Community Technology Preview (something like a beta version) by clicking here. And hopefully future versions of PowerShell will provide better support for object oriented freatures of the language.

A Text Report for Outlook Calendars

November 15, 2008

My prior firm created a great little application for Outlook and Exchange calendars, here’s how it worked. People in the Systems Group entered their out-of-office time (vacation time, sick days, work from home days, etc) into an Exchange Public Folder calendar called “Vacations.” The application, which ran overnight sort of in a batch mode, would read the calendar and format a text report suitable for reading in Outlook or on a Blackberry device. The report, as I remember it, looked something like this:

This is formatCalendarReport.wsf running on 11/9/2008 11:06:30 AM...

     Calendar: Personal Folders/Calendar...
Report period: 11/10/2008 through 11/13/2008 (4 days)...

Monday, 11/10/2008:
         Subject: Sal - Vacation
            From: 11/10/2008   To: 11/12/2008

Tuesday, 11/11/2008:
         Subject: Sal - Vacation
            From: 11/10/2008   To: 11/12/2008
         Subject: Jim - Working from home
            Body: Please contact me at 212.555.1212 as needed.
            From: 11/11/2008   To: 11/11/2008

Wednesday, 11/12/2008:
         Subject: Sal - Vacation
            From: 11/10/2008   To: 11/12/2008
         Subject: Rob - Cisco seminar
            Body: I will be out of the office in the afternoon.
            From: 11/12/2008 12:00:00 PM   To: 11/12/2008 5:00:00 PM

Thursday, 11/13/2008:
         No calendar events for today.

This is formatCalendarReport.wsf ending on 11/9/2008 11:06:31 AM...

Now keep in mind that this calendar report is not something that Outlook or Exchange provides as a standard feature, so a developer in the Systems Programming Group wrote a custom Windows application to format calendar entries to be delivered by email. Shared Public Folder Calendars were widely used by different groups and departments in the firm and people generally liked the daily email format (rather than having to manually view several calendars every day in Outlook).

When I started a job at a new company I wasn’t really surprised to see Exchange Public Folder calendars used for similar shared event scheduling to coordinate vacation time, software releases, and on-call support. I quickly missed the convenience of receiving a daily email so I set out to recreate the report in a script.

A Script to Format Outlook Calendars

formatCalendarReport.wsf is a Windows Scripting Host (WSH) application that uses the VBScript programming language to access Exchange Public Folders and print calendar events in a format similar to the listing above. The script can be run from the Windows CMD prompt using the WSH cscript command. If you’re using a current Service Pack version of Windows XP you should find that WSH and the cscript command are already installed on your system, so download the script to your computer and try to produce usage instructions by running it with the /? parameter as follows:

C:\>cscript /nologo formatCalendarReport.wsf /?

Prints a report of events in an Outlook calendar for a period of time.

Usage: formatCalendarReport.wsf /calendar:value [/numdays:value]
          [/emptyevents[+|-]] [/emptybody[+|-]]

calendar    : pathname of the Outlook Calendar
numdays     : number of days to process in the report
emptyevents : include dates without events, default emptyevents+
emptybody   : include empty body fields, default emptybody+


   formatCalendarReport.wsf /calendar:"Personal Folders/Calendar"
      /numdays:14 /emptyevents+ /emptybody+

The WSH script and its output include a few enhancements compared to the version that I remember. First, when the script runs it produces greeting and closing lines that show the start and end times of the command:

This is formatCalendarReport.wsf running on 11/9/2008 11:06:30 AM...
This is formatCalendarReport.wsf ending on 11/9/2008 11:06:31 AM...

And the runtime parameters are printed at the top of the formatted report:

      Calendar: Personal Folders/Calendar...
 Report period: 11/11/2008 through 11/13/2008 (4 days)...

If there are no scheduled events for a given date, the report will include a message like this:

Thursday, 11/13/2008:
         No calendar events for today.

And if multiple events are scheduled, the subject, body, the start, and the end times of each event are printed as follows:

Tuesday, 11/11/2008:
         Subject: Sal - Vacation
            From: 11/10/2008   To: 11/12/2008
         Subject: Jim - Working from home
            Body: Please contact me at 212.555.1212 as needed.
            From: 11/11/2008   To: 11/11/2008

Notice that calendar appointments which are entered as “All day events” show their start and end date ranges without times (as in the two events immediately above). However, calendar appointments which have specific start and end times (for example, events that are not defined as “All day events”) show the time of day details as in this example:

 Subject: Rob - Cisco seminar
    Body: I will be out of the office in the afternoon.
    From: 11/12/2008 12:00:00 PM   To: 11/12/2008 5:00:00 PM

An Example Command

Here’s how to run it on your system. The script provides command line options to customize the format of the report. Below is a runtime version of the command that uses all the currently supported options:

cscript /nologo formatCalendarReport.wsf
        /calendar:"Personal Folders\Calendar" /numdays:7
        /emptyevents- /emptybody-

cscript is a Windows command that invokes WSH to run a .wsf script, and the /nologo option tells WSH to omit a banner message (which reduces some clutter from the output). formatCalendarReport.wsf is the name of the script.

The Microsoft Exchange Calendar to read is specified by the /calendar option. The calendar is a double-quoted pathname within the Outlook folder list. For example:

/calendar:"Personal Folders\Calendar"

selects a calendar under Outlook’s Personal Folders list. Alternatively, a calendar called Vacations in the Exchange Public Folders list might be accessed like this:

/calendar:"Public Folders\All Public Folders\Vacations"

The formatCalendarReport.wsf script starts from the current date and (by default) creates a report for the next 14 days. In the example above, the /numdays option is used to create a shorter report for seven days (starting from today’s date).

If a day in the calendar doesn’t have any scheduled events, a line item is added to the report that reads “No calendar events for today.” To exclude dates without events, use the /emptyevents- parameter. (By default /emptyevents+ is implied.)

Similarly, a “Body:” line item is included by default, so add /emptybody- if you would like to exclude body fields from the report that don’t contain any data.

System Requirements for the Script

The script requires Windows Scripting Host. If you are running a modern version of Windows (Windows XP, Vista, or Windows Server 2003/2008) you’ll find WSH and the cscript command included in your system. If you are running a different or older version of Windows, or if your system doesn’t have the cscript command, check the Microsoft Scripting FAQ to determine how to install WSH on your system.

The script also requires Outlook Redemption. Outlook Redemption facilitates access to Outlook and Exchange data via scripting languages without the Windows security layer continually confirming access through a pop-up window. Outlook Redemption can be downloaded from the following Web site: Follow the instructions in the readme.txt file to install Redemption on your system to run the formatCalendarReport.wsf script.

A connection to Outlook (for a mailbox in Personal Folders) or an Exchange Server (for a mailbox stored in Exchange) is required. The script connects using the privileges of current user. If you setup the script to run as a Windows Scheduled Task remember to configure logon information (both username and password) for the proper connection to your mailbox.

Additional Comments and Follow-up

A .txt filetype has been added to the name of the script to avoid problems with virus scanners or firewalls when you download the file. Be sure to remove the .txt extension after the download completes so you won’t have a problem running it on your computer.

formatCalendarReport.wsf will format a calendar into a text listing but it doesn’t email the report. A follow-up post will demonstrate how a separate Windows tool can be used to email the completed report to a list of addresses.

Please note that the script was only tested on a Windows XP system running Service Pack 3.

In the meantime, if you download the script and try it on your system, and please post a comment so we can hear something about your experiences running it.