My First PowerShell Cmdlet

We’ve been using PowerShell to write automated tests of the UI on my current project.  One of the tasks I took on today was creating a custom cmdlet to enable us to select radio buttons.

I already had an existing assembly of cmdlets to work with, so I just added a new class (SelectRadioButton) to it.  Next, I added references to System.Management.Automation and System.Windows.Automation. With these references in place, I could add this attribute to the class:

[Cmdlet(VerbsCommon.Select, "RadioButton", SupportsShouldProcess = true)]

The attribute determines the actual name of the cmdlet you’ll use in scripts (Select-Radiobutton).  The cmdlet needs an instance of AutomationElement to operate on, so that’s defined next:

[Parameter(Position = 0, Mandatory = true, HelpMessage = "Element containing a radio button control")]
[ValidateNotNull]
public AutomationElement Element { get; set;}

Finally, I adapted some of the logic for my override of the ProcessRecord from this article on using UI automation.  The end result looks something like this:

protected override void ProcessRecord()
{
try
{
if (Element.Current.ControlType.Equals(ControlType.RadioButton))
{
SelectionItemPattern pattern = Element.GetCurrentPattern(SelectionItemPattern.Patern) as SelectionItemPattern;
if (pattern != null) pattern.Select();
}
else
{
//Put something in here for handling something other than a RadioButton
}
}
catch (Exception ex)
{
// You could put some logging here
throw;
}

}

In non-iPhone 4 news

Apple stealthily revised the Mac mini.  Get the full story here, but the part I think is the most interesting is that they designed in a removable panel on the bottom to make it easy to replace the RAM yourself.  It shows a rare bit of flexibility from Apple when it comes to their hardware.

As for the rest of the device:

  • No more power brick?  Nice!
  • Tons of ports (including HDMI).
  • SD card slot
  • No Blu-Ray?  Rats.  “Bag of hurt” or no, that would have been nice.
  • The price bump from the previous version of the Mac mini seems a bit steep.

The original Mac mini was the first computer I ever bought from Apple.

When default settings attack

When you first install SQL Server 2008 Express, the TCP/IP protocol is disabled by default.  Be sure the protocol is enabled (which requires restarting the service) before you try to run an application that depends on it, otherwise you could spend hours trying to figure out why your application won’t work.  It looks like SQL Server 2008 R2 Developer behaves the same way.

I suggested this awhile back to a co-worker who’d been struggling all day with why an application wasn’t working, and it turned out to be the solution.

To Curacao and back

I spent the past 7 days vacationing in Curacao with my girlfriend Ebony and another couple we’re friends with.  In this post, I’ll talk about how it went, and how I might have done things differently if I were visiting again.

Why Curacao?

Ebony has wanted to go there for awhile, because of the beautiful water, sun, and beaches.

What to wear

Definitely wear light clothing.  Average high temperatures in Curacao are mid-to-upper 80s Fahrenheit year-round.  Don’t skimp on sunscreen, or you’ll regret it–even if your skin is already relatively dark.  My friends aren’t that much lighter than me, and all of them got burnt.  Don’t go easy on bug spray either.

Accommodations

We spent two nights at Renaissance Curacao Resort & Casino in Willemstad.  If you’re familiar with and/or a fan of Marriott properties, this one has everything you expect.  They also have plenty of outlets for appliances and electronics from the U.S., so you won’t need to use converters.  The only wi-fi access appeared to be in the lobby, and I never managed to connect with my iPhone.  There’s wired internet access from the rooms, so netbook and laptop users will have an alternative to the business center.  The private beach they talk about on their web page is man-made, and doesn’t connect directly to the ocean, but a large saltwater pool.

We spent the rest of the time at the Hyatt Regency Curacao Golf Resort, Spa, and Marina.  Parts of the property are still under construction, so we got the benefit of a grand opening rate, 4 nights for the price of 3, and free breakfast for the duration of our stay.  The service we received from every member of the staff was excellent.  Without exception, they were all incredibly courteous and polite, and went out of their way to accommodate our requests.  I thought the rooms were nice, but some of the balconies are much better for privacy than others.  The tub has a rather high edge, so it’s a bit of a challenge to get into unless you’re tall.  Strangely, the shower only has frosted glass on half the length of the tub–and no sliding door.

Food

Bistro Le Clochard was expensive, but the food was excellent.  It’s inside Rif Fort, a very short walk from the Renaissance.  We discovered that their kitchen accommodates vegetarians quite well.  It seems to be a quite popular place, so make reservations ahead of time, or you’ll have to eat elsewhere.  The restaurant within the Renaissance is ok.

The Hyatt has three restaurants: Medi, Shor, and Swim.  The food at all of them is quite good, though the serving times vary widely (Shor is the slowest, Swim is the fastest).  Swim will serve you poolside or at the beach.  Their plantain chips and fish tacos were especially good.

How to pay

U.S. currency was accepted everywhere we tried to use it, as were our credit cards.  I checked the tourist board website to get information ahead of time.

Activities, Attractions, & Shopping

Of the attractions available in Curacao, we got to the Kura Hulanda Museum and the Rif Fort in Willemstad.  At Kura Hulanda, the extra money for a tour guide was well worth it.  It provides a great history lesson of many cultures, as well as the slave trade.  With more time, I would have visited the Mikve Israel-Emanuel Synagogue and the Maritime Museum as well.

During our time at the Hyatt, we went on a 3-hour cruise with some time for snorkeling.  I still regret my lack of underwater camera gear for this, because there were a lot of strange and beautiful fish to see.  There was even a small shipwreck close to where we snorkeled that we were able to see.  Ocean Encounters handled our tour, and they did an excellent job.  If we’d planned further in advance, we could have gone on the 7-hour cruise to and from Klein Curacao.  This trip made me wish I knew how to scuba dive.  A trip back for the sole purpose of getting PADI-certified would probably be worth it.

At least in Willemstad, there are tons of places to buy jewelry, electronics, clothes, and souvenirs.  Prices in downtown were pretty good from what I saw.  The street vendors just outside the Rif Fort offered the best prices, and we ended up getting a couple of very nice things in both places.

Getting there (and back)

We flew American Airlines from Reagan National Airport to Hato International via Miami.  Our friends flew to Miami from Philadelphia, then to Hato International.  During the time I researched flight costs, they ranged from $450/person to well over $600/person.  We ended up using frequent flier miles for the DCA-MIA leg of the trip to cut down our out-of-pocket costs.  If I had it to do over again, I’d have planned much further in advance.

One thing I noticed (to my annoyance) about flying into and out of Miami is that the gate personnel decided to pick on either Ebony or both of us about the size of our carry-on luggage.  To make sure you avoid that kind of harassment, make sure your packed carry-on fits in the stupid little cages they have near the gates.  Otherwise, you could end up having to check a bag you weren’t expecting and risk the airline losing it (like American Airlines nearly did with her bag).

The last thing I’ll say about flying to and from Curacao (at least in this post), is to avoid taking the last flight out of Curacao on whatever day you depart.  If there’s a problem with that flight (as there was in our case), you’ll be stuck at least one extra day.