VMGuru.com - Home of the Virtualization Gurus

Our Books REALLY are Available Now!

Don’t become overwhelmed by your VMware Infrastructure project. Use the books that tens of thousands of others have used to design, plan, and implement their virtual infrastructures.Download Now!

Scripting
Fun with PowerShell - Calculate Permutations PDF Print
Written by Scott Herold   
Saturday, 13 June 2009 22:17

I got sidetracked on Twitter tonight with a conversation between @jasonboche and @vmdoug, and since my wife is out of town visiting family I figured what better way to spend a Saturday night than to write a quick PowerShell script that can calculate the number of unique permutations based on 2 criteria.

First is the total number of available elements.  in this case, we were looking at the number of available URL combinations on bit.ly before they would "run out".  Without spending any more than 15 seconds investigating, I determined that bit.ly uses only alphanumeric keys, but is case sensitive.  That means we have 26 uppercase letters, 26 lowercase letters, and 10 integers (0-9).  That gives us 62 total elements.

The second criteria is the number of total elements used in the combination.  In this case, bit.ly still uses 5 character URL strings.

The math behind this is something that I actually still remembered from high school oh so many years ago and is P = n!/(n-r)! where P is the number of Permutations, n is the total number of available elements, and r is the number of elements used in the combination.

Borrowing a function from stackoverflow.com (The nested loop calculation was pissing me off so I had to cheat), I was able to put together the following PowerShell script that can rather quickly do basic permutation calculations.

function factorial( [int] $f ) 

$result = 1
if ( $f -gt 1){
$result = $f * ( factorial ( $f - 1 ) )  
}
$result
}
 
function permutation( [int] $n, [int] $r )
{
(factorial $n) / (factorial ($n - $r) )
}
[int] $n = Read-Host "Total number of available elements:"
[int] $r = Read-Host "Total number of elements in combination:"
 
if ($n -ge 1 -and ($n - $r) -ge 0) {
permutation $n $r
}
else{
Write-Host "Invalid input parameters"

 

So, when all is said and done, by using this script we can determine that when using 62 total elements in 5 element combinations, bit.ly currently has 776,520,240 URL combinations available.  if they were to change to a 6 character URL, the number jumps to 44,261,653,680, in addition to the 776,520,240 combinations from their 5 character URLs.  I think its safe to say that as long as the bit.ly database can handle the load, we don't need to worry about them running out of URLs any time soon.

 
Resolving Improper Memory Limits on your Virtual Machines PDF Print
Written by Scott Herold   
Monday, 11 May 2009 12:14

Last week I posted an article that talked about what happens on an ESX Server when a virtual machine has a memory limit set lower than the amount of memory assigned to that virtual machine.  Sound confusing?  If so, head over and read the original blog post.

The short version is that the situation is simply not good, and has major performance implications across the ESX Host, and potentially across the whole infrastructure.  Today, I want to show how you can simply identify and resolve this significant VMware Infrastructure issue using some simple PowerShell commands.

 
Conception of a Turtle - Part 2 PDF Print
Written by Scott Herold   
Friday, 17 April 2009 12:21

This is the second part of my blog post in which I give people a little insight into the "Behind the Scenes" of bringing Virtualization EcoShell to life.  Why did I do it, Why did I choose PowerGUI, etc.  My goal is to give people just a little appreciation into the amount of effort it takes to bring new ideas to market (and to do it for free!).

 
Conception of a Turtle - Part 1 PDF Print
Written by Scott Herold   
Thursday, 16 April 2009 18:47

As many people have hopefully noticed, yesterday marked the release of Virtualization EcoShell from Vizioncore.  Virtualization EcoShell is a freeware desktop toolkit for VMware administrators based off Windows PowerShell technology.  When get out to customer sites or am at trade shows I am often asked “Where did this idea come from?”, or “Wow, what into getting this available?”  For this blog series, I figured I’d give everyone some insight into what went into taking Virtualization EcoShell from conception to delivery.  The trick will be doing so in a way that doesn’t put everyone to sleep.  I’ve decided to split this post into two parts that I will release over two days.  In exchange for making you guys come back both days, I’ll post another chapter a week early right after I post Part 2 tomorrow.

 
Get Some Relief this Tax Season PDF Print
Written by Scott Herold   
Wednesday, 08 April 2009 19:20

April 15th is often a sad day, at least in America.  It is the day we have to finally stop delaying and actually pay the US Government the money we owe them from the previous year.  This year, I'm hoping to make April 15th a little bit better for everyone by announcing the public availability of a new freeware product Virtualization EcoShell™.  I'm not talking "Free for 30 days and then we're going to rip 80% of the features away".  I'm not talking "Free....for only a few ESX Servers".  I'm talking 100% completely free of charge regardless of the size of your environment.  How's that for an April 15th surprise?

 
<< Start < Prev 1 2 3 Next > End >>

Page 1 of 3

Syndication

feed-image RSS Feed

Buy on Amazon