Writing PowerShell Scripts

After using PowerShell for about a year, I've actually come to love it. I'm not saying it's perfect, and I'm not saying it's the best it could be. PowerShell is not as powerful as Perl and it's not as native as BASH, but what it does very well is .Net.


When Microsoft created the .Net framework, they created a fantastically powerful platform that could be easily extended and shaped to fit any need. Like any good Object Oriented programming framework, there was a strong set of basic objects built in that allowed both Microsoft and third parties to build very robust solutions quickly and easily. Nearly all MS products now have .Net assemblies, which add capabilities into the framework for the product being used. This is true not only of products like Office and Visio, but of back-end products like Exchange, PowerPoint, Windows itself, and Active Directory! And PowerShell can access it all.


So, what's the best way to get started with PowerShell? I found that learning the PowerShell language was similar to learning any programming language- have an itch to scratch. What I mean is everyone can write the "Hello World" app. Even people with no programming experience at all can do it, especially in PowerShell. But to really get down to it and learn the ins and outs of a language, you need to be applying it to an actual problem you have.


So, let's see an example. What if you were in charge of a group of servers and you needed to check some statistics from them all. Well, we know that WMI already contains that data and more. And wouldn't you know it, one of the Commandlets in PowerShell gets us an Object containing WMI data! So, let's take a quick look:

$wmidata = get-wmiobject win32_computersystem

That's it! We now have an object that contains the WMI data from win32_computersystem. Sure, you can do this in VBScript so far, but it's not nearly as simple! And we're about to demolish what VBScript can do!

$wmidata | Get-Member

   TypeName: System.Management.ManagementObject#root\cimv2\Win32_ComputerSystem

Ok, so we see that this object is actually a .Net framework data type from the System.Management... assembly. We also see that there's a commandlet called Get-Member in PowerShell, which returns all of the methods, properties, and ScriptMethods an object exposes! At this point, Doc Brown will say "Great Scott"!

Alright, we want to actually do something here, so let's get to it. We want to collect system information for several computers on our network. Because we're admins, and we love being informed...right?

$wmidata = get-wmiobject -computername somecomputer win32_computersystem

"Machine name: " +$wmidata.Name

"Model: " + $wmidata.Model

"Manufacturer: " + $wmidata.Manufacturer

"Logged on user: " +$wmidata.UserName

"Total RAM: " +$wmidata.TotalPhysicalMemory

Our output:

Machine name: somecomputer

Model: OptiPlex 755

Manufacturer: Dell Inc.

Logged in user: MYDOMAIN\auser

Total RAM: 4158242816

Ok, so far this has saved me about 20 minutes of VBScript and it's got me all this data! And here's a neat trick...

"Total RAM: " + $wmidata.TotalPhysicalMemory / 1GB

Yes, you can abbreviate all that conversion math to go between KB, MB, and GB by using those letters.


So, we have a script that can connect to a remote computer (assuming you have permission) and gather WMI data. It then displays that data onto the screen for you. And it took us, what, 2 minutes of typing to get this? Using your imagination, you can probably see that you could wrap this all in a for loop and rip through a list in a matter of minutes. And the fun doesn't stop there!


If you're interested in learning PowerShell, I suggest you take a look at the Microsoft PowerShell site here . It's open to the public, and it's helpful. But you may find that Microsoft's information is a bit terse. Once you get your head around PowerShell, you'll actuall find this kind of information the most helpful. Also, check out the .Net framework documentation...this all applies to PowerShell objects! So, find an itch to scratch and get coding!


That's fast

How fast is the new Intel Thunderbolt peripheral bus? Let's crunch the numbers.

Western Digital announced a new 6TB drive recently, which is roughly 1748 HOURS of high quality HD video from Netflix, Hulu, or one of the other streaming companies. To be clear, this is their highest quality offering currently, and you could record 73 DAYS of it.

So. How quick can we fill our disk under perfect conditions? What if I just wanted to fill every single nook and cranny of this behemoth? Below, I've listed some popular computer peripheral connections and how long it would take them. In short, Thunderbolt is the clear winner!


Bus Speed (MB/sec) Time
USB 1.1 1.5 48d 13h 5m 4.00s
FireWire 400 49.152 1d 11h 33m 20.00s
USB 2 60 1d 5h 7m 37.60s
FireWire 800 98.304 0d 17h 46m 40.00s
SATA 1G 150 0d 11h 39m 3.04s
SATA 3G 300 0d 5h 49m 31.52s
SATA 6G 600 0d 2h 54m 45.76s
USB 3 625 0d 2h 47m 46.33s
Thunderbolt 1250 0d 1h 23m 53.16s



Family Christmas Traditions

Let me set the scene for you. Three brothers and two parents in one car. None of us get along whatsoever. The tree farm my parents "fell in love with" is over two hours away. We get there on what is inevitably the coldest year on record, and trek around for two hours searching for a tree. Initially we find three, narrow that down to two in an hour and finally, as the daylight has gone, we decide on the perfect tree. It looks like every other tree.

Dad hands me the saw..or the rusty jalopy that stands in for a saw. And there I am…face down, ass up under a 14 foot tall douglas fir that I already hate. Covered in sap and needles, freezing what used to be my balls off. Of course, the tree is so thick nobody can hold it while I cut the son of a bitch down…and you just CAN'T get out of three feet of snow that quickly. So, not only do I get the honor of cutting down a tree, but I get the PRIVILEGE of dragging it a mile down a craggy hill side, in the snow, covered in what is the most hateful mix of water, shame, sap, and sharp pointy sabers masquerading as evergreen needles.

We purchase the tree, discover we forgot rope for the 10th year in a row, but $17 of rope (roughly 10 feet), strap the tree down to the roof of the car, and make our way home in the same manner we started…miserable and tired.

Let it be known that nobody's family is better than mine.


YAPPR- Yet Another Palm Pre Review

As many of you know, I am considering terminating my contract with AT&T to move over to the Sprint network and purchase a Palm Pre. I made my Pre purchase on Sunday, August 2 at 11pm. By Tuesday, I had my Pre in hand. Having had a few days to use the device, network, and sprint store customer service, I feel it's time for an initial review.


What this is

This will be a review of the Palm Pre hardware, Palm's new webOS, the Sprint network, and Sprint customer service. I will be as in-depth, specific, and un-biased as I can, and critical where I have had problems. I will also be making a comparison between the iPhone and Pre interface functions, which should help people get the idea of the paradigm each platform represents.


What this is not

This is not going to be a tit-for-tat between the iPhone and the Pre. Since comparing usability is a subjective matter, I will not be focusing energy on calling out what platform I feel does things right, and which one(s) don't. There is more than enough content online to help you decide what you like, and you can (and should) always stop by your nearest Sprint or Best Buy to compare several different smart phones for yourself.


Of Pre and Men

The Palm Pre seems to have been released as Palm's hail Mary play- a last ditch effort to retool, reorganize, and release a product that can save the company. How well it is working, and how long Palm can be sustained on the Pre has yet to be seen, and I think making early predictions would be a mistake. I don't think anybody could have seen how big the iPhone would be when Apple released the first generation, and in fact Apple, Inc. itself has been startled by our voracious appetite for smart devices.

Having said that, the underlying Operating System on the Palm Pre is known as webOS. Palm has developed webOS to be a very simple AJAX/HTML5 device that is easy to develop for if you have any web development experience. Since there seem to be an infinite number of web developers in the world, Palm seems to feel confident that this is the best choice.

As of yet, Palm has not released their Software Development Kit (SDK) to the general public, so there are few real-world experiences with development. We'll have to chalk this decision up as a "TBD". There does seem to be quite a bit of buzz in several internet forums, some of which already have "home brew" applications available for download and install. This is much like apps for Jailbroken iPhones- There is no official support, and Palm would prefer you use their distribution methods.



The Palm Pre itself is a plastic body phone with a plastic screen and rubberized keyboard buttons. The phone's body slides open from bottom-to-top revealing a keyboard that extends the phone's dimensions by about 25%. When closed, the Pre is not as tall and not as wide as my iPhone, but it is thicker.

Official dimensions of the Pre are 2.3" wide, 3.9" high, and .67" thick. These numbers mean literally nothing without holding a phone in your hand. Sadly, every store in the world has their cell phones tethered with security cords, so you won't really be able to get a good feel for this unless you can hold an unbridled phone.

The device itself has a curved body and screen, which seems to lend itself very well to holding it in your hand and  single-thumb flicking. The curvature also helps the Pre disappear in your pocket, which is an added bonus. For those that carry a blackberry or iPhone in your pocket, you know how bulky it can feel. The Pre feels slightly better, though you will probably want it to be the only thing in your pocket still.



Several people, including myself, were concerned with the device's keyboard size. As we shrink smart phones smaller and smaller, it is clear that they keyboard will pay the ultimate price until it disappears completely. Apple is obviously the first one to recognize this fact, and they have made many non-believers change camps. For now, however, they keyboard on the Pre is absurdly small and yet somehow still functional. Each key is considerably smaller than a quarter of an inch, which means my little finger handily covers a minimum of four keys.

Even with such small keys, I can type "This is a test of how fast I can type on the palm pre. No caps. Don't judge." in 14 seconds, and only making two mistakes. First letter caps are handled by the phone, after any punctuation. Apostrophes are also placed into words where they belong automagically. So, 1 word per second for an average of 60 words per minute. This is far, FAR slower than I have become on the iPhone. Given time, I will become faster- I started at about a word every 20 seconds on Tuesday.



The Pre's screen measures 3.1" and has a resolution of 320 wide x 480 high. This is the same resolution the iPhone has, but in a screen that measures 0.4" smaller diagonally. This translates into sharper, but smaller images. For some, a smaller screen is not a plausible trade-off, so they probably won't enjoy the Pre. It isn't that the screen is noticeably smaller when using either device, but real estate is real estate.

So far, I have used the Pre in a dark room at night, direct sunlight, and literally every condition between. The brightness has always been high or low enough to comfortably view the screen, and when in direct sun there doesn't appear to be as much glare from the Pre screen when compared to the iPhone. I attribute this to the fact that  the Palm screen is curved, and the iPhone is simply flat glass.

Interestingly, the Pre screen feels a bit like the iPhone 3Gs- when you move your finger across the surface, there is very little resistance. One thing I have noticed, however, is that finger and face oil show up on the Pre's screen as though it were some kind of magnet. When looking directly at the screen, you don't notice the streaks and swipe marks, when when the device is off and you look at an's pretty bad.

As always, a screen protector is a requirement. I don't have one on my Pre just yet, and I haven't developed any scratches or blemishes on the screen or body, but every phone needs a screen protector. All of the major manufacturers have them available online and in stores, many of which are unbelievably inexpensive. I suggest invisiShield from Zagg.



The external speaker built into the Palm Pre has a good volume range without distortion, and can produce enough sound that it's almost too loud when turned all the way up. In a noisy environment, you will certainly hear your notification long as they have some high pitch noises in them.

When enabled, the vibrate is actually pleasant. It's strong enough to be felt when the phone is in your pocket, but doesn't get carried away with the vibrate duration like a Nokia or and LG does. I've found that this reduces the number of "Phantom Vibrate" incidents to zero in my case, which is actually a nice thing. I enjoy not thinking my phone is ringing and I'm missing it.

Sound is, by far, one place that the Pre pulls away from the iPhone and many other competitive smart phones. Most of them do not focus on built-in sound, choosing instead to rely on headphones and Bluetooth headsets. This makes it impossible to share a Youtube video, to listen to a sound clip, or even use speaker phone in nearly any environment on anything but the Pre.

With regard to headphones, the Pre ships with earbuds like most other phones at this point. The buds themselves are decent quality- Certainly lower fidelity than my real headphones, higher than generic earbuds, and about on par with the iPod/iPhone earbuds. This is actually a relief to me, since the Apple earbuds are widely believed to be the best quality free earbuds that come with any device for consumers. If anything, I would say that the Pre earbuds produce a little more bass than the Apple ones, but I attribute this to them being smaller and therefore fitting into my ears better.



The webOS operating system introduces the concept of "cards", which are basically application windows. An application can have one or more cards, and one or more cards may be running at any given moment. To be clear, you can have multiple applications running at the same time on the Palm Pre. This is a huge departure from the iPhone and iPod Touch paradigm, where only one application is allowed to execute at a time.

In addition to cards, there is also a notifications area at the bottom of the screen. In an effort to not waste screen real estate, when there are no unchecked notifications, the area disappears. When a notification is present, the screen scales up about 1/4th of an inch, so no applications are hidden or obscured, and the notification is displayed. If the user ignores a notification, or interacts with an card in the main screen area, the notification area is shrunk to about 1/8th of an inch, and only an icon is displayed. Touching the notification area brings up the full sized notifications again. The user can touch a notification to open its corresponding application, or the notification can be "swiped" to the edge of the screen to permanently dismiss it.

For examples of these concepts, check out this Engadget Palm Pre UI demo video.



In the new Palm webOS, we are reintroduced to an old favorite- Gestures. Palm has always tried to make life easier by assigning tasks to motions. Now, in 2009, instead of using gestures with a stylus, we simply swipe left, right, up and down with our fingers.

These motions activate several features within the webOS, most importantly the back gesture. Swiping your finger from right to left in the gesture area between the screen and button will cause your browser to go back a page, your application to go back a card, or a list of running cards to be shown for app selection. For example, if I am in the messaging application in an active conversation, and I swipe "back", I will be take back to my buddy / conversation list.

Also included in the gestures, are Cut/Copy/Paste features. Pressing the gesture area and X, C, or V will activate each function just like your computer! While this does require two-handed operation, I don't find that to be a problem as the Pre and iPhone really need two hands for any real typing anyway.



As of now, there are few applications available from the Palm apps program. As I previously mentioned, Palm has yet to officially unveil their SDK, so there aren't many sanctioned application developers. There are "homebrew" apps, and enabling them is far easier than jailbreaking an iPhone.

What applications do exist are quite well done, including the "homebrew" ones. Several big names have received early copies of the webOS SDK, which has allowed them to release a small number of helpful things. So far there is a weather app, Fandango for movies, Where and LikeME as well as a few other apps for finding local attractions and activities, a game or two, and a Twitter client.

When developers are officially allowed to write apps for the webOS, it seem there will be an influx of several hundred immediately. I don't know if Palm has any kind of approval or quality check process for apps, but if they do it should be easier than Apple apps since nothing is turned into code that can't be read by people.

There is talk of an actual Apple-like development kit, which would allow programmers to write faster apps that don't use web technologies. These apps would presumably be more powerful, allow access to more phone features, and run quicker. There is no guarantee of this, however, and thus far there aren't many features a current app can't use. This is going to have to remain a "TBD" as well.



Just like the iPhone, changing some of the notification sounds is not an option. This is complete rubbish, and both Palm and Apple need to change this policy immediately. There isn't much more to discuss with this one- Offering a phone without features found in 1996 is unforgivable.

The text selection speed could be doubled. As of now, you have to swipe quite a few times to select a full line of text. This makes selection awkward and unpredictable. Granted, it is more stable than selecting text on the iPhone, it's still only half way there. Make the selector move half the distance my finger moves, and I'll be happy.

When playing music, there is no "scrubber" that would allow you to fast-forward or reverse through a song. On the iPhone, a scrubber appears during certain types of playback, but on the Pre it simply doesn't exist. The one good thing here is that Palm can simply issue an update over the air for that one component, and pretend they never made this massive mistake. Apple has to update the whole phone, which requires it ti be plugged in and sync'd first.


Giant leaps for mankind

The number one game changing feature on the Palm Pre is the automatic backup. When you first configure your phone, you are asked to create a Palm profile. This profile is a place where all your installed Apps, App data, Phone settings, and on-phone contacts are stored. You can back up your phone manually with the Backup app, or you can allow your phone to do it automatically for you on a daily basis. Never again do you have to worry about which contacts you've lost when your phone dies.

Also of huge note is the concept of "synergy". No, not the marketing buzz word. Palm Synergy allows you to have your Google, Outlook, and Palm contacts all appear on your phone. At the same time. And most impressive, when you have duplicate contacts, it merges them into one listing on the phone. It will take details from each contact source, and display them all in one item on the phone! So, if I have you as a work contact, and your cell phone number in my Google contacts list, on my phone it will be noted that I have your cell number in Google and the rest in Exchange!

This feature also works with chat contacts. When I open the messaging application, I can choose to associate your IM screen name with your Contact information, which will then allow me to change between text messaging and IM in a single conversation with you. Simply put, this feature is astonishing.



So, the Palm Pre is a phone built with me in mind. I use multiple apps on my computer, and I do the same on my Pre. I have contacts spread all around my online world, and the Pre keeps track of them all for me. Most importantly, the Pre focuses on me the user and making my life simpler. I don't need another distraction in my day- I already have Facebook, Twitter, News feeds, Youtube, and countless pictures people send me of cats in insane poses.

This is the end of the first part of my review. Next, I will review my support incidents with Sprint, and the network coverage. These will be significantly shorter, and there simply isn't as much to cover.


Double blind RF test

Lately, the news has been full of pseudo-scientific articles about health scares, ailments, disease causing technology, and plain 'ol bullshit. Recently, several news sources picked up a completely bunk story about radio frequency (RF) sensitivity in about 2% of the world's population. But RF sensitivity is a complete sham, with literally no data to back up a patient's claims- Much like chronic fatigue syndrome.

The reason for the following test scenario can be found in an article here on Ars Technica. It seems this week, several news outlets picked up a completely fabricated story and ran with it before having anyone confirm or research the subject. My opinion of journalistic integrity isn't what this post is about, though, so that's for another day.

There is a need to put certain claims to bed once and for all, and the best way to do that is a double-blind test. A test in which neither the subject nor the administrator knows anything that could give them an advantage or disadvantage in any way. For more information on double-blind tests, I suggest reading this Wikipedia article. For now, though, it's on with my concept.



This test consists of several required components- The test administrator, the test taker, an RF generator, a console with a single button, a computer to control the RF output frequency and power, and random data from

By using a single button to trigger the test condition, neither the administrator nor the subject has any influence on the other person, or the test itself. No visual or audio cues can be provided by the administrator if they don't have to adjust controls or view output from the test device.

Random data sourced from has been calculated to be random to a degree far higher than a human brain can acheive. This data is collected through atmospheric noise, processed with several algorithms to assure randomness, and then provided online for the general public. Using this data will prevent a bias for or against the participants, which will provide better results in the end.


Phase 1

During phase one, the test taker will be deciding whether the RF device is on or off. The test data from will simply be a stream of random binary 0 or 1, which will turn the RF device full off or full on. The test administrator will confirm the subject is ready, press the button on the test console, note the subject's answer, and release the button.


Phase 2

During phase two, the data received from will be a sequence of random numbers from 0 to 250. These numbers will control the power output of the RF generator, from 0 to 250 mW. This will give an EIRP (Effective Isotropic Radiated Power) equivalent to that of most WiFi access points, and at close range should be more than enough to be detected.

The test administrator will confirm the subject is ready and press a button on the test console. The button will tell the control computer to choose the next random number in the sequence, and will command the RF generator to output a signal with the given strength. The administrator will note the participant's answer, and release the button.



When all tests have been concluded, the original random data will be made available on the computer console for comparison to the test taker's choices. Phase two should confirm any results seen during phase one- If phase one is passed with better-than-chance results, phase two should show a correlation between radiated power and the subject's perception.