Category: Uncategorized


Just last night a fellow TAM asked if we could automate adding vSphere Tags for Horizon desktops. The background is that if a customer uses a backup solution that ties to these tags to also automate what gets backed up so how can do make this easier for them. Not a bad idea, I also have another customer that does the same scenario and figured it’s something that we can do. He posted the question and we ran with it.

First, create a user account and use the prebuilt Role of Tagging Admin.

Default privileges role can be seen here or by going Menu -> Administration -> Roles

At the vCenter level added this user with the Tagging Admin Role and propagated to children.

Next we will create the Tag Category and Tag ahead of time. In my home lab use case just creating a category for VDI and tag of Non-Prod. You get here by going Menu -> Administration -> Tags & Custom Attributes

Here I created the category of “VDI” and gave it “Many Tags” as I may use this later down the road for more than just one type.

Next I created the “Non-prod” tag and tied to the “VDI” category.

The easy part is done and if you wanted you could even script out the creation of tags and categories.

Now we will create the Powershell script that will be created on the Parent of the desktop pool that we will trigger with the Post-Sync of the Horizon pool configuration.

On the parent create a folder where we will keep the PowerShell script and bat file that we will use to kick off the file. The Horizon post-sync process can only use .bat/.vbs/.cmd files.

Below is my VM-Tag.ps1 script. Here you will define the variables for your vCenter, the tag that we created above, the username and password for the local user we created with the Tagging Admin privileges and then the Computer Name. This is critical that the Computer Name of the OS matches what the VM name will be so we can add the tag to vCenter. If your scenario is different then we will need to find another way to match these so we can automate this process. I wasn’t sure the Get-Credentials that I normally use would work since the parent will fork/clone and the encrypted file won’t work on the child VMs. Also didn’t think the Windows Credential Store would either in this scenario but may test it later.

$vc = "vcenter.AD_Domain.net"
$NPTag = "Non-Prod"
$ComputerName = "$env:computername" # GET COMPUTER NAME
$userTag = "tagging_user@vsphere.local"
$passTag = "YourPassword"


# Connect to vCenter with saved creds
Write-host "Connecting to vCenter.."
connect-viserver -Server $vc -user $userTag -password $passTag | Out-Null

Write-host "Adding backup tag for VM.."
# Add Non-Prod vCenter tag to VM
New-TagAssignment -Tag $NPTag -Entity $ComputerName


exit

Next we will need to create the bat file that will kick off the above script, I called my “post-sync.bat” so that I’ll easily know what that is going forward. I wanted this to not cause any problems if it some reason ran slower and the off chance it kicked off when a user logged in. It should never happen that way but this is why I wanted the window to not display any text (@echo off) and start the powershell in a minimized state (/min) as well if you notice in the PowerShell the Out-Null so it doesn’t show the user the output of the vCenter once it connects.

@echo off
start /min powershell c:\scripts\vm-tag.ps1
exit

I wanted this to not cause any problems if it some reason ran slower and the off chance it kicked off when a user logged in. It should never happen that way but this is why I wanted the window to not display any text (@echo off) and start the powershell in a minimized state (/min) as well if you notice in the PowerShell the Out-Null so it doesn’t show the user the output of the vCenter once it connects.

Now we just need to log into the Horizon Admin portal and add our bat file to the Post-Synchronization Script Name field.

This is the only spot you need to make a change if the pool is already created.

The very last task to do is Shutdown the parent, take a snapshot and push that image out to the pool. Once this is done and sessions are cleared for the new Instant Clones to take place you will see the new Tag.

VM level object view.

Tag object view.

Again this was just a quick overview on how you can accomplish automating a task. Let me know if you have any questions, comments or feedback.

While working with a customer and our PSO engagement, we knew the Cross vCenter Migration Utility fling would be used but there was also around 40 hosts that we needed to migrate between an older 6.0 vCenter to a new 6.7 that we built fresh for this project. Identical networks were built on the new environment prior to migration to make the process easier.

Tasks:

  1. Put host in maintenance mode to vmotion VMs.
  2. Remove hosts from distributed vswitch (VDS) and migrate to standard vswitch (VSS).
  3. Remove host from old vCenter.
  4. Add host to new vCenter.
  5. Add host to new VDS.
  6. Exit maintenance mode.

In between 4 and 5 we are also removing a VIB and then upgrading the hosts using Update Manager which I started to script out and may test this some how since I’m using nested virtual ESXi hosts in my home lab. I am working on making a script that does all this in one now.

Here’s a video of the above working in action, dark mode is the old vCenter while the standard mode is the new vCenter:

Below is the script I used, shout out to William Lam @ virtuallyghetto.com for creating the migration to VSS and migrating to VDS scripts back in 2013 that still stands today. Without it I wouldn’t have been able to figure this out myself. You will notice that I do get errors in the video for trying to delete the VSS because I like to keep a clean environment. If I’m not using it then I want it removed and have added the script to make sure it’s deleted. I also put in the vSAN commands for entering in maintenance mode, I’m not using it on those nested hosts but am with my physical hosts.

# Variables that need to be set prior to starting script
# Old vCenter that we will remove the hosts from
$vc1 = "old-vcenter.something.com"

# New vCenter that we will add the hosts to
$vc2 = "new-vcenter.something.com"

# FQDN of the hosts we will be moving, if need to add or remove FQDN in last host variables but it will throw errors when trying to add/remove VSS and VDS settings, this is expected.
$host1 = "host-01.something.com"
$host2 = "host-02.something.com"
$host3 = "host-03.something.com"
$esxihostuser = "root"
$esxihostpasswd = "changeme!"

# This is the host cluster that we will add the hosts to on the new vCenter
$Cluster = "Your-Cluster"

# Name of portgroups
$mgmt_name = "Your-MGMT-Network"
$vmotion_name = "Your-vMotion-Network"
$ft_name = "Your-FT-Network"

# VDS to migrate from
$vds_name = "Your-DvSwitch"
$vds = Get-VDSwitch -Name $vds_name

# VSS to migrate to
$vss_name = "Your-vSwitch0"

# Save vCenter credentials - Only needs to be ran once to create .cred file.
# $credential = Get-Credential
# $credential | Export-Clixml -path c:\share\scripts\-admin-vcenter.cred
$credential = import-clixml -path C:\share\scripts\-admin-vcenter.cred
# Connect to vCenter with saved creds
connect-viserver -Server $vc1 -Credential $credential

# Update Manager Baselines
#$criticalPatchBaseline = Get-Baseline -Name "Critical Host Patches (Predefined)"
#$noncriticalPatchBaseline = Get-Baseline -Name "Non-Critical Host Patches (Predefined)"
#$hostsecurityPatchBaseline = Get-Baseline -Name "Host Security Patches (Predefined)"


$vmhost_array = @($host1, $host2, $host3)

# Enter Hosts into maintenance with no data migration for vSAN
Write-host "Putting hosts in maintenance mode"
foreach ($vmhost in $vmhost_array) {
Set-VMhost -State maintenance -Evacuate -vsandatamigrationmode nodatamigration $vmhost
}


# Delete previous vSwitch and will throw an error if there isn't a vSwitch already in place.  This is done to keep configs same.
  foreach ($vmhost in $vmhost_array) {
  Remove-VirtualSwitch -VirtualSwitch $vss_name -Confirm:$false
  }

# Create VSS per hosts
foreach ($vmhost in $vmhost_array) {
New-VirtualSwitch -vmhost $vmhost -name $vss_name 

# Name of portgroups to create on VSS
$mgmt_name
$vmotion_name
$ft_name

}

foreach ($vmhost in $vmhost_array) {
Write-Host "`nProcessing" $vmhost

# pNICs to migrate to VSS
Write-Host "Retrieving pNIC info for vmnic0,vmnic1,vmnic2,vmnic3"
$vmnic0 = Get-VMHostNetworkAdapter -VMHost $vmhost -Name "vmnic0"
$vmnic1 = Get-VMHostNetworkAdapter -VMHost $vmhost -Name "vmnic1"
$vmnic2 = Get-VMHostNetworkAdapter -VMHost $vmhost -Name "vmnic2"
$vmnic3 = Get-VMHostNetworkAdapter -VMHost $vmhost -Name "vmnic3"

# Array of pNICs to migrate to VSS
Write-Host "Creating pNIC array"
$pnic_array = @($vmnic0,$vmnic1,$vmnic2,$vmnic3)

# vSwitch to migrate to
$vss = Get-VMHost -Name $vmhost | Get-VirtualSwitch -Name $vss_name

# Create destination portgroups
Write-Host "`Creating" $mgmt_name "portrgroup on" $vss_name
$mgmt_pg = New-VirtualPortGroup -VirtualSwitch $vss -Name $mgmt_name


Write-Host "`Creating" $vmotion_name "portrgroup on" $vss_name
$vmotion_pg = New-VirtualPortGroup -VirtualSwitch $vss -Name $vmotion_name

Write-Host "`Creating" $ft_name "Network portrgroup on" $vss_name
$ft_pg = New-VirtualPortGroup -VirtualSwitch $vss -Name $ft_name

# Array of portgroups to map VMkernel interfaces (order matters!)
Write-Host "Creating portgroup array"
$pg_array = @($mgmt_pg,$vmotion_pg,$ft_pg)

# VMkernel interfaces to migrate to VSS
Write-Host "`Retrieving VMkernel interface details for vmk0,vmk1,vmk2"
$mgmt_vmk = Get-VMHostNetworkAdapter -VMHost $vmhost -Name "vmk0"
$vmotion_vmk = Get-VMHostNetworkAdapter -VMHost $vmhost -Name "vmk1"
$ft_vmk = Get-VMHostNetworkAdapter -VMHost $vmhost -Name "vmk2"


# Array of VMkernel interfaces to migrate to VSS (order matters!)
Write-Host "Creating VMkernel interface array"
$vmk_array = @($mgmt_vmk,$vmotion_vmk,$ft_vmk)

# Perform the migration
Write-Host "Migrating from" $vds_name "to" $vss_name"`n"
Add-VirtualSwitchPhysicalNetworkAdapter -VirtualSwitch $vss -VMHostPhysicalNic $pnic_array -VMHostVirtualNic $vmk_array -VirtualNicPortgroup $pg_array  -Confirm:$false
}

Write-Host "`nRemoving" $vmhost_array "from" $vds_name
$vds | Remove-VDSwitchVMHost -VMHost $vmhost_array -Confirm:$false


# Put hosts into maintenance mode
Write-host "Putting hosts in maintenance mode"
foreach ($vmhost in $vmhost_array) {
Set-VMhost -State maintenance -Evacuate -vsandatamigrationmode nodatamigration $vmhost
}

# Remove host from vCenter
Write-Host "Removing" $vmhost_array "from" $vc1

foreach ($vmhost in $vmhost_array) {
Remove-VMhost -vmhost $vmhost -Confirm:$false
}

Write-host "Please don't forget about these hosts out in the ether.."

# Disconnect from old vCenter
Disconnect-VIserver -Server $vc1 -Force -Confirm:$false

# Connect to new vCenter
$credential = import-clixml -path C:\share\scripts\admin-vcenter.cred
connect-viserver -Server $vc2 -Credential $credential
$vmhost_array = @($host1, $host2, $host3)

# Add host to new vCenter
Write-Host "`nAdding" $vmhost_array "to" $vc2
foreach ($vmhost in $vmhost_array) {
add-vmhost $vmhost -Location $Cluster -user $esxihostuser -password $esxihostpasswd -Force
}
Write-host "Hosts are now added to the vCenter.."

# Put hosts into maintenance mode
Write-host "Putting hosts in maintenance mode"
foreach ($vmhost in $vmhost_array) {
Set-VMhost -State maintenance -Evacuate -vsandatamigrationmode nodatamigration $vmhost
}

# Create VDS - Can be the same or new VDS ifyou want
$vds_name = "Your-DvSwitch-01"


#Write-Host "`nCreating new VDS" $vds_name
$vds = Get-VDSwitch -Name $vds_name -Location (Get-Datacenter -Name Your-DataCenter-Name)

# Create DVPortgroup
Write-Host "Creating new Management DVPortgroup"
#New-VDPortgroup -Name "Management Network" -Vds $vds | Out-Null
Write-Host "Creating new Storage DVPortgroup"
#New-VDPortgroup -Name "Storage Network" -Vds $vds | Out-Null
Write-Host "Creating new vMotion DVPortgroup"
#New-VDPortgroup -Name "vMotion Network" -Vds $vds | Out-Null
Write-Host "Creating new VM DVPortgroup`n"
#New-VDPortgroup -Name "VM Network" -Vds $vds | Out-Null

foreach ($vmhost in $vmhost_array) {
# Add ESXi host to VDS
Write-Host "Adding" $vmhost "to" $vds_name
$vds | Add-VDSwitchVMHost -VMHost $vmhost | Out-Null

# Migrate pNIC to VDS (vmnic0/vmnic1)
Write-Host "Adding vmnic0/vmnic1 to" $vds_name
$vmhostNetworkAdapter = Get-VMHost $vmhost | Get-VMHostNetworkAdapter -Physical -Name vmnic0
$vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter -Confirm:$false
$vmhostNetworkAdapter = Get-VMHost $vmhost | Get-VMHostNetworkAdapter -Physical -Name vmnic1
$vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter -Confirm:$false

# Migrate VMkernel interfaces to VDS

# Management #
$mgmt_portgroup = "Your-MGMT-Network"
Write-Host "Migrating" $mgmt_portgroup "to" $vds_name
$dvportgroup = Get-VDPortgroup -name $mgmt_portgroup -VDSwitch $vds
$vmk = Get-VMHostNetworkAdapter -Name vmk0 -VMHost $vmhost
Set-VMHostNetworkAdapter -PortGroup $dvportgroup -VirtualNic $vmk -confirm:$false | Out-Null

# Storage - I'm not using so rem'd it out just in case I do need it later
#$storage_portgroup = "Your-Storage-Network"
#Write-Host "Migrating" $storage_portgroup "to" $vds_name
#$dvportgroup = Get-VDPortgroup -name $storage_portgroup -VDSwitch $vds
#$vmk = Get-VMHostNetworkAdapter -Name vmk1 -VMHost $vmhost
#Set-VMHostNetworkAdapter -PortGroup $dvportgroup -VirtualNic $vmk -confirm:$false | Out-Null

# vMotion #
$vmotion_portgroup = "Your-vMotion-Network"
Write-Host "Migrating" $vmotion_portgroup "to" $vds_name
$dvportgroup = Get-VDPortgroup -name $vmotion_portgroup -VDSwitch $vds
$vmk = Get-VMHostNetworkAdapter -Name vmk1 -VMHost $vmhost
Set-VMHostNetworkAdapter -PortGroup $dvportgroup -VirtualNic $vmk -confirm:$false | Out-Null

# Fault Tolerance #
$ft_portgroup = "Your-FT-Network"
Write-Host "Migrating" $ft_portgroup "to" $vds_name
$dvportgroup = Get-VDPortgroup -name $ft_portgroup -VDSwitch $vds
$vmk = Get-VMHostNetworkAdapter -Name vmk2 -VMHost $vmhost
Set-VMHostNetworkAdapter -PortGroup $dvportgroup -VirtualNic $vmk -confirm:$false | Out-Null

# Migrate remainder pNIC to VDS (vmnic2/vmnic3)
Write-Host "Adding vmnic2/vmnic3 to" $vds_name
$vmhostNetworkAdapter = Get-VMHost $vmhost | Get-VMHostNetworkAdapter -Physical -Name vmnic2
$vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter -Confirm:$false
$vmhostNetworkAdapter = Get-VMHost $vmhost | Get-VMHostNetworkAdapter -Physical -Name vmnic3
$vds | Add-VDSwitchPhysicalNetworkAdapter -VMHostNetworkAdapter $vmhostNetworkAdapter -Confirm:$false

}
# Delete previous vSwitch
foreach ($vmhost in $vmhost_array) {
Remove-VirtualSwitch -VirtualSwitch $vss_name -Confirm:$false
}
# Exit hosts from maintenance
Write-host "Taking hosts out of maintenance mode"
foreach ($vmhost in $vmhost_array) {
Set-VMhost $vmhost -state Connected
}

Write-host "Hosts have been migrated from VDS to VSS then removed from vCenter then added to a vCenter and finally added back to a VDS"


Requirements:

One or more RDSH (Windows Terminal Servers) with Horizon View Agent installed.

One or more VMware Horizon View Connection Servers version 6 already setup.

Software installed (or Thinapp’d!)

rdsh-01

In your View Manager, add your Farms for the RDSH hosts:

rdsh-02

Add the installed software:

rdsh-03

rdsh-04

Add entitled users:

rdsh-05

Should look like this after you add the software:

rdsh-06

Add a manual application (if only one host has the software* or if you are pointing to a ThinApp’d streaming package).

*I say if only one host because the software I installed wasn’t on the list but I may not have given it time to find it.

rdsh-07

rdsh-08

rdsh-09

Misconfiguration with the path, Office 15 is no space and should be \Office15\

Now I get:

rdsh-10

Since I only installed Visio on one of the RDSH instances then it will tell you which one is missing the software. If I needed to reboot view-rdsh-01 then the application would not be available in a HA scenario and this is a good way to find out those cases.

Now from the same client for desktops, you can also launch applications as well as create a shortcut for a quick launch of both:

rdsh-11

Since View uses PCoIP, any device that is supported can launch these applications like the desktops with the same interface.  The most time consuming part of the whole thing is just installing the software on the RDSH servers but you don’t need to do anything special.

I haven’t been updating this blog very much lately but let me say something.. I’m exhausted mentally!  Why you ask?  Let me explain.

With Shared Services we have included training into most of the big purchases, which we like to do on-site due to the cost of travel for 6-18 people would be crazy to deal with all the stuff we have in production.   This is also great in the sense that I get to see my family every day after work but since you are technically still on campus makes it hard to break away from the daily grind.  That part is getting easier as we go though.

List of training that I’ve been in the last 2 months:

VMware vCloud Director 5.5 Install, Configure and Manage (3 days)

VMware View Best Practices (3 days)

VMware vCenter Operations Manager/vCOPS Analyze and Predict (2 days)

CommVault Basic Course (3 days)

We also had an Isilon Basic course (5 days) plus Compellent basic course (5 days) last year.

Where am I going with this?  OU:S2 is making sure that our team is well trained to help support our customers.  This also brings the 3 IT staff together from the different campuses and forms a way of reaching out to others in the class that may have a better handle on the environment.  I really enjoy going to training and proud that OU allows us to keep learning.

Now that VMworld is over and I’m back to work, it only seems right to write a take away about it.

First, my buddy and coworker David Stricklin went again as well this year so this marks his 4th and my 5th attendance.  Also our friend from the north campus, David Wisby, was also able to go so we definitely were able to “divide and conquer” the sessions as well as meet up for the parties.  Being a vExpert and VMUG leader there were a couple that only I could go so I was glad that both David’s (I’ll start calling them by last names) were able to hook up and have fun.

This was also the first time I went as a presenter.  My session was with Sean O’Dell who works at VMware and helps me with presentations/content for the OKC VMUG.  We had 116 register and 82 actually attend.  Not a bad turn out to hear what we are doing here at the University of Oklahoma with Shared Services.  It was great to get follow up questions and to hear of other universities starting to do the same as us.  The feedback was good except for the “it was boring and stop with the inside jokes” one.  I guess if you leave less than 10 minutes into the session you might think that and I apologize for my nervousness that I eventually was able to get out of the way.

The vExpert and VMUG parties were a great way to meet others in the two communities and nice to see that CEO Pat Gelsinger, COO Carl Eschenbach and then heard that former CTO Steven Herrod showed up after I left.  I highly doubt any other community would get that treatment but they need to.  I am definitely looking forward to next year and may try to do a follow up presentation on how we’ve progressed (hopefully the move from vCD to vCAC).

If you are in the IT field, be it virtualization, network or whatever I highly recommend following these vExperts on Twitter.  A lot of good info across the board and around the world. I will try to do a more in depth write up about the sessions I attended and the take-aways but now I have to go cry for installing and getting vCloud Director going for production a month before VMworld only to hear that it’s eventually going away and being cut up to get the multi-tenate in vCAC and other features else where.  Don’t mind the tears on the keyboard.

-Joey

In retrospect to the PC vs Mac commercials, VMware released these videos about a M$ employee taking a lie detector test.  Those that say it’s not true to form on the M$ questions are lying to themselves.  There are four videos in total, I would watch them all back to back and have a good laugh.  Then go back to your vSphere (web) client..

I have the next OKC VMUG setup for the same place, Samis Education Center, on July 9th.  Dell is going to be sponsoring this event so we should have lunch available.  Registration is now open.

We will be going over vCenter Automation Center and the new product, vCenter Log Insight.  Time willing I’ll do a demo over what Shared Services here at OU is currently doing so we can kick off showing what we are doing within our group and see new ways or offering help on design and implementations.

See you all there!

Catching up!

So been doing a lot these past two months.  Finishing up our Shared Services projects so we can now phase out of the 9 teams to three DTO (Design, Transitions and Operations).  Been a year and half but it’s good to see the light at the end of the tunnel.  Also had another VMUG where we covered the VMware Horizon Suite (thanks to Sean O’dell).  Tom Hollingsworth, currently the ONLY Oklahoma vExpert, also presented on the vExpert community and Cloud Cred.  Ryan Costello went over Project Nee/VMware Hands-on-Labs.  It was a good meeting as there were more interactions then I thought from the crowd.  Very pleased with that.

Look for the next VMUG in June since I’ll be a proud daddy to my 4th child in May.. I’ll be just a tad bit busy.  🙂