I never knew this was possible, but I stumbled on it the other day. It is pretty simple.
Monthly Archives: October 2009
Using Powershell scripts from MSBuild, Scheduled Tasks, etc.
There are a few different ways to use Powershell from the legacy cmd shell. The most common way is to call it like the following.
> powershell write-host "hello world"
As you can see, the powershell.exe is called with Powershell commands as the parameters. I started noticing some odd behavior though. I have the following script, TestScript.ps1. It has code as follows:
param ( $str ) write-host $str
Very simple right. Well guess what happens when I call it from powershell.exe like above?
> powershell .\TestScript.ps1 "hello world" hello
A little odd. I have a very cordial script but it is a little tongue tied. I didn’t spend a lot of time trying to figure out why this was occurring, I instead used powershell -? to help me find an alternate method, and probably better way to call Powershell scripts from the legacy cmd shell.
> powershell -Command "& { .\TestScript.ps1 'hello world' }" hello world
This worked like a charm. Note the quotes, as script blocks aren’t interpreted from the cmd shell properly, and will cause odd behavior. And from MSBuild, a little bit of XML escapage and you can easily use Powershell.
<Target Name="AfterBuild"> <Exec Command="powershell.exe -command "& {.\Register-EmailApiSnapIn.ps1 '$(TargetPath)'}"" /> </Target>
When TDD Goes Bad, NUnit wasted 2 hours of my night
[TestFixture] public class IHateNunit { [Test] public void A_list_works() { IList<string> strs = new List<string>() { "asdf" }; //Double Pass Assert.That(strs.Count, Is.EqualTo(1)); Assert.That(strs, Has.Count(1)); } [Test] public void An_array_doesnt() { IList<string> strs = new string[] { "asdf" }; //Pass Assert.That(strs.Count, Is.EqualTo(1)); //#FAIL Assert.That(strs, Has.Count(1)); } }
Amazon knows me too well – Go Stu
Amazon just recommended Hadoop: The Definitive Guide to me. My coworker Stu and his use of Hadoop is featured as a case study in the book. How does Amazon know me this well?
Don’t pass-the-buck, a manager tip
I preface this by saying I believe I know very little about management. I am a software developer who happens to also manage, not the other way around.
Recently, I have been on a Don’t pass-the-buck kick. What do I mean by this? Imagine the following scenario.
Chris the CEO decided that manager Max’s team needed to stop working on widget X and start working on widget Y because it has more business value. Max knows his team is already halfway through widget X and really loves working on it, unlike Y which is not started and the bane of their existence. But, Chris the CEO knows what is right for the business and Max does what he asks.
Max then goes and tells the team ‘Team, Chris is forcing us to switch from X to Y. I know you love X and I fought to keep it, but he is the boss and we have to do what he tells us’
What’s wrong with this story? Manager Max passed-the-buck. Managers serve two important roles in regards an organization’s structure.
- Advocate for their team – This is easy. Manager Max fought CEO Chris for X instead of Y.
- Face of the organization – This is hard. Manager Max could have explained why Y was more important. He could have been the bad guy to his team, but he wasn’t.
Being the face of the organization is hard because it involves hard conversations. Hard conversations suck. But if they aren’t had, worse can happen. Team’s need to understand why Y, in order to connect with the mission of the organization. They also need to have a conversation about Y, no matter what the outcome. Otherwise, the manager is basically saying their opinions don’t count.
I think passing-the-buck is something prohibits many managers from becoming leaders. I am absolutely guilty of doing it, but I realize its detriment to me, as well as my team.
Leadership is ultimately about creating a way for people to contribute to making something extraordinary happen.
(PS: The phrase passing-the-buck has a very interesting history)



