Aug 2 2010

PowerShell, Ninja Turtles?

PowerShell, I love the shell and I always could do with some more power.  I have heard a lot of people complain about windows lacking in this department, like I have heard woman talk about their husbands at the water cooler. Tools are important, but more importantly is thinking about the way that a developer works. Hopefully this will help me explain myself and the reason i believe Microsoft introduced PowerShell.  The fun part of doing any project is in implementing the real meat of the application, lets take a firewall as an example.

The objective of a firewall is to inspect packets and to either allow or dismiss the packets. The fun part of writing that software would be the packets inspection, and the rules engine (the thing that decides what goes through). The boring part would be the interface where you would edit the rules and perhaps a dashboard that will display the current status on ports etc.

You will undoubtedly find that the developers at some point had to test the different parts of the application. This either means they create the simplest way to test it, or go through the effort of making the end user dashboard all be it in battleship gray and big ugly buttons. Me, option 1 is always the answer. Even big ugly gray buttons is not only boring, it is wasted time that i could be spending on Facebook or Twitter.

It turns out, that a lot of the time others also code in a very similar pattern to me. Firstly, that makes me feel a lot better about myself and secondly it saves me from having to use a GUI. What i am trying to get at is the ability to use the command line or even better, write a batch script. The advantage of these is that they are  simple to change and allow you to make changes without the ability to know a coding language and more prevalent of late, a coding environment or framework.

Have a look at the following

   1: netsh advfirewall firewall add rule name="SQL Server (TCP 1432)" dir=in action=allow protocol=TCP localport=1433 profile=domain

What we have before us is a command line utility that allows us to add rules to the firewall on Windows 2008. Talk about the easiest way to repeat a test a few times, add this to a batch file and you can test over and over an over. The difference here is that in Linux, almost everyone believes that this is the only way to change items and the exact opposite would be said for Windows. I can only believe that this is what caused Microsoft to release PowerShell. An almost official way of saying, look we are hardcore too, we have the shell. I earnestly believe that they have always had a shell and this is shell v2.0 and i like it.

In the following weeks and future posts i will be trying to introduce new concepts and scripts in PowerShell along with other technologies.


Apr 7 2010

..:: New Hardware Time ::..

Yes, it is time for me to buy new hardware. I have been using a Dell XPS m1730 which is pushed as a Desktop replacement and if you ask me, this is exactly what this beast is! You don’t want to carry this thing around with you, you want to put it on your desk and leave it there! i also think that with all the carrying around it is starting to kill itself slowly, which is both scary and sad since it is just under two years old. So this leaves me with the chance now to get a new computer / laptop.

I first off need to say that there is nothing like the power of a desktop PC. Laptops will always try and catch up, but the physical limitations that a laptop design has rules it out of the power race. I however work in a dual location (work and home) and lugging a big box around, although technically i have been doing it for two years is not practical anymore. Also, the power supply that comes with the beast weighs in just under 2Kg’s and it is a pain in the rectum to carry around! Battery life is ok, but the need for a power source is there because no-one works for less than 3 hours at a stint and my battery lasts just under 2.

So i decided to draw up a quick list of things that i need as a result of lessons i have learnt with my previous hardware.

  • at least 500Gb 7200RPM Drive preferably a solid state and another drive
  • at least 4 gigs of RAM or more (large disks means virtualization so probably 8 gigs)
  • Intel 2.6ghz or more with 6mb cache
  • 15.4 screen with (1600×1200) display
  • VGA out and or HDMI
  • A battery or combination of batteries that give more than 3 hours work time
  • Decent weight

I also have had to face facts that the type of work i have to do is changing. I used to sit and code, design and partially document for a good 9, 10 hours a day and this machine was good for that. Of late i am having to give more presentation, do a lot of planning and project management (the latter of which is like eating wet popcorn) and so i need a versatile device rather than a single purpose built one. I would really like to try and move towards a goal based approach in my work rather than single incident type style that i am currently working on at the moment. This style of work has me in the office all day and when i am away from my desk in meetings etc i need to come back and start from where i left off, which i admit is a dumb way of working.

So for the next short while it is going to be drawing up processes etc to almost get my team i manage in a self managed mode so i can start to expand into new area’s again. Oh and a Mac is not out of the equation….


Jan 27 2010

..:: Booting From A Windows 7 VHD ::..

One of a new features in Windows 7 and Windows Server 2008 R2 is the ability to boot from a VHD.  It is pretty simple to enable this feature and have it ready at your disposal!  Before you begin you should note the following…

  • You can only boot a Windows 7 or Windows Server 2008 R2 VHD
  • You must configure the boot editor from a Windows 7 or Server 2008 R2 install
  • You cannot use a Virtual PC VHD, I suggest a Hyper-V VHD
  • You need to start with a clean slate, don’t try and reuse an old VHD

I am sure this will change as Windows 7 goes through the beta and RC stages on its way to RTM and we’ll update this as necessary but here goes…

Start by launching a Command Prompt and be sure to run as Administrator, once that is done run the following commands…

bcdedit /copy {current} /d “Boot_From_VHD”

Copy the CSLID that is displayed and then run…

bcdedit /set {CLSID} device vhd=[C:]\vhdname.vhd

bcdedit /set {CLSID} osdevice vhd=[C:]\vhdname.vhd

bcdedit /set {CLSID} detecthal on

You can replace [C:]\vhdname.vhd with the path and name of your VHD.

Once that is complete reboot and you will have the option to “Boot_From_VHD”!  You can verify the bootloader is configured correctly with the bcdedit command which will list all the boot options.  If you want to delete the entry make note of the GUID listed in bcdedit and use the following command…

bcdedit /delete {GUID} /cleanup