The PowerShell Journey: Part 1

February 22, 2011 Leave a comment

As a developer I try to use the latest and greatest and when something good comes about I try to pick up as much of it as I can.  The use of command or batch files has been a part of my world for a long as I have used computers.  Back in the day, there were batch menus for DOS computers so people with little or no computer experience could get the their applications (Lotus 123, Wordstar, etc.)  The days of doing DOS menus has past but the power of the command shell remains.

The New Command Shell for Windows

I know I am late to the party when it comes to PowerShell but when it comes to shells I am skeptical at first, excited or dismayed second.  Recently there seems to be more and more need to run a shell with more power than VBScript could hope to provide, I was skeptical but I now see the fruit of such a pursuit.  When PowerShell hit the street I hardly noticed because I was very happy with my shell and I could do anything with a cscript command that could not be done with old DOS commands.   Thanks, but no thanks.

Then something changed, I needed to run a script to start & stop an IIS application pool on another server.  I looked and found this http://blog.developers.ie/cgreen/archive/2006/10/20/2341.aspx which clearly uses .NET to control a remote IIS web application pool.  I was about to translate this to VBScript when I thought about what PowerShell is supposed to be able to do out of the box.  I pursued it and came up with the following script:

# Action : Start, Stop, Recycle
param([string]$server, [string]$AppPool, [string]$Action)
$sPath = "IIS://" + $server + "/W3SVC/AppPools/" + $AppPool
$de = New-Object System.DirectoryServices.DirectoryEntry($sPath)
$de.Invoke($Action)

I know it isn’t sexy but it performs the task I needed. This is just the beginning, I’m sure there will be more scripts with more meat in them. Stay tuned, I am starting a series: The PowerShell Journey.

Categories: Code Tags:

Backup and Archive

January 20, 2011 Leave a comment

I have been using USB connected drives to backup the computer for a while now.  I can’t remember when I started but it was around the time when my daughter was born (Jan 2006).   Before the USB drive backup system, I was using DVD disks, several of them and waiting a long time for the backup to complete.   These backups were with an application that would attempt to compress the data and write out in their proprietary format to the disks.  One day I had a hard drive crash and found the disks but I had not backed-up the application.  I found the program later but the whole restore process was not pleasant.  In came USB drives and I could backup the files intact without using a backup program and the world was well again.

Four years later, I am backing up to an online web storage solution called BackBlaze and I love it for the most part.  The service took a very long time to do the initial backup but I have slept well at night since then knowing I have a copy of all of my files safe and sound.  The service does not save a history of the files backed up though, nor does it contain a list of old files I do not have on my primary or connected hard drive.

I still save an archive of old files and such to two USB drives.  The first is a 320GB drive used for the photos and videos we have taken over the years and the second is a 1.5TB drive for everything else.

Everyone needs a backup solution make sure you find one that works for you.

Categories: Data

Code Simplification: String Maximum Length

December 6, 2010 2 comments

I was looking at some old code and ran across something that struck a chord of wrong with me.

string temp; 
temp = "There can only be one!";
if (temp.length > 15) temp = temp.substring(0, 15);

Then I thought we could use a little math to handle the problem:

string temp; 
temp = "There can only be one!";
temp = temp.substring(0, Math.Min(15, temp.Length));

I think Microsoft should have included this kind of method to the String class. Hope this helps.

Categories: Code Tags:

AMD: Remember you are a technology company!

June 30, 2010 1 comment

AMD seems to have lost itself somewhere along the way.  I have owned several AMD-based systems over the years starting with a 386 clone to an Athlon several years ago.   Having a deep love for all things hardware and software, I like to know what the technical specifications of just about anything I read about.  The type of hardware doesn’t matter, be it a hard drive, case, power supply or processor; it’s all good to me.  That is why I need to convey my deep disappointment about AMD.

I saw a new laptop on Newegg‘s web site and was intrigued to see a processor I have never seen before.  The processor is a mobile Phenom II quad-core and the machine looks like a upper-middle end machine except I know nothing about the processor.  I assumed that going to the AMD web site would yield all kinds of information about the processor.  I was utterly flabbergasted to see it not on the list of mobile processors from the home page.  I then searched the web site for the phrase “mobile Phenom” with odd results, the first two links had the processor named but no link to any technical documentation just all kinds of marketing.  The third link took me to a page listing all the classifications for the processors with “AMD Notebook Platform for Home” and “AMD Notebook Platform for Work” listed but when I clicked on those I get more of what I found in the initial search, marketing material.  Then I saw on the far right, a link to “Compare Processors” with notebook processors listed and there is a compare page.  I select the first “AMD Phenom™ II Quad-Core Mobile Processors” option and there are two processors I clicked on the P620 and no luck.  Just the basic technical facts about the design and manufacturing of the processor.  Don’t they think we want to know about the power management features, the memory controller, the memory type is uses, etc?  Twenty minutes and nothing to show for it.

I gave up at this point and looked for more detail outside of the AMD site and was disappointed again.  Another five minutes lead me to all kinds of speculation on performance because AMD has no material to say how the processor performs relative to the old line of mobile processors or even compared to the desktop version.

How can I buy a machine when I know virtually nothing about the processor?

AMD, I know I am just one guy but here are your action items:

  • Make the specifications of your processors easier to find and available to search engines.  I hate to point out that your direct competitor makes 90% of the specifications very easy to find.  Do the same.
  • Make a detailed specifications page with all of the details including architecture, bus configuration and any other real selling points for a technology geek.  If your marketing department is feeling a little left out, then include links to the marketing materials for the pseudo-techs or non-techs.
  • If it makes sense, have a technology oriented version of your site where people like me can find the dirty details like relative performance and technology factors to make educated decisions on the validity of the processor as the platform for a tech-geek.

You may just sell more of your product if more information is available.

Categories: Hardware Tags: , ,

Enterprise Library 5.0 – Notes

April 23, 2010 2 comments

The new version of Enterprise Library has some interesting implied additions and constraints.  I have used the frameworks before and like them for the most part, they keep the structure of a large application from looking like slop.  I took a good look at it and I am impressed how much better the library gets in each release.  In our organization however, we have chosen not to use the framework because we used the first few and converting from 1.0 or 1.1 to 2.0 to 3.1 was a royal pain.  Several applications used 3 and 4 but they soon converted to the Castle framework because the Castle team seemed to be making more progress.  Both have pros and cons which you may assess for yourself if your interest level is high enough.

What I do want to note is the lack of expressed Windows XP support with the Enterprise Library 5.  Here is the beginning of the system requirements section:

System Requirements Screenshot

I saw a comment asking if Windows XP was supported and the reply was that if it works, it works.

There are a ton of breaking changes this time, but none appear to be outside the realm of making things better in the long run.  There is also a Migration Guide as usual to help in the transition process.

Great job on the release and I hope to see more good things from the Enterprise Library in the future.

Categories: Code Tags: ,

iPad Second Impressions

April 5, 2010 2 comments

The iPad has been released with all the fanfare of a king arriving home from a great battle.  iTunes has been updated to support the new applications. New applications specifically designed to support the iPad are well underway.  Now all of us skeptics can be silenced, or not.

I realized the cleaver plan of Apple a few hours after the release.  I have thought hard why anyone would want a larger iPhone other than it’s a gadget of bigger proportions.  The reason became clear when a read a blog post of an eBook reader that was very pleased with the iPad and it’s screen, form factor and overall size and weight.  Weeks ago I read that school books were to be available for the iPad.  Then I put it together, the iPad is the perfect medium for a student to carry a single lightweight device rather than a bunch of heavy books.   The school system doesn’t have to carry as many books (maybe none in the future) and the students only have to carry a gadget to their classes, brilliant.

I am sure there are people out there that are saying “Why does it have to a tablet, why not a netbook or Macbook or the like.”  The problem with a PC, Mac or Linux machine is the potential for data loss.  The iPad only has the data that has been synced with a computer so if it gets fried, dropped, drowned or just fails, the data is still on the computer.

I officially rescind my previous skeptical post and say the iPad is a gadget worth getting.

Categories: Hardware Tags: , ,

When is CRUD enough?

April 1, 2010 Leave a comment

Let’s lay some groundwork before we start the rant.

CRUD is an acronym for the Create, Read, Update and Delete operations done to tables in a database.  I believe I can safely say “All database applications do at least the CRU of the CRUD”.

Now for the argument

I have never dealt with an enterprise level application that does just plain old CRUD.  In every case, there was some sort of logical requirement that precluded the CRUD requirement.  In the academic world there are examples of applications where CRUD operations can be done, but I have not been involved with one for a very long time.

Here’s an example:

Tables: UserInfo, ProductInfo, EventHistory

Assume EventHistory is a generic event history table with the key from the foreign table (UserInfo, ProductInfo, etc.)

Now, let’s add a new UserInfo record with the appropriate EventHistory record, this would require an Insert of the  UserInfo record with the retrieval of the key column then a write to the EventHistory table to record the user and such of the action.  Two trips even in a transaction, bleh.

How about writing a stored procedure to do the same.  One trip with little overhead to the calling application.  Simple, nice.

I’m sure there are a ton of people saying it could be done in a trigger and yet others think it should be done in the business application layer but in my opinion, the database is a good place to database oriented things.

Categories: Code Tags: , ,