Building my Orion Server [VMware Scripting Edition] – Step 1

This is part 1 of a multi-part post on updates that I’ve made to How I Build an Orion Server.  Primarily, it will be three parts.  If you need this for a Hyper-V environment, I’ve got that script as well.

  1. Building my Orion Servers in VMware
  2. Configuring the disks on the VM after OS install
  3. Configuring the VM with the new disks

I’ve been working on converting my Hyper-V scripts to be useful for VMware environments as well.  This is my first pass with building the VM’s on VMware.

So, here’s my variable declaration:

#region Variable Declaration
$VMName       = "OrionServer"  # Server Name
$CPUCount     = 4              # Number of CPU's to give the VM
$CPUReserve   = 25             # Percentage of CPU's being reserved
$RAMBoot      = 8GB            # Startup Memory
$DiskFormat   = "Thin"         # Use Thin, Thick, or EagerZerodThick Disks
$VlanName     = "VM - VLAN 40" # VLAN assignment for the Network Adapter
# Sizes and count of the disks
$VHDSizes = [ordered]@{ "C" =  40GB; # Boot
                        "D" =  26GB; # Page 
                        "E" =  40GB; # Programs
                        "F" =  10GB; # Web
                        "G" =  10GB; # Logs
                       } 
$GuestOS = "windows9Server64Guest" # OS Identifer of the Machine
#endregion

Easy part is done.  I’ve configured how I want the Orion Server to be architected (at least the general framework).  Note the $GuestOS variable which (in my case) is Windows 2016 Server.  You may need to change this for your own environment.

Next is going through the motions of using these variables to create a VM.  Since reservations are handled differently within VMware as opposed to Hyper-V, I’ve kept some of the names of the variables the same.

Before I can even get started, I’ll need to enable the PowerCLI commands and disable (maybe) the Hyper-V commands.  This is done via choosing the modules to use within PowerShell.

#region Import the VMware Module & Remove the Hyper-V Module (if enabled)
if ( -not ( Get-Module -Name "VMware.PowerCLI" -ErrorAction SilentlyContinue ) )
{
    Import-Module VMware.PowerCLI -Force
}
if ( Get-Module -Name "Hyper-V" -ErrorAction SilentlyContinue )
{
    Remove-Module -Name "Hyper-V" -Confirm:$false -Force
}
#endregion Import the VMware Module & Remove the Hyper-V Module

Now I’ll need to connect to the vCenter that runs my infrastructure.  I first check to see if it’s already connected (which it probably won’t be) and then I connect to it.

#region Connect to vCenter server via Trusted Windows Credentials
if ( -not ( $global:DefaultVIServer ) )
{
    Connect-VIServer -Server vCenter.demo.lab
}
#endregion Connect to vCenter server via Trusted Windows Credentials

I’ll also need to specify on which host I want to configure this VM.  In my case I have quite a few, so I want to find the one with the most available CPU available.  You can specify a host or a cluster manually if you prefer.

# Find the host with the most free MHz or specify one by using:
# $VMHost = Get-VMHost -Name "ESX Host Name"
$VmHost = Get-VMHost | Sort-Object -Property @{ Expression = { $_.CpuTotalMhz - $_.CpuUsageMhz } } -Descending | Select-Object -First 1

Hyper-V uses a percentage to determine how many MHz to reserve, whereas VMware uses an actual MHz value.  I didn’t want to change my variables, so I needed to calculate the per processor MHz for the host.

# Calculate the MHz for each processor on the host
$MhzPerCpu = [math]::Floor( $VMHost.CpuTotalMhz / $VMHost.NumCpu )

I’m just about ready to build the VM.  Now I need to convert the disk sizes to a list and convert them from bytes to GB.

# Convert the Disk Sizes to a list of numbers (for New-VM Command)
$DiskSizes = $VHDSizes.Keys | Sort-Object | ForEach-Object { $VHDSizes[$_] / 1GB }

We’re ready to build the VM.

# Create the VM
$VM = New-VM -Name $VMName -ResourcePool $VMHost -DiskGB $DiskSizes -MemoryGB ( $RAMBoot / 1GB ) -DiskStorageFormat $DiskFormat -GuestId $GuestOS -NumCpu $CPUCount

Now let’s put in our reservations.

# Setup minimum resources
# CPU is Number of CPUs * Reservation (as percentage) * MHz per Processor
$VM | Get-VMResourceConfiguration | Set-VMResourceConfiguration -CpuReservationMhz ( $CPUCount * ( $CPUReserve / 100 ) * $MhzPerCpu ) -MemReservationGB ( $RAMBoot / 2GB )

Lastly, we’ll set the Network Adapter to the proper VLAN.

# Set my VLAN
$VM | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $VlanName -Confirm:$false

That’s it.  After it’s executed, this is what I get:

Orion Server on VMware

That’s pretty much it.  This script was tested with ESX 6.0 with Windows 10 as the client.

Now I boot it up use my Windows Deployment Server to install Server and go from there.

The next post will include an optimized way that I handle the post-image configuration.  It’s basically a scripted version of my original post.

Keep on Rambling!

4 thoughts on “Building my Orion Server [VMware Scripting Edition] – Step 1”

  1. Why are you building these without Disk Drives? How are you doing your Windows Install, and how about updating VMware Tools (Loading ISO) into your VM? I get a minimal install but that seems to make things a bit more difficult or unnecessary.

    Reply
    • Personally, I use Windows Deployment Services, so I don’t need to mount the ISO. Insofar as installing the VMware Tools, I do it from a network share. IMHO, it’s easier than dealing with the VM Tools ISO.

      Reply
  2. Awesome 3-part guide. As a Orion newbie this was just what in needed to get my VM servers configured and ready for installing the Orion software. Much appreciated. Keep up the good work.

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.