However, as of today there isn't a similar view available for Instant Clone farms for RDSH. So I've put together a work around utilizing Horizon PowerCLI and the Active Directory module for PowerShell. Using Horizon PowerCLI you can determine the RDS hosts associated with a specific farm. Then, using the Active Directory module, you can connect to View LDAP directory to look up Instant Clone maintenance/image properties from LDAP objects that represent these RDS hosts. This includes info similar to what's seen in the screen shot above.
A prerequisite for this script is an OS that's setup properly for Horizon PowerCLI and has the the VMware.Hv.Helper module imported. These blogs by Ray Heffer and Graeme Gordon will get you up to speed with these perquisites. Also, you'll need Active Directory Module for PowerShell, a process that's covered pretty well in this blog.
With the above prerequisites lined up you can get started with the script. The entire script is included below along with sample screenshots from it's output. If you just want to take a crack at the script change the variables at the very top of then have at it. Otherwise, here's some details on how it works.
How It Works
First variables are populated with values for farm name and connection server.
$farmName = "InstantFarm"
$connectionServer = "horizon.work.com"
Next, credentials are gathered for access to the Horizon API and View LDAP environment. For the script to work it needs to be a user with administrator rights to the Horizon environment.
$cred = Get-Credential
With the creds now in hand you can authenticate to the Horizon API and copy the global extension data to a variable for later use.
Connect-HVServer -server $connectionServer -Credential $cred
$Services1=$Global:DefaultHVServers.ExtensionData
Now you can access the View LDAP directory using New-PSDrive and the Active Directory provider. We're going to provide it the name of our connection server and "ou=Servers,DC=vdi, DC=vmware, DC=int" as the root.
New-PSDrive -Name ViewLDAP -PSProvider ActiveDirectory –Server ($connectionServer + ":389") -Root "ou=Servers,DC=vdi, DC=vmware, DC=int" -Credential $cred
cd ViewLDAP:
(For more information on the Active Directory module for PowerShell check out this page by Microsoft.)
With a successful connection to the View API and View LDAP directory you can start having some fun. First, you can leverage the Get-HVFarmSummary advanced function to get the farm ID of the farm you wish to monitor.
$MySummary = Get-HVFarmSummary $farmName
You're then going to use this ID as a parameter for the FarmHealth_Get function associated with the FarmHealth service. To simplify access to this service and it's functions, we'll use the View API Helper library to create an object for it.
Then take this new object and feed it the variable for the extension data along with the id for the farm.
$TestFarmHealth = $FarmHealth.FarmHealth_Get($Services1, $MySummary.id)
$viewLDAPObjects = @()
ForEach ( $RDSHHost in ($TestFarmHealth.RdsServerHealth))
{
$target = $RDSHHost.Name + "*"
$rdsObject = Get-ADObject -Filter {ipHostNumber -like $target} -Properties pae-DisplayName, ` pae-SVIVmSnapShot, ipHostNumber, pae-SVIVmOperationStatus,`
pae-VmCreated, pae-SVIVmParentVM
$viewLDAPObjects += $rdsObject
}
Now the $viewLDAPObjects contains a collection of AD objects representing the RDSH VMs. Using FT we can neatly display the relevant properties of these objects that tell us about image update status. You could do it with a line as simple as the one below. (The command in my script is bit messier for the sake of more readable output.)
Example Output
This is what my farm looks like prior to a new image push. Note that all VMs are using the same Parent VM and snapshot.
Here's what the output looks like with an additional server getting updated.
And finally, here's what it looks like after every single VM has been updated with the new image.
The Script:
No comments:
Post a Comment