VMM 2012 R2 Deploy-VDI script with validation checks

Welcome Forums General PowerShell Q&A VMM 2012 R2 Deploy-VDI script with validation checks

This topic contains 2 replies, has 2 voices, and was last updated by

3 years, 4 months ago.

  • Author
  • #33302

    Topics: 4
    Replies: 4
    Points: 0
    Rank: Member


    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.

  • #33364

    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    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?

  • #33395

    Topics: 4
    Replies: 4
    Points: 0
    Rank: Member

    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

    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

    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.

The topic ‘VMM 2012 R2 Deploy-VDI script with validation checks’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort