Created
March 11, 2017 06:07
-
-
Save dlinsley/74f7fc4597099a062365278c072308a6 to your computer and use it in GitHub Desktop.
Sample to add vCenter to Horizon View with all available options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Author: Daniel Linsley, @danlinsley | |
Description: Sample to add vCenter to Horizon View with all available options | |
#> | |
Import-Module VMware.VimAutomation.HorizonView | |
Connect-HVServer -Server "view.corp.local" -User "[email protected]" -Pass "yourPassword" | |
$vc_service = New-Object VMware.Hv.VirtualCenter | |
#Create a vc_spec for each VirtualCenter you want to add | |
$vc_spec = New-Object VMware.Hv.VirtualCenterSpec | |
$vc_spec.DisplayName = "Your vCenter Host" | |
$vc_spec.Description = "Your vCenter Host for XYZ" | |
$vc_password = ConvertTo-SecureString "youPassword" -AsPlainText -Force | |
$vc_spec.ServerSpec = createVcServerSpec("vcenter.corp.local", "[email protected]",$vc_password) | |
$vc_spec.Limits = createVcLimits(20, 50, 30, 30, 20) | |
# Does not need to be specified | |
#$vc_spec.CertificateOverride | |
$vc_spec.StorageAcceleratorData = createVcStorageAcceleratorData($True, 1024) | |
$vc_spec.SeSparseReclamationEnabled = $True | |
$vc_spec.ViewComposerData = createViewComposerData("STANDALONE", "viewcomp.corp.local", "[email protected]", $vc_password) | |
# Add the vCenter to View: | |
$vC_Id = $vc_service.VirtualCenter_Create($vc_spec) | |
############################################################### | |
function createVcServerSpec($hostName, $username, $password) { | |
$spec = New-Object VMware.Hv.ServerSpec | |
$spec.ServerName = $hostName | |
$spec.Port = 443 | |
$spec.UseSSL = $true | |
$spec.UserName = $username | |
$spec.Password = $password | |
$spec.ServerType = "VIRTUAL_CENTER" | |
return $spec | |
} | |
function createViewComposerServerSpec($hostName, $username, $password) { | |
$spec = New-Object VMware.Hv.ServerSpec | |
$spec.ServerName = $hostName | |
$spec.Port = 18443 | |
$spec.UseSSL = $true | |
$spec.UserName = $username | |
$spec.Password = $password | |
$spec.ServerType = "VIEW_COMPOSER" | |
return $spec | |
} | |
function createVcLimits($vcProvLimit, $vcPowerOpsLimit, $viewProvLimit, $viewMaintLimit, $instaCloneLimit) { | |
$limits = New-Object VMware.Hv.VirtualCenterConcurrentOperationLimits | |
$limits.VcProvisioningLimit = $vcProvLimit | |
$limits.VcPowerOperationsLimit = $vcPowerOpsLimit | |
$limits.ViewComposerProvisioningLimit = $viewProvLimit | |
$limits.ViewComposerMaintenanceLimit = $viewMaintLimit | |
$limits.InstantCloneEngineProvisioningLimit = $instaCloneLimit | |
return $limits | |
} | |
function createVcStorageAcceleratorData($enable, $defaultCacheSizeMB) { | |
$data = New-Object VMware.Hv.VirtualCenterStorageAcceleratorData | |
$data.Enabled = $enable | |
$data.DefaultCacheSizeMB = $defaultCacheSizeMB | |
return $data | |
} | |
function createViewComposerData($type, $hostname, $username, $password) { | |
$data = New-Object VMware.Hv.VirtualCenterViewComposerData | |
$data.ViewComposerType = $type #Possible Values: DISABLED, LOCAL_TO_VC, STANDALONE | |
if ($type -ne "DISABLED") { | |
$data.ServerSpec = createViewComposerServerSpec($hostname,$username,$password) | |
} | |
return $data | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment