Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- 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 "administrator@vsphere.local" -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", "administrator@vsphere.local",$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", "admin@vsphere.local", $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
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement