Reading / parsing / writing .ini files in Powershell using XML

February 17, 2012 – 14:59

Last weekend I decided I needed to improve my Powershell scripting skills for a technical training I’m attending this week and started working on a script that could download, install and configure several applications unattended on demand. More on that script in a later blog post, for now I will focus on a specific feature I needed to script in order to make it all work.

One of the applications was still using a .ini file to configure some parameters of the tool and by nature of the script, I wanted to modify these values. One could use a search & replace method to change values in a .ini file (which is of course a simple text based file). In my search to easily parse a .ini file, I found several functions that could read the file and insert the values into hashtables. This makes values usable in a variable like $inihash[sectionname][keyname] = “value” however due to the nature of hashtables, it will sort the values in it’s hashtable by the hashvalue of it’s content. As most of us know, a hash value is different per object, per runtime, per system and will generate a unsorted mess. Inserting a .ini file with key1, key2, key3 might end up as key2, key1, key3 and there is no real way to circumvent this.

I was trying to work out the solution by working with hashtables, arrays and more .net objects in order to store the .ini values in a neat and sorted way. One could make a array with a hashtable with another nested array and hashtable but this would greatly increase complexity and reduce code friendliness as the $ini[section][key] notation would no longer function.

The other day I was casually discussing the problem with a fellow trainee and he suggested to (ab)use a XML object as a “storage box” as it would neatly allow nested constructions (section.key = value) and will remain sorted as it was imported (1,2,3 –> 1,2,3). First we would have to import a .ini file in to a XML object, later modify values and finally export the XML to a .ini file (sorted like the input .ini file).

Read the rest of this entry »





Enabling Wake On WAN/power savings for your home network / server

December 23, 2011 – 02:27

The following post describes my personal setup in my home network to conserve power and how you can possibly do the same in your own home or small business setup. By implementing advanced standby / hibernation setups, you can have significant savings on power bills and reduce your carbon footprint. I will show how you can use power saving techniques without it becoming impractical. I should warn you this post can get quite technical in the end and may not work in your setup (totally depends on your network router).

Power saving techniques

There are several ways to save energy when it comes to working in a (Windows based) home network. You can for instance lower the total power consumption of your PC by switching the Power Plan in Windows 7. By doing so, your PC will turn off unused hard disks, use less power for wireless radios and go to standby sooner when your user session is idling.

power

As we all know, you can put a PC in standby or hibernation instead of shutting it down. Even though shutting a computer completely down will save more energy than putting it in standby, it can be very useful to have the computer resume its duties quicker. I don’t put my workstations in standby or hibernation as an SSD as a boot drive makes cold boot a snappy 20 seconds wait.

Read the rest of this entry »





Windows 7: Looking ahead at PDC

October 25, 2008 – 23:00

What can we expect to see of Windows 7 at the upcoming Microsoft Professional Developers Conference (or PDC) next week? I take a sneak peak at some of the features or improvements leaked, discussed or presented the last couple of weeks. This list isn’t accurate as Microsoft has deliberately been quiet about Windows 7 and its main features. Expect to hear about most of the following article next week when Windows 7 is officially uncovered to developers, IT pros, the press and the rest of the public at Microsoft PDC 2008!

Note: This article was written just before the official unveiling of Windows 7. The following notes and features are based on speculations, rumors, leaked information and screenshots. This article is made in partnership with Microsoft oriented weblog Bink.nu. Credit given where credit is due.
 
 

Will Windows 7 get a cool new user-interface in terms of graphical overhaul?

Nope. Microsoft did officially state they won’t be changing the UI a lot (like they did when moving from Windows XP to Windows Vista) as, although very cool, most people get scared when seeing a new UI. The average user or users with less computer experience had some trouble adapting to the (rather minor, in my opinion) changes Windows Vista brought. So be prepared to be let down when it comes to the graphical appearance of the system itself if you were expected something better / newer / nicer. They are however putting some effort into making the experience more uniform across the system.


[http://screenshots.winfuture.de/1223485042.jpg, credit: WinFuture.de]

I hate User Account Control (UAC) in Vista! Are they going to change that at all?

Nope. UAC as designed is a basic security and permissions/access design that should be implemented in every modern day operating system. Linux and Mac OS X have had this design for ages now, separating users from admins and raising privileges on the spot when needed. In some of the latest leaked screenshots, it showed Microsoft is however working on refining the user experience when using User Account Control. It showed a configuration panel allowing the user to set when and how the user should be notified of UAC notifications. Also note that Microsoft is very much paying attention to the general public on this issue. Based upon user input when Vista launched, Microsoft refined UAC in the Windows Vista Service Pack 1 release.

Will Windows 7 have a completely new and rewritten kernel powering the OS giving us more power?

Nope. Microsoft stated on their official Windows 7 blog they won’t be bringing a brand new kernel to the system as it’s simply not needed. The current NT kernel is just fine and, although people like to think otherwise, is fairly fast. They (Microsoft) did say they are brining improvements to the kernel as always. One should also consider the compatibility issues created when changing some as fundamental as the Windows kernel itself.
[http://windowsvistablog.com/blogs/windowsvista/archive/2008/05/27/communicating-windows-7.aspx]

(Story continues after the break! Please read on for more information)

Read the rest of this entry »





Woops

October 24, 2008 – 21:44

I had logged into my Vista Ultimate machine remotely over the local network. When I walked over to the machine itself, it showed this weird inverted login screen.

A touch of the mouse, fixed it. Two more on my Flickr account.





HP harddisk encryption software and me…

October 24, 2008 – 02:43

As you may now, I usually use a HP Compaq business notebook (the 15” 8510p to be exact). For the last 9 months I have been using this model for both work and personal usage and it’s my weapon of choice when needing a mobile powerhouse without breaking my back. Performance is great (you can get better these days, I got one of the last pre-Penryn models) and overall it’s a reliable and sturdy device.

So last week I was going over some security principles and decided that file-based encryption wasn’t enough for my mobile system. I decided to look at drive encryption and for my scenario I had 2 very good and supported choices:

·         Windows Vista Bitlocker
I run Windows Vista Ultimate x64 so using Bitlocker would be a viable option for me

·         HP Protecttools Drive Encryption
The official business-level encryption solution provided by the OEM, HP, itself.

At first I wanted to use Bitlocker and I used the Bitlocker preparation Vista Ultimate Extra to prepare my harddrive for Bitlocker usage. The tool however refused to use my harddrive as it didn’t understood some of the partitions located on the drive (yes, even I have a dualboot to Linux, don’t like it tough) and it refused my harddrive.

Too bad and I decided to use the OEM-supported solution HP ProtectTools Drive Encryption. I figured as HP is a large and  good company (who has always given me great tech support here in the Netherlands), there would be no recovery issues in the event something should go horribly wrong.

And boy did things go wrong…

Earlier this month I turned on Drive Encryption in the software (which is buggy, doesn’t autolaunch the admin tool as Administrator in Windows Vista with UAC turned on, crap HP software). It took about 2 hours to encrypt my drive and it installed a little on-the-fly decryption app in the bootloader. All was working great and performance was still very good. I backed up a recovery key to 2 different USB sticks (just in case). It also asked me whether I wanted to use the online recovery service. As the service does nothing but store your decryption key for a ridiculous amount of money / year, I declined and used the USB-only solution.

Exactly one week ago, Thursday afternoon, I was prepping a demo I was going to give the following day @ 9AM. At around 15:00, I was done with my notebook and switched it to standby. Sometime later I had to change some boot arguments of the Windows Vista bootloader and used a few applications to reflect the changes needed (who I’m guessing rewrote the Vista bootloader, nothing fancy). All was good and I rebooted to test my changes and I noticed it didn’t load the HP decryption software (usually asking me for my password) and it just gave me a flashing cursor.

I rebooted again .. same. I booted a recovery dvd with a few partition manager applications on it. Double checked whether Vista partition was the active one. It of course was. I booted the Vista DVD and try to use auto fix. It couldn’t find my Windows drive (which is explainable as it is encrypted).

The HP system relies on the bootloader software to be present in order to decrypt the harddrive. Messing with the bootloader (which a normal OS installation next to you current OS would also do), seems to wipe away the HP software. Ok great.. now I have a locked drive.

Next up .. recovery.. I had my decryption key but no means to use it as the recovery option was a part of the bootloader decryption software. I quickly visited the HP.com support site in search of a recovery solution for the encrypted harddrive. No luck. Googled on the product name and found nothing usefull.

I quickly rang up HP Netherlands as it was about a hour before lines closing. Quickly got a pro (no level-1/level-2 filtering here, GREAT!) and explained the situation. However unfortunately due to some issues with the phone systems when using T-Mobile as a provider, I got disconnected. This happened a number of times and I quickly switched to landlines (after being on hold and being disconnected 3x). Ultimately had an employee working with me on how to resolve the issue. No luck. I explained my level of expertise on Windows Vista and systems overall and we both gave great ideas on how to possibly resolve the issue (recover the drive or reinstall the bootloader software). He looked in the central database and had no luck. It was over closing time and they had to cut the call short (which I understand). I asked them whether HP USA could help me further as they are 24/7. The Dutch support line said no as they use the same internal support KB.

I was getting late and quickly went to the shops to grab some food before they all closed. Some cooking later, I was looking at the software being used by HP for the encryption. HP ProtectTools uses a branded version of Safeboot (www.safeboot.com, now owned by McAfee). I again searched the internet but didn’t find a lot of useful stuff. One forum post noted the name (which I can’t say according to HP) of a recovery solution used by enterprises.

Via sources (I’m not allowed to say which ones according to HP) I got my hands on the decryption DVD. Great! Quickly inserted the disc and booted the system yet again. “Please enter daily 4 digit code”. Oh .. euh. 1234 .. nope. Tried some other numbers and couldn’t guess the number. I opted to cancel and the recovery app locked down. It had one other option “Activation via HP backup”. Hey! I have that. Inserted my USB stick and selected the file. “Valid”. Awesome! .. “Now please enter 4 digit daily code”. Arghh.

Looked up the support number for the Safeboot tool. The Dutch number was disconnected as McAfee had bought them. When trying the US number, I got connected to McAfee Enterprise support. I opted for Safeboot support. 1 minute waiting later, I had a tech person on the line. I explained my situation and stated I had the software. Just needed the key. The kind sir explained nicely to me they couldn’t give me the key without the proper SLAs. I understood however still lame the only thing holding me is a 4 digit code which the guy had displayed on his screen but couldn’t give me. I tried asking real real nice. Nope .. no go. He advised me to ring up HP USA.

So I did. Got disconnected 3 times whilst waiting (and having to pass the horrible voice-activated menu’s, what’s wrong with keyinput?) and had to wait another 15 minutes. Ultimately I got my tech person on the phone. Took about half an hour to explain the situation. Of course the ma’am couldn’t find anything in the KB either. I also explained my situation was urgent and I had to have the drive back before 9AM next morning. She would “look into it and do some research” while I would wait on hold (with the WORST waiting music EVER). I waited for up a to an hour. She was no help and couldn’t find anything. It took her over 90 minutes to realize with the Dutch guy did in 15 minutes. Ultimately she rang McAfee USA again and we had a little conference call (after I waited another 30 minutes whilst she was explaining the situation to McAfee). Ultimately I had the McAfee tech guy on the phone but again just like before, they couldn’t do anything for me.

I thanked them both and hang up (as waiting any longer or making a escalation ticket would be pointless and take way too long).  Nearly 5 hours of calling, waiting and being disconnected, I was no further in my quest to unlock my harddrive.

Another desperate 15 minutes of Googling and ringing up 4 IT Pro’s out of their beds, I gave up. I decided the best thing to do, was to wipe the harddrive and install a clean image. As I was using special software for the demo the following day, I couldn’t just use a backup. I had to reinstall from scratch. Of course all my documents and vital information was backed up to external hdd, LAN share and trusty Sharepoint sites so that wasn’t a too big a problem. However I did took me another couple of hours to setup the demo software again from scratch. By the time I got in bed, it was nearly 4AM.

The following day I got up at 7AM and give my demo at 9AM using my cleanly installed software (which went great dispite the 3 hours of sleep). Stayed on location till 6PM. After that I went to a friends house for dinner. Fixed his internet and had a good time. By the time I was back in my bed, it was 3AM/4AM.

So basically HP is providing a encryption solution they cannot support or recover for you in case something should go wrong. There are no external decryption tools provided. If you are using HP ProtectTools Drive Encryption right now, I really suggest turning it off and migrating away from the solution. At the very least, find some way to backup your bootloader containing the decryption software.

As for the recovery service which SafeBoot is providing for HP.. It’s a yearly fee to store your (kinda useless) recovery key online and a support service (allowing you to ring the 2 McAfee persons I talked to earlier directly). I asked McAfee whether that would have saved me in my situation had I taken up the subscription. The short answer: No. They only provide you your key and provide support for resetting the password remotely. They don’t provide support when your bootloader committed suicide.

I’m never ever using full drive encryption software by HP again! Perhaps HP could have given me a better solution had I waited a couple of days so they could escalate the problem to other departments and McAfee. I didn’t have the luxury of time, and you might not too when things go wrong. Stay away from HP Drive Encryption solutions (or anything Safeboot related).

One small note: I heard that Safeboot supported the HP software directly via their own helpdesk line thus unloading complex support calls to the HP helpdesk. However McAfee bought Safeboot in 2007. The HP agreement still stands but support is limited to enterprise SLA holders only.





Emergency Patch.. The effect on installations?

October 24, 2008 – 01:46

This post is about the emergency patch release today on Thursday 23rd of October. For more info: http://bink.nu/news/emergency-patch-details-server-service-vulnerability.aspx. This a re-posting of the following Bink story: http://bink.nu/news/emergency-patch-the-effect-on-installations.aspx

Microsoft has been quick to act on informing IT pros and the general public on the security issue in nearly every NT-based Windows version out in the wild however more details are still lacking.

The bug concerns the Server service found in all NT-based Windows OS responsible for communication between computers in a Windows based Network allowing for remote execution of code.

Bink first reported the issue along with a link to the rather small KB article. Since then Microsoft updated the article (several times?) to provide more information to the public. Questions are raised after seeing this additional information.

Why are Windows 2000 / XP / 2003 rated “Critical” and why are Vista and 2008 rated “Important”?

Why is there information available on what could happen on Windows 2000 / XP / 2003 systems but not on what could happen to Vista and 2008 systems?

Why are Windows Server 2008 Core installations effected?

Who found this critical flaw? (Internal or external reporting)

How come Windows 7 is effected? (This also confirms the bug is in the deep roots of the NT Server service and no major overhaul is taking place in concerning these types of services in Windows 7, not that a overhaul was expected.)

The updated are available to all users via Windows Update right now. All systems using the default autoupdate settings should get the patch tonight. For enterprise deployment, please refer to the deployment guide.

Hopefully when the systems are patched, we could get a glimpse on how this bug works and how it could be there has been a flaw in a modern and secure system for over 8 years now. More information will be posted as it comes available.





Microsoft NL confirms Windows Server 2008 R2 is in fact Windows 7?

August 13, 2008 – 16:42

This morning the monthly newsletter from the Technet team in the Netherlands was send out to thousands of Dutch IT Pros. Usually these have little news to me as it is mostly a summary of things going on and happening within Microsoft and new products released last few weeks. Every month Microsoft-vet Tony Krijnen writes this letter and sends it out.

However … this month I noticed something different and consulted co-writer Raymond Comvalius. What was written surprised us both. Tony wrote in his letter “Zo hebben Daniël en ik net een uitgebreide training achter de rug over de mogelijkheden van Windows 7 (Windows Server 2008 R2) en alles over het Software+Services concept”. (Translation: Daniël and I just completed an extended training on the features of Windows 7 (Windows Server 2008 R2) and on everything related to the Software+Services concept).

The most remarkable bit being of course the notation of Windows Server 2008 R2 right after Windows 7 thus meaning Windows Server 2008 R2 will be based on Windows 7? One can only speculate at this point as Microsoft won’t talk on Windows 7 openly just yet.

Little is known on Windows Server 2008 R2. In May 2008 first details started to show: http://bink.nu/news/windows-server-2008-r2-planned-for-2009.aspx. A little fact that we do know is that Windows Server 2008 R2 will be x64-only as Windows Server 2008 is confirmed to be the last server edition of Windows to support x86.

Naming the new  version (of Windows Server) Windows Server 2008 R2 is a good move in my mind as  it won’t scare people away from Windows Server 2008, waiting for the new version (for instance Windows Server 2009). Making it sound like it’s not a huge upgrade, will make sure the adoption of Windows Server 2008 stays on track.





Hardware ramblings

August 3, 2008 – 17:05

Ugh

As if the summer heat wasn’t bad enough in my home office (26C with AC, 32C+ without), it now officially killed one of my HDDs.

About 3 months ago I bought three new 750GB Samsung F1 disks and had put them all in RAID. All was sailing smooth and the speeds were amazing. However this last Wednesday I was working with multiple virtual PC’s whilst downloading and extracting large files in the background.

Whilst extracting, WinRAR threw an CRC errors. This can happen and luckily this can be fixed using some freeware utilities. I had set QuickPAR to fix the issues .. it crashed after a few minutes. Hmm strange…

Shortly after that explorer crashed and burned. I quickly saved all the data and rebooted the workstation. The Intel RAID manager (ICH9) threw an error: “Problem occured in disk 2″. Oh dear.

Surprisingly Vista booted through it but it was quite unstable. Excel would crash every 5 minutes. I stopped the computer again and took out the HDDs. They felt as if they were on fire (which is strange as they have active cooling on them and the aircon in the room was turned on). I’d let them cool down a bit, lay them beside the casing and targeted some extra casefans on them.

Booted through again .. again the RAID warning. Windows booted and looked stable enough. Using the Intel Storage Manager app I resetted the HDD back to normal state and all was fine. Some heavy I/O later on, thing became unstable again. Double checked the Intel app again: Disk 3 error.

Nice :\ … so HDD3 is officially dying. I got all the data on external backups so that was a problem. I killed the RAID, took the disk out and recreated the RAID with just 2 disks. Fast enough for me I guess. Sending the dying one to Samsung once it’s gone through the KillDisk hell.

As some of you may know, I picked up a Geforce 8800GT and I loved it. I, however, didn’t like the cooler that much. A singleslot cooler with a very loud fan on it. It was fair enough when idle. However put some load on it and it sounds like it would take off and take the PC with it. Two weeks later I ordered a new cooler and have waited for it to be shipped. After being in backorder for nearly 2 months, I canceled it.

This week I picked up the Zalman VF-1000. Installation was a charme (for me at least) but ended up fighting the tightness in my Antec P180 in order to install the fan header. After 10 minutes of trying to hook the damn thing up, I gave up and got myself a molex-3pinfan converter from the old cabinet. Hooked it up, worked perfectly.

As for the VF1000 performance, haven’t done real temperature measurements yet, but I’m not too fond of it to be honest. The low noise setting makes a rumble noise (like a seeking HDD) and the high-speed setting is only slightly more silent over the stock fan. But the overall exhaust heat is less so that helps.

I guess we’ve come to a point that hardware is so overpowered, silence is becoming a luxury most people won’t be able to afford. That’s what we get for pushing it :)





Site has a new logo

July 25, 2008 – 22:04

The site now has a new logo thanks to designer and personal friend Thijs van Gils. I used to have the default logo used by the theme (pop-blue). Many times I’ve tried to whip something up in Photoshop, but no success. Guess I should stick to my day job for now.

Thijs van Gils is a creative designer of multiple disciplines. He often creates diverse pieces of design. I don’t always get them as I tend to think in straight lines.. but then again it’s nice we’re not all alike because then the world would be very boring. Big thanks again to you Thijs. Included below is a little teaser of some of his work..


Vine Hallway from Thijs van Gils


Raindrops Intro from Thijs van Gils

You can reach Thijs on info at thijsvangils.nl





Most meaningfull image all month…

July 25, 2008 – 00:27

This is one of the most meaningfull images I’ve seen all month..

Why? you might ask.. Well .. just a little while ago I wrote about Sherweb eating my email and how it kinda pissed me off. One example was my hotel reservation I made about a month ago. Didn’t recieve the email at all. Even if I forwarded it myself using Windows Live Mail…

As DNS is updating (after correcting some server-side errors for the MX records) most of my email is coming in at the new server. Quickly I tested the (for me now famous “hoteltest”) spam filter on the new server by forwarding the email again to my mailbox.

A blank email with the url “http://www.choicehotels.com” went straight for the Junk Mail folder. However the forward of the orginal message went great and it landed securely in my inbox (or Postvak IN)!

Meaningless to you, allot to me ;)