VMM 2012 R2 Deploy-VDI script with validation checks

Hi,

I developed a function that allows administrators to create multiple VDI VMs using a VM template, guest OS profile on vmm 2012 R2.

I am trying to figure out a way to add these 2 goals to my function.

  1. The function should validate whether the IP pool has enough available IPs available for VM’s to communicate. In my use case, the IP pool has 508 IPs available.

  2. Names of the VM’s should not exceed 15 characters.

I can provide what I have completed thus far.

I look forward to working with you all.

Thanks and happy holidays.

  1. Time to switch to IPv6! (grin). You’ll never run out!

But seriously.

Let’s start with the easy one. If the VM name is in $name, then $name.length will tell you how many characters it is. You can just check to see if that’s over your limit or not.

You should be able to do something like…

Get-SCIPAddress | Where State -eq ‘Assigned’ | Measure

And the resulting object will have a Count property showing number of assigned addresses. That’ll tell you if you’re past your limit, right?

Thanks Don, I will definitely play around with that and see how it works.

While I was waiting for a reply, I did something different.

I used Get-SCIPAddress and queried the subnet and created a variable out of it.

$availableaddressesObj = (Get-SCStaticIPAddressPool -Subnet 192.168.1.0/24).AvailableAddresses

I then used the If statement and the less than switch against my count parameter, to check and see if the number of machines would have enough ip’s in the pool and throw a error.

Check if there are enough IPs.

if($availableaddressesObj -lt $count) {
Write-Host “There is not enough IP addresses available in the pool, ensure that the IP pool has enough IPs and retry function.” -ForegroundColor Yellow
break
}

I did something similar for the computer name check as well. I can send you a copy of the function to provide you with more context.