Enhancements to examples, validation and netBiosName

1) Renamed Get-HVDesktopSpec to Get-HVPoolSpec.
2) Enhancements to examples
3) Enhancements to validation for farm and pool
4) ADDomainId handling for farm and pool
This commit is contained in:
praveenmathamsetty
2017-01-09 21:11:54 +05:30
parent 1ceacb298d
commit a30d144974

View File

@@ -176,7 +176,7 @@ The Add-HVDesktop adds virtual machines to already exiting pools by using view A
.EXAMPLE .EXAMPLE
Add managed manual VMs to existing manual pool Add managed manual VMs to existing manual pool
Add-HVDesktop -PoolName 'ManualPool' -Machines 'manualPool1', 'manualPool2'. Add-HVDesktop -PoolName 'ManualPool' -Machines 'manualPool1', 'manualPool2' -Confirm:$false
.EXAMPLE .EXAMPLE
Add virtual machines to automated specific named dedicated pool Add virtual machines to automated specific named dedicated pool
@@ -368,7 +368,7 @@ function Add-HVRDSServer {
.EXAMPLE .EXAMPLE
Add RDSServers to manual farm Add RDSServers to manual farm
Add-HVRDSServer -Farm "manualFarmTest" -RdsServers "vm-for-rds","vm-for-rds-2" Add-HVRDSServer -Farm "manualFarmTest" -RdsServers "vm-for-rds","vm-for-rds-2" -Confirm:$false
.OUTPUTS .OUTPUTS
None None
@@ -1915,11 +1915,11 @@ function New-HVFarm {
.EXAMPLE .EXAMPLE
Creates new linkedClone farm by using json file Creates new linkedClone farm by using json file
New-HVFarm -Spec C:\VMWare\Specs\LinkedClone.json New-HVFarm -Spec C:\VMWare\Specs\LinkedClone.json -Confirm:$false
.EXAMPLE .EXAMPLE
Creates new manual farm by using rdsServers names Creates new manual farm by using rdsServers names
New-HVFarm -Manual -FarmName "manualFarmTest" -FarmDisplayName "manualFarmTest" -Description "Manual PS Test" -RdsServers "vm-for-rds.eng.vmware.com","vm-for-rds-2.eng.vmware.com" New-HVFarm -Manual -FarmName "manualFarmTest" -FarmDisplayName "manualFarmTest" -Description "Manual PS Test" -RdsServers "vm-for-rds.eng.vmware.com","vm-for-rds-2.eng.vmware.com" -Confirm:$false
.OUTPUTS .OUTPUTS
None None
@@ -2260,7 +2260,7 @@ function New-HVFarm {
break break
} }
try { try {
Test-HVFarmSpec -JsonObject $jsonObject Test-HVFarmSpec -PoolObject $jsonObject
} catch { } catch {
Write-Error "Json object validation failed, $_" Write-Error "Json object validation failed, $_"
break break
@@ -2522,7 +2522,14 @@ function New-HVFarm {
if ($pscmdlet.ShouldProcess($farmSpecObj.data.name)) { if ($pscmdlet.ShouldProcess($farmSpecObj.data.name)) {
$Id = $farm_service_helper.Farm_Create($services, $farmSpecObj) $Id = $farm_service_helper.Farm_Create($services, $farmSpecObj)
} } else {
try {
Test-HVFarmSpec -PoolObject $farmSpecObj
} catch {
Write-Error "FarmSpec object validation failed, $_"
break
}
}
return $farmSpecObj return $farmSpecObj
} }
@@ -2535,77 +2542,77 @@ function New-HVFarm {
function Test-HVFarmSpec { function Test-HVFarmSpec {
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
$JsonObject $PoolObject
) )
if ($null -eq $jsonObject.Type) { if ($null -eq $PoolObject.Type) {
Throw "Specify type of farm in json file" Throw "Specify type of farm"
} }
$jsonFarmTypeArray = @('AUTOMATED','MANUAL') $jsonFarmTypeArray = @('AUTOMATED','MANUAL')
if (! ($jsonFarmTypeArray -contains $jsonObject.Type)) { if (! ($jsonFarmTypeArray -contains $PoolObject.Type)) {
Throw "Farm type must be AUTOMATED or MANUAL" Throw "Farm type must be AUTOMATED or MANUAL"
} }
if ($null -eq $jsonObject.Data.Name) { if ($null -eq $PoolObject.Data.Name) {
Throw "Specify farm name in json file" Throw "Specify farm name"
} }
if ($null -eq $jsonObject.Data.AccessGroup) { if ($null -eq $PoolObject.Data.AccessGroup) {
Throw "Specify horizon access group in json file" Throw "Specify horizon access group"
} }
if ($jsonObject.Type -eq "AUTOMATED"){ if ($PoolObject.Type -eq "AUTOMATED"){
$jsonProvisioningType = $jsonObject.AutomatedFarmSpec.ProvisioningType $jsonProvisioningType = $PoolObject.AutomatedFarmSpec.ProvisioningType
if ($null -eq $jsonProvisioningType) { if ($null -eq $jsonProvisioningType) {
Throw "Must specify provisioningType in json file" Throw "Must specify provisioningType"
} }
if ($null -eq $jsonObject.AutomatedFarmSpec.RdsServerNamingSpec.namingMethod) { if ($null -eq $PoolObject.AutomatedFarmSpec.RdsServerNamingSpec.namingMethod) {
Throw "Must specify naming method to PATTERN in json file" Throw "Must specify naming method to PATTERN"
} }
if ($null -eq $jsonObject.AutomatedFarmSpec.RdsServerNamingSpec.patternNamingSettings) { if ($null -eq $PoolObject.AutomatedFarmSpec.RdsServerNamingSpec.patternNamingSettings) {
Throw "Specify Naming pattern settings in json file" Throw "Specify Naming pattern settings"
} }
if ($null -eq $jsonObject.AutomatedFarmSpec.RdsServerNamingSpec.patternNamingSettings.namingPattern) { if ($null -eq $PoolObject.AutomatedFarmSpec.RdsServerNamingSpec.patternNamingSettings.namingPattern) {
Throw "Specify specified naming pattern in json file" Throw "Specify specified naming pattern"
} }
if ($null -eq $jsonObject.AutomatedFarmSpec.virtualCenterProvisioningSettings.enableProvisioning) { if ($null -eq $PoolObject.AutomatedFarmSpec.virtualCenterProvisioningSettings.enableProvisioning) {
Throw "Specify Whether to enable provisioning in json file" Throw "Specify Whether to enable provisioning or not"
} }
if ($null -eq $jsonObject.AutomatedFarmSpec.virtualCenterProvisioningSettings.stopProvisioningOnError) { if ($null -eq $PoolObject.AutomatedFarmSpec.virtualCenterProvisioningSettings.stopProvisioningOnError) {
Throw "Specify Whether provisioning on all VMs stops on error in json file" Throw "Specify Whether provisioning on all VMs stops on error"
} }
$jsonTemplate = $jsonObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.Template $jsonTemplate = $PoolObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.Template
$jsonParentVm = $jsonObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.ParentVm $jsonParentVm = $PoolObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.ParentVm
$jsonSnapshot = $jsonObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.Snapshot $jsonSnapshot = $PoolObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.Snapshot
$jsonVmFolder = $jsonObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.VmFolder $jsonVmFolder = $PoolObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.VmFolder
$jsonHostOrCluster = $jsonObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.HostOrCluster $jsonHostOrCluster = $PoolObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.HostOrCluster
$ResourcePool = $jsonObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.ResourcePool $ResourcePool = $PoolObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.ResourcePool
if (!( ($null -ne $jsonTemplate) -or (($null -ne $jsonParentVm) -and ($null -ne $jsonSnapshot) )) ) { if (!( ($null -ne $jsonTemplate) -or (($null -ne $jsonParentVm) -and ($null -ne $jsonSnapshot) )) ) {
Throw "Must specify Template or (ParentVm and Snapshot) names in json file" Throw "Must specify Template or (ParentVm and Snapshot) names"
} }
if ($null -eq $jsonVmFolder) { if ($null -eq $jsonVmFolder) {
Throw "Must specify VM folder in json file to deploy the VMs" Throw "Must specify VM folder to deploy the VMs"
} }
if ($null -eq $jsonHostOrCluster) { if ($null -eq $jsonHostOrCluster) {
Throw "Must specify Host or cluster in json file to deploy the VMs" Throw "Must specify Host or cluster to deploy the VMs"
} }
if ($null -eq $resourcePool) { if ($null -eq $resourcePool) {
Throw "Must specify Resource pool in json file to deploy the VMs" Throw "Must specify Resource pool to deploy the VMs"
} }
if ($null -eq $jsonObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.VirtualCenterStorageSettings.Datastores) { if ($null -eq $PoolObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.VirtualCenterStorageSettings.Datastores) {
Throw "Must specify datastores names in json file" Throw "Must specify datastores names"
} }
if ($null -eq $jsonObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.VirtualCenterStorageSettings.useVSan) { if ($null -eq $PoolObject.AutomatedFarmSpec.VirtualCenterProvisioningSettings.VirtualCenterStorageSettings.useVSan) {
Throw "Must specify whether to use virtual SAN or not" Throw "Must specify whether to use virtual SAN or not"
} }
if ($null -eq $jsonObject.AutomatedFarmSpec.CustomizationSettings.customizationType) { if ($null -eq $PoolObject.AutomatedFarmSpec.CustomizationSettings.customizationType) {
Throw "Specify Type of customization to use in json file" Throw "Specify customization type"
} }
if ($null -eq $jsonObject.AutomatedFarmSpec.CustomizationSettings.SysprepCustomizationSettings) { if ($null -eq $PoolObject.AutomatedFarmSpec.CustomizationSettings.SysprepCustomizationSettings) {
Throw "Specify Sysprep customization settings in json file" Throw "Specify sysPrep customization settings"
} }
if ($null -eq $jsonObject.AutomatedFarmSpec.RdsServerMaxSessionsData.MaxSessionsType) { if ($null -eq $PoolObject.AutomatedFarmSpec.RdsServerMaxSessionsData.MaxSessionsType) {
Throw "Specify MaxSessionsType in json file" Throw "Specify MaxSessionsType"
} }
} elseif ($jsonObject.Type -eq "MANUAL") { } elseif ($PoolObject.Type -eq "MANUAL") {
if ($null -eq $jsonObject.manualFarmSpec.rdsServers) { if ($null -eq $PoolObject.manualFarmSpec.rdsServers) {
Throw "Specify rdsServers name in json file" Throw "Specify rdsServers name"
} }
} }
} }
@@ -2788,9 +2795,17 @@ function Get-HVFarmCustomizationSetting {
throw "No Composer Domain Administrator found with netBiosName: [$netBiosName]" throw "No Composer Domain Administrator found with netBiosName: [$netBiosName]"
} }
$ADDomain_service_helper = New-Object VMware.Hv.ADDomainService $ADDomain_service_helper = New-Object VMware.Hv.ADDomainService
$adDomianId = ($ADDomain_service_helper.ADDomain_List($services) | Where-Object { $_.NetBiosName -eq $netBiosName } | Select-Object -Property id) $ADDomains = $ADDomain_service_helper.ADDomain_List($services)
if ($null -eq $adDomianId) { if ($netBiosName) {
throw "No Domain found with netBiosName: [$netBiosName]" $adDomianId = ( $ADDomains| Where-Object { $_.NetBiosName -eq $netBiosName } | Select-Object -Property id)
if ($null -eq $adDomianId) {
throw "No Domain found with netBiosName: [$netBiosName]"
}
} else {
$adDomianId = ( $ADDomains[0] | Select-Object -Property id)
if ($null -eq $adDomianId) {
throw "No Domain configured in view administrator UI"
}
} }
$ad_containder_service_helper = New-Object VMware.Hv.AdContainerService $ad_containder_service_helper = New-Object VMware.Hv.AdContainerService
$adContainerId = ($ad_containder_service_helper.ADContainer_ListByDomain($services, $adDomianId.id) | Where-Object { $_.Rdn -eq $adContainer } | Select-Object -Property id).id $adContainerId = ($ad_containder_service_helper.ADContainer_ListByDomain($services, $adDomianId.id) | Where-Object { $_.Rdn -eq $adContainer } | Select-Object -Property id).id
@@ -3055,7 +3070,7 @@ function New-HVPool {
.EXAMPLE .EXAMPLE
Create new automated linked clone pool by using JSON spec file Create new automated linked clone pool by using JSON spec file
New-HVPool -Spec C:\VMWare\Specs\LinkedClone.json New-HVPool -Spec C:\VMWare\Specs\LinkedClone.json -Confirm:$false
.EXAMPLE .EXAMPLE
Clones new pool by using existing pool configuration Clones new pool by using existing pool configuration
@@ -3729,7 +3744,8 @@ function New-HVPool {
} }
try { try {
Test-HVDesktopSpec -JsonObject $jsonObject #Json object validation
Test-HVPoolSpec -PoolObject $jsonObject
} catch { } catch {
Write-Error "Json object validation failed, $_" Write-Error "Json object validation failed, $_"
break break
@@ -3765,21 +3781,20 @@ function New-HVPool {
$FullClone = $true $FullClone = $true
} }
switch ($custType) { switch ($custType) {
'SYS_PREP' { 'SYS_PREP' {
$sysprepCustomizationSettings = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.SysprepCustomizationSettings $sysprepCustomizationSettings = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.SysprepCustomizationSettings
$sysPrepName = $sysprepCustomizationSettings.customizationSpec $sysPrepName = $sysprepCustomizationSettings.customizationSpec
$reusePreExistingAccounts = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.reusePreExistingAccounts $reusePreExistingAccounts = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.reusePreExistingAccounts
} }
'QUICK_PREP' { 'QUICK_PREP' {
$powerOffScriptName= $jsonObject.AutomatedDesktopSpec.CustomizationSettings.QuickprepCustomizationSettings.PowerOffScriptName $powerOffScriptName= $jsonObject.AutomatedDesktopSpec.CustomizationSettings.QuickprepCustomizationSettings.PowerOffScriptName
$powerOffScriptParameters = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.QuickprepCustomizationSettings.PowerOffScriptParameters $powerOffScriptParameters = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.QuickprepCustomizationSettings.PowerOffScriptParameters
$postSynchronizationScriptName = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.QuickprepCustomizationSettings.PostSynchronizationScriptName $postSynchronizationScriptName = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.QuickprepCustomizationSettings.PostSynchronizationScriptName
$postSynchronizationScriptParameters = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.QuickprepCustomizationSettings.PostSynchronizationScriptParameters $postSynchronizationScriptParameters = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.QuickprepCustomizationSettings.PostSynchronizationScriptParameters
} }
'NONE' { 'NONE' {
$doNotPowerOnVMsAfterCreation = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.NoCustomizationSettings.DoNotPowerOnVMsAfterCreation $doNotPowerOnVMsAfterCreation = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.NoCustomizationSettings.DoNotPowerOnVMsAfterCreation
} }
} }
} }
$namingMethod = $jsonObject.AutomatedDesktopSpec.VmNamingSpec.NamingMethod $namingMethod = $jsonObject.AutomatedDesktopSpec.VmNamingSpec.NamingMethod
@@ -3927,8 +3942,12 @@ function New-HVPool {
$allowMultipleSessionsPerUser = $jsonObject.DesktopSettings.logoffSettings.allowMultipleSessionsPerUser $allowMultipleSessionsPerUser = $jsonObject.DesktopSettings.logoffSettings.allowMultipleSessionsPerUser
$deleteOrRefreshMachineAfterLogoff = $jsonObject.DesktopSettings.logoffSettings.deleteOrRefreshMachineAfterLogoff $deleteOrRefreshMachineAfterLogoff = $jsonObject.DesktopSettings.logoffSettings.deleteOrRefreshMachineAfterLogoff
$refreshOsDiskAfterLogoff = $jsonObject.DesktopSettings.logoffSettings.refreshOsDiskAfterLogoff $refreshOsDiskAfterLogoff = $jsonObject.DesktopSettings.logoffSettings.refreshOsDiskAfterLogoff
$refreshPeriodDaysForReplicaOsDisk = $jsonObject.DesktopSettings.logoffSettings.refreshPeriodDaysForReplicaOsDisk if ($jsonObject.DesktopSettings.logoffSettings.refreshPeriodDaysForReplicaOsDisk) {
$refreshThresholdPercentageForReplicaOsDisk = $jsonObject.DesktopSettings.logoffSettings.refreshThresholdPercentageForReplicaOsDisk $refreshPeriodDaysForReplicaOsDisk = $jsonObject.DesktopSettings.logoffSettings.refreshPeriodDaysForReplicaOsDisk
}
if ($jsonObject.DesktopSettings.logoffSettings.refreshThresholdPercentageForReplicaOsDisk) {
$refreshThresholdPercentageForReplicaOsDisk = $jsonObject.DesktopSettings.logoffSettings.refreshThresholdPercentageForReplicaOsDisk
}
} }
if ($null -ne $jsonObject.DesktopSettings.displayProtocolSettings) { if ($null -ne $jsonObject.DesktopSettings.displayProtocolSettings) {
@@ -3938,7 +3957,9 @@ function New-HVPool {
if ($null -ne $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings) { if ($null -ne $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings) {
$renderer3D = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.renderer3D $renderer3D = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.renderer3D
$enableGRIDvGPUs = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.enableGRIDvGPUs $enableGRIDvGPUs = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.enableGRIDvGPUs
$vRamSizeMB = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.vRamSizeMB if ($jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.vRamSizeMB) {
$vRamSizeMB = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.vRamSizeMB
}
$maxNumberOfMonitors = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.maxNumberOfMonitors $maxNumberOfMonitors = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.maxNumberOfMonitors
$maxResolutionOfAnyOneMonitor = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.maxResolutionOfAnyOneMonitor $maxResolutionOfAnyOneMonitor = $jsonObject.DesktopSettings.displayProtocolSettings.pcoipDisplaySettings.maxResolutionOfAnyOneMonitor
} }
@@ -3947,8 +3968,12 @@ function New-HVPool {
if ($null -ne $jsonObject.DesktopSettings.mirageConfigurationOverrides) { if ($null -ne $jsonObject.DesktopSettings.mirageConfigurationOverrides) {
$overrideGlobalSetting = $jsonObject.DesktopSettings.mirageConfigurationOverrides.overrideGlobalSetting $overrideGlobalSetting = $jsonObject.DesktopSettings.mirageConfigurationOverrides.overrideGlobalSetting
$enabled = $jsonObject.DesktopSettings.mirageConfigurationOverrides.enabled if ($jsonObject.DesktopSettings.mirageConfigurationOverrides.enabled) {
$url = $jsonObject.DesktopSettings.mirageConfigurationOverrides.url $enabled = $jsonObject.DesktopSettings.mirageConfigurationOverrides.enabled
}
if ($jsonObject.DesktopSettings.mirageConfigurationOverrides.url) {
$url = $jsonObject.DesktopSettings.mirageConfigurationOverrides.url
}
} }
} }
if ($null -ne $jsonObject.DesktopSettings.flashSettings) { if ($null -ne $jsonObject.DesktopSettings.flashSettings) {
@@ -4309,7 +4334,15 @@ function New-HVPool {
$desktop_helper = New-Object VMware.Hv.DesktopService $desktop_helper = New-Object VMware.Hv.DesktopService
if ($pscmdlet.ShouldProcess($desktopSpecObj.base.name)) { if ($pscmdlet.ShouldProcess($desktopSpecObj.base.name)) {
$id = $desktop_helper.Desktop_create($services,$desktopSpecObj) $id = $desktop_helper.Desktop_create($services,$desktopSpecObj)
} } else {
try {
#DesktopSpec validation
Test-HVPoolSpec -PoolObject $desktopSpecObj
} catch {
Write-Error "DesktopSpec object validation failed, $_"
break
}
}
return $desktopSpecObj return $desktopSpecObj
} }
@@ -4354,12 +4387,6 @@ function Get-HVPoolProvisioningData {
} }
$vmObject.ParentVm = $parentVmObj.id $vmObject.ParentVm = $parentVmObj.id
$dataCenterID = $parentVmObj.datacenter $dataCenterID = $parentVmObj.datacenter
if ($dataCenter -and $dataCenterID) {
$baseImageVmInfo = $base_imageVm_helper.BaseImageVm_ListByDatacenter($services,$dataCenterID)
if (! ($baseImageVmInfo.Path -like "/$dataCenter/*")) {
throw "$parentVM not exists in datacenter: [$dataCenter]"
}
}
$vmObject.datacenter = $dataCenterID $vmObject.datacenter = $dataCenterID
} }
if ($snapshotVM) { if ($snapshotVM) {
@@ -4546,9 +4573,17 @@ function Get-HVPoolCustomizationSetting {
# View Composer and Instant Clone Engine Active Directory container for QuickPrep and ClonePrep. This must be set for Instant Clone Engine or SVI sourced desktops. # View Composer and Instant Clone Engine Active Directory container for QuickPrep and ClonePrep. This must be set for Instant Clone Engine or SVI sourced desktops.
if ($InstantClone -or $LinkedClone) { if ($InstantClone -or $LinkedClone) {
$ad_domain_helper = New-Object VMware.Hv.ADDomainService $ad_domain_helper = New-Object VMware.Hv.ADDomainService
$adDomianId = ($ad_domain_helper.ADDomain_List($services) | Where-Object { $_.NetBiosName -eq $netBiosName } | Select-Object -Property id) $ADDomains = $ad_domain_helper.ADDomain_List($services)
if ($null -eq $adDomianId) { if ($netBiosName) {
throw "No Domain found with netBiosName: [$netBiosName]" $adDomianId = ($ADDomains | Where-Object { $_.NetBiosName -eq $netBiosName } | Select-Object -Property id)
if ($null -eq $adDomianId) {
throw "No Domain found with netBiosName: [$netBiosName]"
}
} else {
$adDomianId = ($ADDomains[0] | Select-Object -Property id)
if ($null -eq $adDomianId) {
throw "No Domain configured in view administrator UI"
}
} }
$ad_container_helper = New-Object VMware.Hv.AdContainerService $ad_container_helper = New-Object VMware.Hv.AdContainerService
$adContainerId = ($ad_container_helper.ADContainer_ListByDomain($services,$adDomianId.id) | Where-Object { $_.Rdn -eq $adContainer } | Select-Object -Property id).id $adContainerId = ($ad_container_helper.ADContainer_ListByDomain($services,$adDomianId.id) | Where-Object { $_.Rdn -eq $adContainer } | Select-Object -Property id).id
@@ -4681,115 +4716,115 @@ function Get-DesktopSpec {
} }
function Test-HVDesktopSpec { function Test-HVPoolSpec {
param( param(
[Parameter(Mandatory = $true)] [Parameter(Mandatory = $true)]
$JsonObject $PoolObject
) )
if ($null -eq $jsonObject.type) { if ($null -eq $PoolObject.type) {
Throw "Pool type is empty, need to be configure in json file" Throw "Pool type is empty, need to be configured"
} }
if ($null -eq $jsonObject.Base.Name) { if ($null -eq $PoolObject.Base.Name) {
Throw "Pool name is empty, need to be configure in json file" Throw "Pool name is empty, need to be configured"
} }
if ($null -eq $jsonObject.Base.AccessGroup) { if ($null -eq $PoolObject.Base.AccessGroup) {
Throw "AccessGroup of pool is empty, need to be configure in json file" Throw "AccessGroup of pool is empty, need to be configured"
} }
if ($jsonObject.type -eq "AUTOMATED") { if ($PoolObject.type -eq "AUTOMATED") {
if (! (($jsonObject.AutomatedDesktopSpec.UserAssignment.UserAssignment -eq "FLOATING") -or ($jsonObject.AutomatedDesktopSpec.UserAssignment.UserAssignment -eq "DEDICATED")) ) { if (! (($PoolObject.AutomatedDesktopSpec.UserAssignment.UserAssignment -eq "FLOATING") -or ($PoolObject.AutomatedDesktopSpec.UserAssignment.UserAssignment -eq "DEDICATED")) ) {
Throw "UserAssignment must be FLOATING or DEDICATED" Throw "UserAssignment must be FLOATING or DEDICATED"
} }
if ($jsonObject.AutomatedDesktopSpec.ProvisioningType -eq $null) { if ($PoolObject.AutomatedDesktopSpec.ProvisioningType -eq $null) {
Throw "Pool Provisioning type is empty, need to be configure in json file" Throw "Pool Provisioning type is empty, need to be configured"
} }
$provisionTypeArray = @('VIRTUAL_CENTER', 'VIEW_COMPOSER', 'INSTANT_CLONE_ENGINE') $provisionTypeArray = @('VIRTUAL_CENTER', 'VIEW_COMPOSER', 'INSTANT_CLONE_ENGINE')
if (! ($provisionTypeArray -contains $jsonObject.AutomatedDesktopSpec.provisioningType)) { if (! ($provisionTypeArray -contains $PoolObject.AutomatedDesktopSpec.provisioningType)) {
Throw "ProvisioningType of pool is invalid" Throw "ProvisioningType of pool is invalid"
} }
if ($null -eq $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.EnableProvisioning) { if ($null -eq $PoolObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.EnableProvisioning) {
Throw "Whether to enable provisioning immediately or not, need to configure in json file" Throw "Whether to enable provisioning immediately or not, need to be configured"
} }
if ($null -eq $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.StopProvisioningOnError) { if ($null -eq $PoolObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.StopProvisioningOnError) {
Throw "Whether to stop provisioning immediately or not on error, need to configure in json file" Throw "Whether to stop provisioning immediately or not on error, need to be configured"
} }
if ($null -eq $jsonObject.AutomatedDesktopSpec.VmNamingSpec.NamingMethod) { if ($null -eq $PoolObject.AutomatedDesktopSpec.VmNamingSpec.NamingMethod) {
Throw "Determines how the VMs in the desktop are named, need to configure in json file" Throw "Determines how the VMs in the desktop are named, need to be configured"
} }
if ($null -ne $jsonObject.AutomatedDesktopSpec.VmNamingSpec.NamingMethod) { if ($null -ne $PoolObject.AutomatedDesktopSpec.VmNamingSpec.NamingMethod) {
$namingMethodArray = @('PATTERN','SPECIFIED') $namingMethodArray = @('PATTERN','SPECIFIED')
if (! ($namingMethodArray -contains $jsonObject.AutomatedDesktopSpec.VmNamingSpec.NamingMethod)) { if (! ($namingMethodArray -contains $PoolObject.AutomatedDesktopSpec.VmNamingSpec.NamingMethod)) {
Throw "NamingMethod property must to be one of these SPECIFIED or PATTERN" Throw "NamingMethod property must to be one of these SPECIFIED or PATTERN"
} }
if (($null -eq $jsonObject.AutomatedDesktopSpec.VmNamingSpec.patternNamingSettings) -and ($null -eq $jsonObject.AutomatedDesktopSpec.VmNamingSpec.specificNamingSpec)) { if (($null -eq $PoolObject.AutomatedDesktopSpec.VmNamingSpec.patternNamingSettings) -and ($null -eq $PoolObject.AutomatedDesktopSpec.VmNamingSpec.specificNamingSpec)) {
Throw "Naming pattern (or) Specified name settings need to be configure in json file" Throw "Naming pattern (or) Specified name settings need to be configured"
} }
} }
if ($null -eq $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.VirtualCenterStorageSettings.UseVSan) { if ($null -eq $PoolObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.VirtualCenterStorageSettings.UseVSan) {
Throw "Must specify whether to use virtual SAN or not" Throw "Must specify whether to use virtual SAN or not"
} }
$jsonTemplate = $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.Template $jsonTemplate = $PoolObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.Template
$jsonParentVm = $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.ParentVm $jsonParentVm = $PoolObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.ParentVm
$jsonSnapshot = $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.Snapshot $jsonSnapshot = $PoolObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.Snapshot
$jsonVmFolder = $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.VmFolder $jsonVmFolder = $PoolObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.VmFolder
$jsonHostOrCluster = $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.HostOrCluster $jsonHostOrCluster = $PoolObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.HostOrCluster
$ResourcePool = $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.ResourcePool $ResourcePool = $PoolObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.virtualCenterProvisioningData.ResourcePool
if (! (($null -ne $jsonTemplate) -or (($null -ne $jsonParentVm) -and ($null -ne $jsonSnapshot) ))) { if (! (($null -ne $jsonTemplate) -or (($null -ne $jsonParentVm) -and ($null -ne $jsonSnapshot) ))) {
Throw "Must specify Template or (ParentVm and Snapshot) names in json file" Throw "Must specify Template or (ParentVm and Snapshot) names"
} }
if ($null -eq $jsonVmFolder) { if ($null -eq $jsonVmFolder) {
Throw "Must specify VM folder in json file to deploy the VMs" Throw "Must specify VM folder to deploy the VMs"
} }
if ($null -eq $jsonHostOrCluster) { if ($null -eq $jsonHostOrCluster) {
Throw "Must specify Host or cluster in json file to deploy the VMs" Throw "Must specify HostOrCluster to deploy the VMs"
} }
if ($null -eq $resourcePool) { if ($null -eq $resourcePool) {
Throw "Must specify Resource pool in json file to deploy the VMs" Throw "Must specify Resource pool to deploy the VMs"
} }
if ($null -eq $jsonObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.VirtualCenterStorageSettings.Datastores) { if ($null -eq $PoolObject.AutomatedDesktopSpec.VirtualCenterProvisioningSettings.VirtualCenterStorageSettings.Datastores) {
Throw "Must specify datastores names in json file" Throw "Must specify datastores names"
} }
if ($null -eq $jsonObject.AutomatedDesktopSpec.VirtualCenterManagedCommonSettings.transparentPageSharingScope) { if ($null -eq $PoolObject.AutomatedDesktopSpec.VirtualCenterManagedCommonSettings.transparentPageSharingScope) {
Throw "Must specify transparent page sharing scope in json file" Throw "Must specify transparent page sharing scope"
} }
$jsonCustomizationType = $jsonObject.AutomatedDesktopSpec.CustomizationSettings.CustomizationType $jsonCustomizationType = $PoolObject.AutomatedDesktopSpec.CustomizationSettings.CustomizationType
switch ($jsonCustomizationType) { switch ($jsonCustomizationType) {
"NONE" { "NONE" {
if ($null -eq $jsonObject.AutomatedDesktopSpec.CustomizationSettings.noCustomizationSettings) { if ($null -eq $PoolObject.AutomatedDesktopSpec.CustomizationSettings.noCustomizationSettings) {
Throw "Specify noCustomization Settings in json file" Throw "Specify noCustomization Settings"
} }
} }
"QUICK_PREP" { "QUICK_PREP" {
if ($null -eq $jsonObject.AutomatedDesktopSpec.CustomizationSettings.quickprepCustomizationSettings) { if ($null -eq $PoolObject.AutomatedDesktopSpec.CustomizationSettings.quickprepCustomizationSettings) {
Throw "Specify quickprep CustomizationSettings in json file" Throw "Specify quickPrep customizationSettings"
} }
} }
"SYS_PREP" { "SYS_PREP" {
if ($null -eq $jsonObject.AutomatedDesktopSpec.CustomizationSettings.sysprepCustomizationSettings) { if ($null -eq $PoolObject.AutomatedDesktopSpec.CustomizationSettings.sysprepCustomizationSettings) {
Throw "Specify sysprep CustomizationSettings in json file" Throw "Specify sysPrep customizationSettings"
} }
} }
"CLONE_PREP" { "CLONE_PREP" {
if ($null -eq $jsonObject.AutomatedDesktopSpec.CustomizationSettings.cloneprepCustomizationSettings) { if ($null -eq $PoolObject.AutomatedDesktopSpec.CustomizationSettings.cloneprepCustomizationSettings) {
Throw "Specify ClonePrep CustomizationSettings in json file" Throw "Specify clonePrep customizationSettings"
} }
} }
} }
} elseIf ($jsonObject.Type -eq "MANUAL") { } elseIf ($PoolObject.Type -eq "MANUAL") {
$jsonUserAssignment = $jsonObject.ManualDesktopSpec.UserAssignment.UserAssignment $jsonUserAssignment = $PoolObject.ManualDesktopSpec.UserAssignment.UserAssignment
if (! (($jsonUserAssignment -eq "FLOATING") -or ($jsonUserAssignment -eq "DEDICATED")) ) { if (! (($jsonUserAssignment -eq "FLOATING") -or ($jsonUserAssignment -eq "DEDICATED")) ) {
Throw "UserAssignment must be FLOATING or DEDICATED" Throw "UserAssignment must be FLOATING or DEDICATED"
} }
$jsonSource = @('VIRTUAL_CENTER','UNMANAGED') $jsonSource = @('VIRTUAL_CENTER','UNMANAGED')
if (! ($jsonSource -contains $jsonObject.ManualDesktopSpec.Source)) { if (! ($jsonSource -contains $PoolObject.ManualDesktopSpec.Source)) {
Throw "The Source of machines must be VIRTUAL_CENTER or UNMANAGED" Throw "The Source of machines must be VIRTUAL_CENTER or UNMANAGED"
} }
if ($null -eq $jsonObject.ManualDesktopSpec.Machines) { if ($null -eq $PoolObject.ManualDesktopSpec.Machines) {
Throw "Specify list of machines to add to this desktop during creation" Throw "Specify list of virtual machines to be added to this pool"
} }
} }
elseIf ($jsonObject.type -eq "RDS") { elseIf ($PoolObject.type -eq "RDS") {
if ($null -eq $jsonObject.RdsDesktopSpec.Farm) { if ($null -eq $PoolObject.RdsDesktopSpec.Farm) {
Throw "Specify Farm needed to create RDS Desktop" Throw "Specify farm needed to create RDS desktop"
} }
} }
} }
@@ -4813,7 +4848,7 @@ function Remove-HVFarm {
.EXAMPLE .EXAMPLE
Delete a given farm. For an automated farm, all the RDS Server VMs are deleted from disk whereas for a manual farm only the RDS Server associations are removed. Delete a given farm. For an automated farm, all the RDS Server VMs are deleted from disk whereas for a manual farm only the RDS Server associations are removed.
Remove-HVFarm -FarmName 'Farm-01' -HvServer $hvServer Remove-HVFarm -FarmName 'Farm-01' -HvServer $hvServer -Confirm:$false
.EXAMPLE .EXAMPLE
Deletes a given Farm object(s). For an automated farm, all the RDS Server VMs are deleted from disk whereas for a manual farm only the RDS Server associations are removed. Deletes a given Farm object(s). For an automated farm, all the RDS Server VMs are deleted from disk whereas for a manual farm only the RDS Server associations are removed.
@@ -4930,7 +4965,7 @@ function Remove-HVPool {
.EXAMPLE .EXAMPLE
Deletes pool from disk with given parameters PoolName etc. Deletes pool from disk with given parameters PoolName etc.
Remove-HVPool -HvServer $hvServer -PoolName 'FullClone' -DeleteFromDisk Remove-HVPool -HvServer $hvServer -PoolName 'FullClone' -DeleteFromDisk -Confirm:$false
.EXAMPLE .EXAMPLE
Deletes specified pool from disk Deletes specified pool from disk
@@ -5088,7 +5123,7 @@ function Set-HVFarm {
.EXAMPLE .EXAMPLE
Updates farm configuration by using json file Updates farm configuration by using json file
Set-HVFarm -FarmName 'Farm-01' -Spec 'C:\Edit-HVFarm\ManualEditFarm.json' Set-HVFarm -FarmName 'Farm-01' -Spec 'C:\Edit-HVFarm\ManualEditFarm.json' -Confirm:$false
.EXAMPLE .EXAMPLE
Updates farm configuration with given parameters key and value Updates farm configuration with given parameters key and value
@@ -5290,7 +5325,7 @@ function Set-HVPool {
.EXAMPLE .EXAMPLE
Updates pool configuration by using json file Updates pool configuration by using json file
Set-HVPool -PoolName 'ManualPool' -Spec 'C:\Edit-HVPool\EditPool.json' Set-HVPool -PoolName 'ManualPool' -Spec 'C:\Edit-HVPool\EditPool.json' -Confirm:$false
.EXAMPLE .EXAMPLE
Updates pool configuration with given parameters key and value Updates pool configuration with given parameters key and value
@@ -5500,7 +5535,7 @@ function Start-HVFarm {
.EXAMPLE .EXAMPLE
Requests a recompose of RDS Servers in the specified automated farm Requests a recompose of RDS Servers in the specified automated farm
Start-HVFarm -Recompose -Farm 'Farm-01' -LogoffSetting FORCE_LOGOFF -ParentVM 'View-Agent-Win8' -SnapshotVM 'Snap_USB' Start-HVFarm -Recompose -Farm 'Farm-01' -LogoffSetting FORCE_LOGOFF -ParentVM 'View-Agent-Win8' -SnapshotVM 'Snap_USB' -Confirm:$false
.EXAMPLE .EXAMPLE
Requests a recompose task for automated farm in specified time Requests a recompose task for automated farm in specified time
@@ -5776,7 +5811,7 @@ function Start-HVPool {
.EXAMPLE .EXAMPLE
Requests a refresh of machines in the specified pool Requests a refresh of machines in the specified pool
Start-HVPool -Refresh -Pool 'LCPool3' -LogoffSetting FORCE_LOGOFF Start-HVPool -Refresh -Pool 'LCPool3' -LogoffSetting FORCE_LOGOFF -Confirm:$false
.EXAMPLE .EXAMPLE
Requests a rebalance of machines in a pool with specified time Requests a rebalance of machines in a pool with specified time
@@ -6414,7 +6449,7 @@ function Get-HVMachineSummary {
return $machineList return $machineList
} }
function Get-HVDesktopSpec { function Get-HVPoolSpec {
<# <#
.Synopsis .Synopsis
Gets desktop specification Gets desktop specification
@@ -6431,11 +6466,11 @@ function Get-HVDesktopSpec {
.EXAMPLE .EXAMPLE
Converts DesktopInfo to DesktopSpec Converts DesktopInfo to DesktopSpec
Get-HVDesktopSpec -DesktopInfo $DesktopInfoObj Get-HVPoolSpec -DesktopInfo $DesktopInfoObj
.EXAMPLE .EXAMPLE
Converts DesktopInfo to DesktopSpec and also dumps json object Converts DesktopInfo to DesktopSpec and also dumps json object
Get-HVPool -PoolName 'LnkClnJson' | Get-HVDesktopSpec -FilePath "C:\temp\LnkClnJson.json" Get-HVPool -PoolName 'LnkClnJson' | Get-HVPoolSpec -FilePath "C:\temp\LnkClnJson.json"
.OUTPUTS .OUTPUTS
Returns desktop specification Returns desktop specification
@@ -6763,4 +6798,4 @@ function Get-HVInternalName {
} }
} }
Export-ModuleMember Add-HVDesktop,Add-HVRDSServer,Connect-HVEvent,Disconnect-HVEvent,Get-HVDesktopSpec,Get-HVInternalName, Get-HVEvent,Get-HVFarm,Get-HVFarmSummary,Get-HVPool,Get-HVPoolSummary,Get-HVMachine,Get-HVMachineSummary,Get-HVQueryResult,Get-HVQueryFilter,New-HVFarm,New-HVPool,Remove-HVFarm,Remove-HVPool,Set-HVFarm,Set-HVPool,Start-HVFarm,Start-HVPool Export-ModuleMember Add-HVDesktop,Add-HVRDSServer,Connect-HVEvent,Disconnect-HVEvent,Get-HVPoolSpec,Get-HVInternalName, Get-HVEvent,Get-HVFarm,Get-HVFarmSummary,Get-HVPool,Get-HVPoolSummary,Get-HVMachine,Get-HVMachineSummary,Get-HVQueryResult,Get-HVQueryFilter,New-HVFarm,New-HVPool,Remove-HVFarm,Remove-HVPool,Set-HVFarm,Set-HVPool,Start-HVFarm,Start-HVPool