Update VMware.HV.Helper.psm1

Added functions to starting and starting Instant Clone maintenance operations on a host for Horizon 7.x
This commit is contained in:
Jack McMichael
2018-12-01 17:15:38 -07:00
parent cb9e57e185
commit 937f213451

View File

@@ -11478,4 +11478,117 @@ function Get-HVlicense {
[System.gc]::collect()
}
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,New-HVEntitlement,Get-HVEntitlement,Remove-HVEntitlement, Set-HVMachine, New-HVGlobalEntitlement, Remove-HVGlobalEntitlement, Get-HVGlobalEntitlement, Set-HVApplicationIcon, Remove-HVApplicationIcon, Get-HVGlobalSettings, Set-HVGlobalSettings, Set-HVGlobalEntitlement, Get-HVResourceStructure, Get-HVLocalSession, Get-HVGlobalSession, Reset-HVMachine, Remove-HVMachine, Get-HVHealth, New-HVPodfederation, Remove-HVPodFederation, Get-HVPodFederation, Register-HVPod, Unregister-HVPod, Set-HVPodFederation,Get-HVSite,New-HVSite,Set-HVSite,Remove-HVSite,New-HVHomeSite,Get-HVHomeSite,Set-HVEventDatabase,Get-HVEventDatabase,Clear-HVEventDatabase,Get-HVlicense,Set-HVlicense
function Start-HVMaintenance {
<#
.Synopsis
Puts a host in instant clone maintanence mode
.DESCRIPTION
Puts a host in instant clone maintanence mode
.PARAMETER Host
ESXi Host name to modify the InstantClone.Maintenance attribute
.EXAMPLE
Start-HvMaintenance -Host <hostname>
.NOTES
Author : Jack McMichael
Author email : @jackwmc4 / jackwmc4@gmail.com
Version : 1.0
===Tested Against Environment====
Horizon View Server Version : 7.6
PowerCLI Version : PowerCLI 11
PowerShell Version : 5.1
#>
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = 'High')]
param(
[Parameter(Mandatory=$true, Position=0)]
[string]$Server,
[Parameter(Mandatory = $false)]
$HvServer = $null
)
begin {
$services = Get-ViewAPIService -hvServer $hvServer
if ($null -eq $services) {
Write-Error "Could not retrieve ViewApi services from connection object"
break
}
}
process {
if ((Get-Annotation -Entity (Get-VMHost -Name $Server) -CustomAttribute "InstantClone.Maintenance").Value -eq ""){
Set-Annotation -Entity (Get-VMHost -Name $Server) -CustomAttribute "InstantClone.Maintenance" -Value "1" | Out-Null
}
while ((Get-Annotation -Entity (Get-VMHost -Name $Server) -CustomAttribute "InstantClone.Maintenance").Value -ne "2") {
shouldcontinue()
Start-Sleep -Seconds 10
}
[System.gc]::collect()
}
}
function Stop-HVMaintenance {
<#
.Synopsis
Takes a host out of instant clone maintanence mode
.DESCRIPTION
Takes a host out of instant clone maintanence mode
.PARAMETER Host
ESXi Host name to clear the InstantClone.Maintenance attribute
.EXAMPLE
Stop-HvMaintenance -Host <hostname>
.NOTES
Author : Jack McMichael
Author email : @jackwmc4 / jackwmc4@gmail.com
Version : 1.0
===Tested Against Environment====
Horizon View Server Version : 7.6
PowerCLI Version : PowerCLI 11
PowerShell Version : 5.1
#>
[CmdletBinding(
SupportsShouldProcess = $true,
ConfirmImpact = 'High')]
param(
[Parameter(Mandatory=$true, Position=0)]
[string]$Server,
[Parameter(Mandatory = $false)]
$HvServer = $null
)
begin {
$services = Get-ViewAPIService -hvServer $hvServer
if ($null -eq $services) {
Write-Error "Could not retrieve ViewApi services from connection object"
break
}
}
process {
if (-not (Get-Annotation -Entity (Get-VMHost -Name $Server) -CustomAttribute "InstantClone.Maintenance").Value -eq "") {
Set-Annotation -Entity (Get-VMHost -Name $Server) -CustomAttribute "InstantClone.Maintenance" -Value "" | Out-Null
}
Set-VMhost $Host -State Connected | Out-Null
[System.gc]::collect()
}
}
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,New-HVEntitlement,Get-HVEntitlement,Remove-HVEntitlement, Set-HVMachine, New-HVGlobalEntitlement, Remove-HVGlobalEntitlement, Get-HVGlobalEntitlement, Set-HVApplicationIcon, Remove-HVApplicationIcon, Get-HVGlobalSettings, Set-HVGlobalSettings, Set-HVGlobalEntitlement, Get-HVResourceStructure, Get-HVLocalSession, Get-HVGlobalSession, Reset-HVMachine, Remove-HVMachine, Get-HVHealth, New-HVPodfederation, Remove-HVPodFederation, Get-HVPodFederation, Register-HVPod, Unregister-HVPod, Set-HVPodFederation,Get-HVSite,New-HVSite,Set-HVSite,Remove-HVSite,New-HVHomeSite,Get-HVHomeSite,Set-HVEventDatabase,Get-HVEventDatabase,Clear-HVEventDatabase,Get-HVlicense,Set-HVlicense, Start-HVMaintenance, Stop-HVMaintenance