Monthly Archives: September 2012

Friday Shorts – .net AJAX Autocomplete with no webservices, youcanthavethisforapassword, Education VMUGS and more

Alright, here we go, week 2 of this series of posts…enjoy ūüôā

Using the AJAX Autocomplete in .net without engaging web services

I’ve found a new appreciation for the autocomplete functionality that languages such as ColdFusion provide out of the box. In a .net project I have been working on I simply wanted to have a textbox where the end user could begin typing in a students name and have the application make suggestions based on what they were typing and what was stored in one of my database tables. Easy enough right? No! You see, most of my googling resulted in setting up webservices to serve the data to the textbox. All in all it seemed pretty ugly. In the end I figured out how to avoid the webservices call altogether following a great article on aspsnippets.com. Obviously you need to tweek to get the results you want, but it all works in the end…trust me!

Seriouisly Microsoft – Only 16 character passwords

I seen a tweet from John Troyer this week which eventually lead me to this article. Now it seems kind of ridiculous to me! What’s the logic in only letting people have a 16 character password? Now my password is a lot less than that and I probably wouldn’t have one any bigger than that but still…It just doesn’t make sense why they would limit a password length – why lessen your security? And what have they done with those users that are already over 16 characters. The section on whether or not they have only hashed the first 16 characters of your password is interesting and honestly I wouldn’t be surprised if that is the way they went. Either way, it’s a great article, have a read and see if you are as dumbfounded as me…

Vertical based VMUGS

In an effort to share knowledge, learn from our peers and just plain ol’ get together we are now, along with a handful of other public school districts are getting together to share ideas, fixes, scripts, etc with each other. So this is planned for a few times a year and based on certain common types of technologies that we all work with, VMware being one of them. That got me to thinking. I love the structure of the VMUGs and I find them extremely valuable on a personal and a business level. However, implementing something into an educational environment vs almost any other environment is a completely different type of beast! There’s a slew of requirements and constraints associated with education. I’d love to see a series of VMUGs or learning sessions or whatever they could be called be held based on business vertical. Off the top of my head you could have Education, Healthcare, Government, etc…. Not saying we need one per quarter, but a couple per year would be cool…ah well, a man can dream…

Happy Birthday mwpreston dot net

As you’ve probably already guessed from the name of this post mwpreston dot net is finally in the books as being one year old. Honestly this is a fairly big accomplishment for me. It’s been a long ride since those first few blog posts (Hey, Who’s the new guy? and VMworld 2011 and the community that surrounds it) ¬†Before starting this blog I have tried on numerous occasions to start others, all sort of falling by the wayside and ending up with me just giving up! So what was my key to obtaining success with this one? I’m not really sure, I think just sticking with it and comitting the time to try to get at the very least one post a week out there. Finally I started to get some readers, then the sponsors came and its been a great ride since then!

So what has the first year entailed for this blog? Well, for starters I’ve had some great sponsors (Veeam, PHD Virtual, AppAssure, Starwind and BitRefinery) come on board. This¬†definitely¬†helps cover costs of hosting and gear that it takes to produce the content. I’m very grateful to have them on the site! Secondly this blog played a pivotal role in my reciving the vExpert designation for 2012. I can’t tell you how much that award means to me. To be recognized by the company who’s technology you have so much passion for is amazing and humbling. And lastly (but most certainly definetly not even close to least) this blog has given myself the avenue to share back any knowledge I can with the community that I love and have learned so much from! A community that has brought me from your standard sysadmin, to a VCP, to a VMworld attendee to a vExpert! Its truly awesome to be able to share, engage, and participate within this group!

And to close out this wonderful birthday I have a few tidbits of stats to share…

That’s really all I have for now. Although some of the numbers are low I’ve very proud of the success I’ve had thus far and very grateful for my readers and their comments they have left. ¬†Thank you all so much for reading and Ill do my best to continue to blog as much and as often as I can.

Friday Fixes and Feelings – .net validation, NHL Lockouts, iOS 6 and more

Ok, so here is my attempt at weekly post that will contain a whole lot of random fixes and tweaks that I’ve done or learned throughout the week. ¬†This may or may not have to do with virtualization or even technology for that matter. It’s basically just an assortment of random thoughts, fixes, and links ¬†that really don’t warrant a full blog post yet I still would like to share with the world ūüôā

So here we go…

Validating hidden form elements in asp.net

I’ve been playing with .net for the past few weeks and ran into a situation where I wanted to have a hidden form element but still use asp’s field validation with it. ¬†I thought I could just do the following and set the visible property to false

<asp:TextBox ID="MyHiddenField" visibile="false" minlength="1" runat="server"></asp:TextBox>

However this seems to cause the <asp:requiredFieldValidator> to not process the textbox at all. ¬†So in order to get this to work you need to use the old school css way to hide it like follows…

<asp:TextBox ID="MyHiddenField" style="display:none;"  minlength="1" runat="server"></asp:TextBox>

Your validation should now work as expected ūüôā

iOS 6 – I got in at 1:03

So the new Apple iOS 6 was released on Wednesday at¬†roughly¬†1pm. ¬†At about 1:15 I had it on my iPad. ¬†Honestly, I don’t see much of a difference but I’m not a heavy iPad user anyways…As well, I only have an iPad 2 so no SIRI for me ūüôĀ – In hindsight it’s probably for the best as those people that sit on buses and trains talking into their iPhone/iPad look a tad bit crazy IMO. ¬†Siri, make me a sandwich!

Some really annoying PowerShell

Arggghh! ¬†All I want to do is create an OU and specify turn off the Protect from accidental deletion flag. ¬†Guess what? ¬†There’s no -ProtectFromAccidentalDeletion option on the New-ADOrgranizationalUnit cmdlet, only on the Set-ADOrganizationalUnit cmdlet. ¬†I know you could | and do crazy PowerShell Guruness like type things to get it one line but it’s still annoying! ¬†Why can’t I just do it all with the New cmdlet? ¬†Oh well, this will have to do…

New-ADOrganizationalUnit -Name "OU_Name" -Path "Path_to_parent OU"
Set-ADOrganizationalUnit -Identity "OU=Full_Path_To_OU" -ProtectedFromAccidentalDeletion $false

Looks like no NHL season – for now!

So the day that everyone knew would come has came and went and the NHL players have been locked out! ¬†Although I understand that professional sports leagues need to be run like a business and it’s always dicey when money is involved it sucks that the two sides just can’t come to an agreement or tentatively use the previous one – for the sake of the game and the fans. ¬†Speaking of fans – if the league is indeed a business then the fans would most certainly be their customers – and if the store is no longer there, customers will go somewhere else. ¬†Here’s hoping the NHL can get there $%@! together and get on the ice!

My son started hockey for the first time.

Speaking of hockey, my son Hayden went to hockey for the first time this year and in his life! ¬†He was pretty pumped to go (as was I) and did great! ¬†He was in a skating program last year which really helped, but it is certainly a different kind of beast when you attach a ton of equipment to such a little body and throw them on the ice! ¬†I’m glad I was able to join him out there as I think it really helped. ¬†Anyways, he goes twice a week so there is lots of time to improve.

Hey Montreal – Sign Subban already!

¬†I said in my¬†about page¬†that you may see the odd rant about the habs and it may have taken a year but I’m ready to do that now! ¬†PK Subban is perhaps one of the most electric, fan pleasing players to hold the blue line position inside the Bell Centre in a long time. ¬†He’s young, strong, and exciting to watch. ¬†The fans love him, the rivals hate him – Why is this guy not signed yet. ¬†I understand that the lockout certainly causes complications but what I don’t understand is why the Montreal Canadiens organization seem to devalue these types of players, players that could stay and be a fan¬†favourite¬†for a long time. ¬†They have already inked their young goaltender Carey Price and are ensuring that he will stay around for at least 6 years. ¬†Why not just complete the bromance? ¬† Just sign him already before he goes somewhere else and lights it up.

Yet another VMworld wrap-up (I know, I’m really late to the party)

I know, VMworld is sooooo two weeks ago, the biggest announcement of vSphere 5.1 has already been delivered and is GA and the world is all basking in its new features and enhancements, the vCloud suites have been blogged to death, most of the sessions have even been made available on the VMworld Socialcast site, so why go and throw yet another VMworld post out there? Well, it was VMworld last year that gave me the final push to start this blog (see post here) and a lot of vGoodness has happened to me since then ( sponsors, certifications, vExpertiness) so I guess i just feel like i owe it to the VMworld gods to throw out my experience at the show.

Last year was my first VMworld and to tell you the truth i had no idea what to expect and after the first day lets just say i was a little overwhelmed, crazy tired and a whole lot excited. So this year i knew what to expect and thought i was more than enough prepared for the awesomeness the show could throw at me….well, not really, i was left with the same symptoms i had in 2011. I had no idea what was in store for me that week in San Francisco but by no means was I ready for what was to unfold. A few highlights of my week below…

I got to meet Pat Gelsinger and Steve Herrod at the CTO reception. How cool is that? You know, just chattin it up with CEO and CTO of the billion dollar company that produces the software that has been consuming every ounce of your free time.  Let me say, being a vExpert at VMworld is pretty awesome!

I had dinner with a bunch of rockstars. I had the chance to sit down and have a fabulous dinner with John Troyer, Martin Klaus, Ben Scheerer, David Davis, Eric Sloof, Tommy Trogden, and vCOps contest winner Joe Filippello. ¬† Due to the massive amount of brainpower in that room you can imagine there were some great conversations – and the food was fabulous. Thanks Ben for the invite and the re-invite ūüôā

My session (OPS-CIM1940). I had the opportunity to participate in a panel session (titled Real World stories of Operational Performance Troubleshooting, Capacity, and Configuration management with vCenter Operations Suite) with a few other attendees and present my stories and experiences with vcops to over 600 people. Never had I spoke in front of that many people before so i was a little nervous but overall i think the session went great and am thankfull for the opportunity

Last but not least is this group of guys (and girl). Honestly they truly make the conference what it is. Most i knew from Twitter¬†already. ¬†Some I met at VMworld 2011, and some I met for the first time this year. ¬† These guys truly made the social part of the conference awesome! ¬†Great group of guys and watch big things to come out of this group ūüôā
There really isn’t much information in this post that anyone will benefit from in it and it probably comes off like a little bit of bragging (cuz it is :)). ¬†Either way I guess one takeaway you can pull out of it is get yourself to a VMworld! ¬† Aside from the massive amount of technical information you can bring back, the real value is the contacts you make. ¬†Every subject matter expert is there and no question I had during the show went unanswered, so just get there! ¬†See you in Barcelona!!! – actually I won’t but it just sounded like a good ending…. ūüôā

Customize the VMware vSphere Health Check to only email report if there is a hardware issue.

One of the things that I love most about utilizing vCenter Server to manage my hosts is the ability to generate a nice little email alert when any hardware within my hosts decides to go a little offside. ¬†That being said there are a lot of times when I don’t have vCenter and am trying to monitor hardware failures on the free ESXi Hypervisor. ¬†This as always been a challenge of some sorts and usually the solution that I end up using is William Lam’s vSphere Health Check Report on top of the vSphere Management Assistant (VMA).

The vSphere Health Check report is an awesome perl script written by William Lam that generates a very thorough report containing almost everything you would need to know about a host and the VMs that are residing on it. ¬†After the script is done running you get a nice little email such as the following….

As you can see there is a slew of information included in the health check report – and don’t take this the wrong way, this is all great information and very nice to have as a little report waiting for you in your inbox every morning ¬†Howerver, the goal I had was to take this script, add it to a cronjob on my VMA, and modify the code so that I only get an email and the attached report if I have a hardware issue. ¬†So to get started go ahead and get your VMA setup if you havn’t already (I think you can use any version of the remote CLI if you don’t have VMA) and go and download version 5.02 of the VMware vSphere Health Check report (The instructions to configure and install it are on the download page as well).

So, now with the customization, around Line 289 (your line numbers may differ as I’ve been in there hitting enter :)) I’ve added a few variables. ¬†$HOSTISSUES is simply going to be a boolean variable that we will flag as yes if we run into any warnings or errors when parsing the hardware health and $emailMessage is a variable that will house those issues so we can place them directly inside the body of the message.

my $VM_TOOL="yes";
my $VMW_APP="yes";
my $VPX_SETTING="yes";

#mwpreston - additions 
my $HOSTISSUES="no"; 
my $emailMessage="";

############################
# START OF SCRIPT
############################

So on we go into the meat and bones of the script. ¬†Around line1930 or so you should see where the script actually goes in and checks the health of the hosts. ¬†Basically what I have done here is if the script finds any issues at all from within this section (anything that isn’t green) I will flag $HOSTISSUES to yes and append the issues to $emailMessage. ¬† I’ve highlighted each spot below where I have added code but you can chose to add it where you like, meaning if you don’t care about a memory error, don’t include it there, etc…

######################
# HEALTH
######################
if($HOST_HEALTH eq "yes") {
	if($local_host->runtime->healthSystemRuntime) {
		if($local_host->runtime->healthSystemRuntime->hardwareStatusInfo) {
			my $hardwareStatusInfo = $local_host->runtime->healthSystemRuntime->hardwareStatusInfo;
			my ($cpuInfo,$memInfo,$storageInfo);
			$healthHardwareString .= "<tr><th align=\"left\">".$host_name."</th></tr>\n";
			my ($sensor_health_color,$sensor_health) = ("","");;

			if($hardwareStatusInfo->cpuStatusInfo) {
				$cpuInfo = $hardwareStatusInfo->cpuStatusInfo;
				foreach(@$cpuInfo) {
					$sensor_health = $_->status->key;
					if ($sensor_health =~ m/green/i) { 
						$sensor_health_color="<td bgcolor=\"$green\">OK</td>"; 
					}
					elsif ($sensor_health_color =~ m/red/i)	{ 
						$sensor_health_color="<td bgcolor=\"$red\">PROBLEM</td>";
						#MWPRESTON - added following 2 lines
						$HOSTISSUES="yes"; 
						$emailMessage .= $_->name."\n"; 
					}
					elsif ($sensor_health_color =~ m/yellow/i) { 
						$sensor_health_color="<td bgcolor=\"$yellow\">WARNING</td>"; 
						#MWPRESTON - added following 2 lines
						$HOSTISSUES="yes"; 
						$emailMessage .= $_->name."\n"; 
					}
					else { 
						$sensor_health_color="<td bgcolor=\"gray\">UNKNOWN</td>"; 
						#MWPRESTON - added following 2 lines
						$HOSTISSUES="yes"; 
						$emailMessage .= $_->name."\n"; 
					}
					$healthHardwareString .= "<tr><td>".$_->name."</td>".$sensor_health_color."</tr>\n";		
				}
			}
			if($hardwareStatusInfo->memoryStatusInfo) {
				$memInfo = $hardwareStatusInfo->memoryStatusInfo;
				foreach(@$memInfo) {
					$sensor_health = $_->status->key;
					if ($sensor_health =~ m/green/i) { 
						$sensor_health_color="<td bgcolor=\"$green\">OK</td>"; 
					}
					elsif ($sensor_health_color =~ m/red/i) { 
						$sensor_health_color="<td bgcolor=\"$red\">PROBLEM</td>"; 
						#MWPRESTON - added following 2 lines
						$HOSTISSUES="yes"; 
						$emailMessage .= $_->name."\n"; 
					}
					elsif ($sensor_health_color =~ m/yellow/i) { 
						$sensor_health_color="<td bgcolor=\"$yellow\">WARNING</td>"; 
						#MWPRESTON - added following 2 lines
						$HOSTISSUES="yes"; 
						$emailMessage .= $_->name."\n"; 
					}
					else { 
						$sensor_health_color="<td bgcolor=\"gray\">UNKNOWN</td>"; 
					}
					$healthHardwareString .= "<tr><td>".$_->name."</td>".$sensor_health_color."</tr>\n";
				}
			}
			if($hardwareStatusInfo->storageStatusInfo) {
				$storageInfo = $hardwareStatusInfo->storageStatusInfo;
				foreach(@$storageInfo) {
					$sensor_health = $_->status->key;
					if ($sensor_health =~ m/green/i) { 
						$sensor_health_color="<td bgcolor=\"$green\">OK</td>"; 
					}
					elsif ($sensor_health_color =~ m/red/i) {
						$sensor_health_color="<td bgcolor=\"$red\">PROBLEM</td>";
						#MWPRESTON - added following 2 lines
						$HOSTISSUES="yes"; 
						$emailMessage .= $_->name."\n";
					}
					elsif ($sensor_health_color =~ m/yellow/i) { 
						$sensor_health_color="<td bgcolor=\"$yellow\">WARNING</td>";
						#MWPRESTON - added following 2 lines
						$HOSTISSUES="yes";
						$emailMessage .= $_->name."\n";
					}
					else { 
						$sensor_health_color="<td bgcolor=\"gray\">UNKNOWN</td>";
						#MWPRESTON - added following 2 lines
						$HOSTISSUES="yes";
						$emailMessage .= $_->name."\n";
					}
					$healthHardwareString .= "<tr><td>".$_->name."</td>".$sensor_health_color."</tr>\n";
				}
			}
		}
		if($local_host->runtime->healthSystemRuntime->systemHealthInfo) {
			my $sensors = $local_host->runtime->healthSystemRuntime->systemHealthInfo->numericSensorInfo;
			$healthSoftwareString .= "<tr><th align=\"left\">".$host_name."</th></tr>\n";
			my $sensor_health_color = "";
			foreach(sort {$a->name cmp $b->name} @$sensors) {
				my $sensor_health = $_->healthState->key;
				if ($sensor_health =~ m/green/) { 
					$sensor_health_color="<td bgcolor=\"$green\">OK</td>"; 
				}
				elsif ($sensor_health_color =~ m/red/) { 
					$sensor_health_color="<td bgcolor=\"$red\">PROBLEM</td>";
					#MWPRESTON - added following 2 lines
					$HOSTISSUES="yes";
					$emailMessage .= $_->name."\n";
				}
				elsif ($sensor_health_color =~ m/yellow/) { 
					$sensor_health_color="<td bgcolor=\"$yellow\">WARNING</td>"; 
					#MWPRESTON - added following 2 lines
					$HOSTISSUES="yes";
					$emailMessage .= $_->name."\n";
				}
				else { 
					$sensor_health_color="<td bgcolor=\"gray\">UNKNOWN</td>"; 
					#MWPRESTON - added following 2 lines
					$HOSTISSUES="yes";
					$emailMessage .= $_->name."\n";
				}
				my $reading;
				if(defined($_->rateUnits)) {
					$reading =  &restrict_num_decimal_digits(($_->currentReading * (10 ** $_->unitModifier)),3) . " " . $_->baseUnits . "/" . $_->rateUnits;
				} else {
					$reading =  &restrict_num_decimal_digits(($_->currentReading * (10 ** $_->unitModifier)),3) . " " . $_->baseUnits;
				}
				$healthSoftwareString .= "<tr><td>".$_->name."</td><td>".$reading."</td>".$sensor_health_color."</tr>\n";
			}	
		}
	}
}

And finally you need to modify the emailReport function in order to check for HOSTISSUES (since we don’t want to email unless we have an issue) and also attach $emailMessage to the body of the message. ¬†This function is near the top of the script starting at roughly line 325. ¬†My changes are below….

sub emailReport {
	#MWPRESTON - modified if statement to include HOSTISSUES
	if($email eq "yes" and $HOSTISSUES ne "no") {
		my $smtp = Net::SMTP->new($EMAIL_HOST ,Hello => $EMAIL_DOMAIN,Timeout => 30,);

		unless($smtp) {
	                die "Error: Unable to setup connection with email server: \"" . $EMAIL_HOST . "\"!\n";
        	}

		open(DATA, $report) || die("Could not open the file");
		my @report = <DATA>;
		close(DATA);

		my @EMAIL_RECIPIENTS = $smtp->recipient(@EMAIL_TO,{SkipBad => 1});
		my $boundary = 'frontier';
		$smtp->mail($EMAIL_FROM);
		$smtp->to(@EMAIL_TO);
		$smtp->data();
		$smtp->datasend('From: '.$EMAIL_FROM."\n");
		$smtp->datasend('To: '.@EMAIL_TO."\n");
		$smtp->datasend('Subject: VMware vSphere Health Check Report Completed - '.giveMeDate('MDYHMS'). " (" . $system_name . ")\n");
		$smtp->datasend("MIME-Version: 1.0\n");
		$smtp->datasend("Content-type: multipart/mixed;\n\tboundary=\"$boundary\"\n");
		$smtp->datasend("\n");
		$smtp->datasend("--$boundary\n");
		$smtp->datasend("Content-type: text/plain\n");
		$smtp->datasend("Content-Disposition: quoted-printable\n");
		#MWPRESTON - added following 2 lines.
		$smtp->datasend("\nProblems have been detected with the following\n");
		$smtp->datasend("\n$emailMessage\n");
		$smtp->datasend("\nReport $report is attached!\n");
		$smtp->datasend("--$boundary\n");
		$smtp->datasend("Content-Type: application/text; name=\"$report\"\n");
		$smtp->datasend("Content-Disposition: attachment; filename=\"$report\"\n");
		$smtp->datasend("\n");
		$smtp->datasend("@report\n");
		$smtp->datasend("--$boundary--\n");
		$smtp->dataend();
		$smtp->quit;
	}
}

If you would like the complete modified script you can get it here – honestly, I would¬†recommend¬†going and downloading Willams version first ¬†and then make the required changes to it. ¬†Since his script seems to be actively updated and worked on, whereas mine here will probably remain pretty static. ¬†Again, I haven’t thoroughly tested this and it’s a use at your own risk type thing – and I’ve only applied these changes in version 5.02 of Williams script.

Again, any comments, concerns, questions, or if you just need help setting up the script or cron job let me know in the comments box below.

Hide those ‘Getting Started’ tabs in the #vSphere 5.1 Web Client

OK another quick post with some hopefully useful information for someone..

Remember these?

And how we could select Edit-Client Settings and uncheck the following box to get rid of them.

That was great, but guess what, now we have these….

So how do we get rid of them. ¬†Easy! – Just go to help and select ‘Hide All Getting Started Pages’

There you go, all gone Рyou know longer have to sit and read the definitions of what a Cluster or Datacenter is!!!  Just throwing this out there due to the fact that those tabs tend to annoy the crap out of me!  #JustSayin 

The infrastructure behind this post was provided by #vAutoLab. ¬†What? ¬†Serious? ¬†You’ve never heard of it? ¬†Craziness, get on over to www.labguides.com and give it a go! ¬†It’s awesomesauce!