From 5a0bb408ba7c88b0dfcc26cbbac112c39afb40d5 Mon Sep 17 00:00:00 2001 From: Wouter Kursten Date: Sat, 7 Apr 2018 11:26:06 +0200 Subject: [PATCH 1/5] Added get-hvhealth --- .../VMware.Hv.Helper/VMware.HV.Helper.psm1 | 98 ++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 b/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 index 0f9a2f9..36e66e0 100644 --- a/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 +++ b/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 @@ -9990,4 +9990,100 @@ function Reset-HVMachine { } } -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 +function get-hvhealth { + <# + .Synopsis + Pulls health information from Horizon View + + .DESCRIPTION + Queries and returns health information from the local Horizon Pod + + .PARAMETER Servicename + The name of the service to query the health for. + This will default to Connection server health. + Available services are ADDomain,CertificateSSOConnector,ConnectionServer,EventDatabase,SAMLAuthenticator,SecurityServer,ViewComposer,VirtualCenter + + .PARAMETER HvServer + Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then + first element from global:DefaultHVServers would be considered in-place of hvServer + + .EXAMPLE + get-hvhealth -service connectionserver + Returns health for the connectionserver(s) + + + .EXAMPLE + get-hvhealth -service ViewComposer + Returns health for the View composer server(s) + + .NOTES + Author : Wouter Kursten + Author email : wouter@retouw.nl + Version : 1.0 + + ===Tested Against Environment==== + Horizon View Server Version : 7.3.2,7.4 + PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1 + PowerShell Version : 5.0 + #> + + [CmdletBinding( + SupportsShouldProcess = $true, + ConfirmImpact = 'High' + )] + + param( + + [Parameter(Mandatory = $false)] + [ValidateSet('ADDomain', 'CertificateSSOConnector', 'ConnectionServer', 'EventDatabase', 'SAMLAuthenticator', 'SecurityServer', 'ViewComposer', 'VirtualCenter')] + [string] + $Servicename = 'ConnectionServer', + + [Parameter(Mandatory = $false)] + $HvServer = $null + ) + + + $services = Get-ViewAPIService -hvServer $hvServer + if ($null -eq $services) { + Write-Error "Could not retrieve ViewApi services from connection object" + break + } + + switch ($Servicename) { + 'ADDomain' { + $healthinfo=$services.ADDomainHealth.ADDomainHealth_List() + } + 'CertificateSSOConnector' { + $healthinfo=$services.CertificateSSOConnectorHealth.CertificateSSOConnectorHealth_list() + } + 'ConnectionServer' { + $healthinfo=$services.ConnectionServerHealth.ConnectionServerHealth_list() + } + 'EventDatabase' { + $healthinfo=$services.EventDatabaseHealth.EventDatabaseHealth_Get() + } + 'SAMLAuthenticator' { + $healthinfo=$services.SAMLAuthenticatorHealth.SAMLAuthenticatorHealth_List() + } + 'SecurityServer' { + $healthinfo=$services.SecurityServerHealth.SecurityServerHealth_List() + } + 'ViewComposer' { + $healthinfo=$services.ViewComposerHealth.ViewComposerHealth_List() + } + 'VirtualCenter' { + $healthinfo=$services.VirtualCenterHealth.VirtualCenterHealth_List() + } + } + if ($healthinfo){ + return $healthinfo + } + else { + Write-Output "No healthdata found for the $servicename service" + } + [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, Get-HVHealth From 969d31fcfbf5f82aea40d43f3730b36a40f87426 Mon Sep 17 00:00:00 2001 From: Wouter Kursten Date: Sun, 8 Apr 2018 10:56:34 +0200 Subject: [PATCH 2/5] added pod to get-hvhealth --- Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 b/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 index 36e66e0..35c090c 100644 --- a/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 +++ b/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 @@ -10001,7 +10001,7 @@ function get-hvhealth { .PARAMETER Servicename The name of the service to query the health for. This will default to Connection server health. - Available services are ADDomain,CertificateSSOConnector,ConnectionServer,EventDatabase,SAMLAuthenticator,SecurityServer,ViewComposer,VirtualCenter + Available services are ADDomain,CertificateSSOConnector,ConnectionServer,EventDatabase,SAMLAuthenticator,SecurityServer,ViewComposer,VirtualCenter,Pod .PARAMETER HvServer Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then @@ -10035,7 +10035,7 @@ function get-hvhealth { param( [Parameter(Mandatory = $false)] - [ValidateSet('ADDomain', 'CertificateSSOConnector', 'ConnectionServer', 'EventDatabase', 'SAMLAuthenticator', 'SecurityServer', 'ViewComposer', 'VirtualCenter')] + [ValidateSet('ADDomain', 'CertificateSSOConnector', 'ConnectionServer', 'EventDatabase', 'SAMLAuthenticator', 'SecurityServer', 'ViewComposer', 'VirtualCenter', 'pod')] [string] $Servicename = 'ConnectionServer', @@ -10075,6 +10075,9 @@ function get-hvhealth { 'VirtualCenter' { $healthinfo=$services.VirtualCenterHealth.VirtualCenterHealth_List() } + 'Pod' { + $healthinfo=$services.podhealth.PodHealth_List() + } } if ($healthinfo){ return $healthinfo From 373b90909584ee0b80a9687eab500536af48c95f Mon Sep 17 00:00:00 2001 From: Wouter Kursten Date: Wed, 25 Apr 2018 11:52:50 +0200 Subject: [PATCH 3/5] added multiple podfederation functions --- .../VMware.Hv.Helper/VMware.HV.Helper.psm1 | 388 +++++++++++++++++- 1 file changed, 387 insertions(+), 1 deletion(-) diff --git a/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 b/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 index 35c090c..03e2585 100644 --- a/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 +++ b/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 @@ -10088,5 +10088,391 @@ function get-hvhealth { [System.gc]::collect() } +function new-hvpodfederation { + <# + .Synopsis + Initiates a Horizon View Pod Federation (Cloud Pod Architecture) + + .DESCRIPTION + Starts the initialisation of a Horizon View Pod Federation. Other pod's can be joined to this federation to form the Cloud Pod Architecture + + .PARAMETER HvServer + Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then + first element from global:DefaultHVServers would be considered in-place of hvServer + + .EXAMPLE + new-hvpodfederation + Returns health for the connectionserver(s) -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, Get-HVHealth + .NOTES + Author : Wouter Kursten + Author email : wouter@retouw.nl + Version : 1.0 + + ===Tested Against Environment==== + Horizon View Server Version : 7.3.2,7.4 + PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1 + PowerShell Version : 5.0 + #> + + [CmdletBinding( + SupportsShouldProcess = $false, + ConfirmImpact = 'High' + )] + + param( + + [Parameter(Mandatory = $false)] + $HvServer = $null + ) + + + $services = Get-ViewAPIService -hvServer $hvServer + if ($null -eq $services) { + Write-Error "Could not retrieve ViewApi services from connection object" + break + } + $services.PodFederation.PodFederation_Initialize() + + Write-Output "The Pod Federation has been initiated. Please wait a couple of minutes and refresh any open admin consoles to use the newly available functionality." + + [System.gc]::collect() +} + +function remove-hvpodfederation { + <# + .Synopsis + Uninitiates a Horizon View Pod Federation (Cloud Pod Architecture) + + .DESCRIPTION + Starts the uninitialisation of a Horizon View Pod Federation. It does NOT remove a pod from a federation. + + .PARAMETER HvServer + Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then + first element from global:DefaultHVServers would be considered in-place of hvServer + + .EXAMPLE + Starts the Uninitiates a Horizon View Pod Federation. + Unintialises + + .NOTES + Author : Wouter Kursten + Author email : wouter@retouw.nl + Version : 1.0 + + ===Tested Against Environment==== + Horizon View Server Version : 7.3.2,7.4 + PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1 + PowerShell Version : 5.0 + #> + + [CmdletBinding( + SupportsShouldProcess = $false, + ConfirmImpact = 'High' + )] + + param( + + [Parameter(Mandatory = $false)] + $HvServer = $null + ) + + + $services = Get-ViewAPIService -hvServer $hvServer + if ($null -eq $services) { + Write-Error "Could not retrieve ViewApi services from connection object" + break + } + $services.PodFederation.PodFederation_Uninitialize() + + Write-Output "The uninitialisation of the Pod Federation has been started. Please wait a couple of minutes and refresh any open admin consoles to see the results." + + [System.gc]::collect() +} + +function get-hvpodfederation { + <# + .Synopsis + Returns information about a Horizon View Pod Federation (Cloud Pod Architecture) + + .DESCRIPTION + Returns information about a Horizon View Pod Federation (Cloud Pod Architecture) + + .PARAMETER HvServer + Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then + first element from global:DefaultHVServers would be considered in-place of hvServer + + .EXAMPLE + get-hvpodfederation + Returns information about a Horizon View Pod Federation + + .NOTES + Author : Wouter Kursten + Author email : wouter@retouw.nl + Version : 1.0 + + ===Tested Against Environment==== + Horizon View Server Version : 7.3.2,7.4 + PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1 + PowerShell Version : 5.0 + #> + + [CmdletBinding( + SupportsShouldProcess = $false, + ConfirmImpact = 'High' + )] + + param( + + [Parameter(Mandatory = $false)] + $HvServer = $null + ) + + + $services = Get-ViewAPIService -hvServer $hvServer + if ($null -eq $services) { + Write-Error "Could not retrieve ViewApi services from connection object" + break + } + $podfederationinfo=$services.PodFederation.PodFederation_Get() + return $podfederationinfo + + [System.gc]::collect() +} + +function register-hvpod { + <# + .Synopsis + Registers a pod in a Horizon View Pod Federation (Cloud Pod Architecture) + + .DESCRIPTION + Registers a pod in a Horizon View Pod Federation. You have to be connected to the pod you are joining to the federation. + + .PARAMETER ADUserName + User principal name of user + + .PARAMETER remoteconnectionserver + Servername of a connectionserver that already belongs to the PodFederation + + .PARAMETER ADPassword + Password of the type Securestring. Can be created with: + $password = Read-Host 'Domain Password' -AsSecureString + + .PARAMETER HvServer + Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then + first element from global:DefaultHVServers would be considered in-place of hvServer + + .EXAMPLE + C:\PS>$adpassword = Read-Host 'Domain Password' -AsSecureString + C:\PS>register-hvpod -remoteconnectionserver "servername" -username "user\domain" -password $adpassword + + .EXAMPLE + register-hvpod -remoteconnectionserver "servername" -username "user\domain" + It will now ask for the password + + .NOTES + Author : Wouter Kursten + Author email : wouter@retouw.nl + Version : 1.0 + + ===Tested Against Environment==== + Horizon View Server Version : 7.3.2,7.4 + PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1 + PowerShell Version : 5.0 + #> + + [CmdletBinding( + SupportsShouldProcess = $false, + ConfirmImpact = 'High' + )] + + param( + [Parameter(Mandatory = $true)] + [String] + $remoteconnectionserver, + + [Parameter(Mandatory = $true)] + [ValidatePattern("^.+?[@\\].+?$")] + [String] + $ADUserName, + + [Parameter(Mandatory = $false)] + [SecureString] + $ADpassword, + + [Parameter(Mandatory = $false)] + $HvServer = $null + ) + + + $services = Get-ViewAPIService -hvServer $hvServer + if ($null -eq $services) { + Write-Error "Could not retrieve ViewApi services from connection object" + break + } + + if (!$ADPassword) { + $ADPassword= Read-Host 'Please provide the Active Directory password for user $AdUsername' -AsSecureString + } + + #$unsecurepassword=$ADPassword | ConvertFrom-SecureString + $vcPassword = New-Object VMware.Hv.SecureString + $enc = [system.Text.Encoding]::UTF8 + $vcPassword.Utf8String = $enc.GetBytes(($ADPassword | ConvertFrom-SecureString)) + + $services.PodFederation.PodFederation_join($remoteconnectionserver,$user,$svcpassword) + write-host "This pod has been joined to the podfederation." + + [System.gc]::collect() +} + +function unregister-hvpod { + <# + .Synopsis + Removes a pod from a podfederation + + .DESCRIPTION + Starts the uninitialisation of a Horizon View Pod Federation. It does NOT remove a pod from a federation. + + .PARAMETER Podname + The name of the pod to be removed. + + .PARAMETER Force + This can be used to forcefully remove a pod from the pod federation. This can only be done while connected to one of the other pods in the federation + + .PARAMETER HvServer + Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then + first element from global:DefaultHVServers would be considered in-place of hvServer + + .EXAMPLE + Unregister-hvpod -podname PODNAME + Checks if you are connected to the pod and gracefully unregisters it from the podfedaration + + .EXAMPLE + Unregister-hvpod -podname PODNAME -force + Checks if you are connected to the pod and gracefully unregisters it from the podfedaration + + .NOTES + Author : Wouter Kursten + Author email : wouter@retouw.nl + Version : 1.0 + + ===Tested Against Environment==== + Horizon View Server Version : 7.3.2,7.4 + PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1 + PowerShell Version : 5.0 + #> + + [CmdletBinding( + SupportsShouldProcess = $false, + ConfirmImpact = 'High' + )] + + param( + [Parameter(Mandatory = $true)] + [string] + $PodName, + + [Parameter(Mandatory = $true)] + [switch] + $force=$false, + + [Parameter(Mandatory = $false)] + $HvServer = $null + ) + + + $services = Get-ViewAPIService -hvServer $hvServer + if ($null -eq $services) { + Write-Error "Could not retrieve ViewApi services from connection object" + break + } + $pods=$services.pod.pod_list() + $pod=$pods | where-object {$_.displayname -like "$podname"} + if ($force -eq $false){ + if ($pod.localpod -eq $False){ + Write-Error "You can only gracefully remove a pod when connected to that pod, please connect to a connection server in pod $podname" + break + } + elseif ($pod.localpod -eq $True){ + write-host "Gracefully removing $podname from the federation" + $services.PodFederation.PodFederation_Unjoin() + } + } + + elseif ($force -eq $true){ + if ($pod.localpod -eq $True){ + Write-Error "You can only forcefully remove a pod when connected to a different pod, please connect to a connection server in another pod then $podname" + break + } + elseif ($pod.localpod -eq $false){ + write-host "Forcefully removing $podname from the federation" + $services.PodFederation.PodFederation_eject($pod.id) + } + } + + + + [System.gc]::collect() +} + +function set-hvpodfederation { + <# + .Synopsis + Used to change the name of a Horizon View Pod Federation (Cloud Pod Architecture) + + .DESCRIPTION + Used to change the name of a Horizon View Pod Federation (Cloud Pod Architecture) + + .PARAMETER Name + The new name of the Pod Federation. + + .PARAMETER HvServer + Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then + first element from global:DefaultHVServers would be considered in-place of hvServer + + .EXAMPLE + set-hvpodfederation -name "New Name" + Will update the name of the current podfederation. + + .NOTES + Author : Wouter Kursten + Author email : wouter@retouw.nl + Version : 1.0 + + ===Tested Against Environment==== + Horizon View Server Version : 7.3.2,7.4 + PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1 + PowerShell Version : 5.0 + #> + + [CmdletBinding( + SupportsShouldProcess = $false, + ConfirmImpact = 'High' + )] + + param( + [Parameter(Mandatory = $true)] + [string] + $name, + + [Parameter(Mandatory = $false)] + $HvServer = $null + ) + + + $services = Get-ViewAPIService -hvServer $hvServer + if ($null -eq $services) { + Write-Error "Could not retrieve ViewApi services from connection object" + break + } + $podservice=new-object vmware.hv.podfederationservice + $podservicehelper=$podservice.read($services) + $podservicehelper.getDatahelper().setdisplayname($name) + $podservice.update($services, $podservicehelper) + get-hvpodfederation + + [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, Get-HVHealth, new-hvpodfederation, remove-hvpodfederation, get-hvpodfederation, register-hvpod, unregister-hvpod, set-hvpodfederation From c4c92f7a87104a0ce6288cf0a151cc94fac7ed19 Mon Sep 17 00:00:00 2001 From: Wouter Kursten Date: Thu, 26 Apr 2018 10:27:36 +0200 Subject: [PATCH 4/5] Added Site functions --- .../VMware.Hv.Helper/VMware.HV.Helper.psm1 | 247 +++++++++++++++++- 1 file changed, 246 insertions(+), 1 deletion(-) diff --git a/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 b/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 index 03e2585..b3e2dbd 100644 --- a/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 +++ b/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 @@ -10475,4 +10475,249 @@ function set-hvpodfederation { [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, Get-HVHealth, new-hvpodfederation, remove-hvpodfederation, get-hvpodfederation, register-hvpod, unregister-hvpod, set-hvpodfederation +function get-hvsite { + <# + .Synopsis + Returns information about the sites within a Horizon View Pod Federation (Cloud Pod Architecture) + + .DESCRIPTION + Returns information about the sites within a Horizon View Pod Federation (Cloud Pod Architecture) + + .PARAMETER HvServer + Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then + first element from global:DefaultHVServers would be considered in-place of hvServer + + .EXAMPLE + get-hvsite + Returns information about the sites within a Horizon View Pod Federation. + + .NOTES + Author : Wouter Kursten + Author email : wouter@retouw.nl + Version : 1.0 + + ===Tested Against Environment==== + Horizon View Server Version : 7.3.2,7.4 + PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1 + PowerShell Version : 5.0 + #> + + [CmdletBinding( + SupportsShouldProcess = $false, + ConfirmImpact = 'High' + )] + + param( + + [Parameter(Mandatory = $false)] + $HvServer = $null + ) + + + $services = Get-ViewAPIService -hvServer $hvServer + if ($null -eq $services) { + Write-Error "Could not retrieve ViewApi services from connection object" + break + } + $hvsites=$services1.site.site_list() + return $hvsites + + [System.gc]::collect() +} + +function new-hvsite { + <# + .Synopsis + Creates a new site within a Horizon View Pod Federation (Cloud Pod Architecture) + + .DESCRIPTION + Creates a new site within a Horizon View Pod Federation (Cloud Pod Architecture) + + .PARAMETER Name + Name of the site (required) + + .PARAMETER Description + Description of the site (required) + + .PARAMETER HvServer + Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then + first element from global:DefaultHVServers would be considered in-place of hvServer + + .EXAMPLE + new-hvsite -name "NAME" -description "DESCRIPTION" + Returns information about the sites within a Horizon View Pod Federation. + + .NOTES + Author : Wouter Kursten + Author email : wouter@retouw.nl + Version : 1.0 + + ===Tested Against Environment==== + Horizon View Server Version : 7.3.2,7.4 + PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1 + PowerShell Version : 5.0 + #> + + [CmdletBinding( + SupportsShouldProcess = $false, + ConfirmImpact = 'High' + )] + + param( + [Parameter(Mandatory = $true)] + [string] + $name, + + [Parameter(Mandatory = $true)] + [string] + $description, + + [Parameter(Mandatory = $false)] + $HvServer = $null + ) + + + $services = Get-ViewAPIService -hvServer $hvServer + if ($null -eq $services) { + Write-Error "Could not retrieve ViewApi services from connection object" + break + } + $sitebase=new-object vmware.hv.sitebase + $sitebase.displayname=$name + $sitebase.description=$description + $services.site.site_create($sitebase) + + [System.gc]::collect() +} + +function set-hvsite { + <# + .Synopsis + renames a new site within a Horizon View Pod Federation (Cloud Pod Architecture) + + .DESCRIPTION + renames a new site within a Horizon View Pod Federation (Cloud Pod Architecture) + + .PARAMETER Sitename + Name of the site to be edited + + .PARAMETER Name + New name of the site (required) + + .PARAMETER Description + New description of the site (required) + + .PARAMETER HvServer + Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then + first element from global:DefaultHVServers would be considered in-place of hvServer + + .EXAMPLE + set-hvsite -site "CURRENTSITENAME" -name "NAME" -description "DESCRIPTION" + Returns information about the sites within a Horizon View Pod Federation. + + .NOTES + Author : Wouter Kursten + Author email : wouter@retouw.nl + Version : 1.0 + + ===Tested Against Environment==== + Horizon View Server Version : 7.3.2,7.4 + PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1 + PowerShell Version : 5.0 + #> + + [CmdletBinding( + SupportsShouldProcess = $false, + ConfirmImpact = 'High' + )] + + param( + [Parameter(Mandatory = $true)] + [string] + $sitename, + + [Parameter(Mandatory = $true)] + [string] + $name, + + [Parameter(Mandatory = $true)] + [string] + $description, + + [Parameter(Mandatory = $false)] + $HvServer = $null + ) + + + $services = Get-ViewAPIService -hvServer $hvServer + if ($null -eq $services) { + Write-Error "Could not retrieve ViewApi services from connection object" + break + } + $siteid=$services1.site.site_list() | where-object {$_.base.displayname -like $sitename} + $siteservice=new-object vmware.hv.siteservice + $sitebasehelper=$siteservice.read($services, $siteid.id) + $sitebasehelper.displayname=$name + $sitebasehelper.description=$description + $siteservice.update($services, $sitebasehelper) + + [System.gc]::collect() +} + +function remove-hvsite { + <# + .Synopsis + renames a new site within a Horizon View Pod Federation (Cloud Pod Architecture) + + .DESCRIPTION + renames a new site within a Horizon View Pod Federation (Cloud Pod Architecture) + + .PARAMETER Name + Name of the site (required) + + .PARAMETER HvServer + Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then + first element from global:DefaultHVServers would be considered in-place of hvServer + + .EXAMPLE + set-hvsite -site "CURRENTSITENAME" -name "NAME" -description "DESCRIPTION" + Returns information about the sites within a Horizon View Pod Federation. + + .NOTES + Author : Wouter Kursten + Author email : wouter@retouw.nl + Version : 1.0 + + ===Tested Against Environment==== + Horizon View Server Version : 7.3.2,7.4 + PowerCLI Version : PowerCLI 6.5, PowerCLI 6.5.1 + PowerShell Version : 5.0 + #> + + [CmdletBinding( + SupportsShouldProcess = $false, + ConfirmImpact = 'High' + )] + + param( + [Parameter(Mandatory = $true)] + [string] + $name, + + [Parameter(Mandatory = $false)] + $HvServer = $null + ) + + + $services = Get-ViewAPIService -hvServer $hvServer + if ($null -eq $services) { + Write-Error "Could not retrieve ViewApi services from connection object" + break + } + $siteid=$services1.site.site_list() | where-object {$_.base.displayname -like $sitename} + $services.site.site_delete($siteid.id) + + [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, Get-HVHealth, new-hvpodfederation, remove-hvpodfederation, get-hvpodfederation, register-hvpod, unregister-hvpod, set-hvpodfederation,get-hvsite,new-hvsite,set-hvsite,remove-hvsite From fc02a60eaf1058aac87fe94061801c96efae5730 Mon Sep 17 00:00:00 2001 From: Wouter Kursten Date: Sat, 28 Apr 2018 17:04:32 +0200 Subject: [PATCH 5/5] fixes for podfederations and sites --- .../VMware.Hv.Helper/VMware.HV.Helper.psm1 | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 b/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 index b3e2dbd..4528a40 100644 --- a/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 +++ b/Modules/VMware.Hv.Helper/VMware.HV.Helper.psm1 @@ -10249,7 +10249,7 @@ function register-hvpod { Registers a pod in a Horizon View Pod Federation. You have to be connected to the pod you are joining to the federation. .PARAMETER ADUserName - User principal name of user + User principal name of user this is required to be in the domain\username format .PARAMETER remoteconnectionserver Servername of a connectionserver that already belongs to the PodFederation @@ -10296,8 +10296,8 @@ function register-hvpod { [String] $ADUserName, - [Parameter(Mandatory = $false)] - [SecureString] + [Parameter(Mandatory = $true)] + [securestring] $ADpassword, [Parameter(Mandatory = $false)] @@ -10311,16 +10311,18 @@ function register-hvpod { break } - if (!$ADPassword) { - $ADPassword= Read-Host 'Please provide the Active Directory password for user $AdUsername' -AsSecureString - } + #if ($ADPassword -eq $null) { + #$ADPassword= Read-Host 'Please provide the Active Directory password for user $AdUsername' -AsSecureString + #} - #$unsecurepassword=$ADPassword | ConvertFrom-SecureString + $temppw = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($ADPassword) + $PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($temppw) + $plainpassword $vcPassword = New-Object VMware.Hv.SecureString $enc = [system.Text.Encoding]::UTF8 - $vcPassword.Utf8String = $enc.GetBytes(($ADPassword | ConvertFrom-SecureString)) + $vcPassword.Utf8String = $enc.GetBytes($PlainPassword) - $services.PodFederation.PodFederation_join($remoteconnectionserver,$user,$svcpassword) + $services.PodFederation.PodFederation_join($remoteconnectionserver,$adusername,$vcpassword) write-host "This pod has been joined to the podfederation." [System.gc]::collect() @@ -10373,9 +10375,9 @@ function unregister-hvpod { [string] $PodName, - [Parameter(Mandatory = $true)] - [switch] - $force=$false, + [Parameter(Mandatory = $false)] + [bool] + $force, [Parameter(Mandatory = $false)] $HvServer = $null @@ -10657,8 +10659,8 @@ function set-hvsite { $siteid=$services1.site.site_list() | where-object {$_.base.displayname -like $sitename} $siteservice=new-object vmware.hv.siteservice $sitebasehelper=$siteservice.read($services, $siteid.id) - $sitebasehelper.displayname=$name - $sitebasehelper.description=$description + $sitebasehelper.getbasehelper().setdisplayname($name) + $sitebasehelper.getbasehelper().setdescription($description) $siteservice.update($services, $sitebasehelper) [System.gc]::collect() @@ -10672,8 +10674,8 @@ function remove-hvsite { .DESCRIPTION renames a new site within a Horizon View Pod Federation (Cloud Pod Architecture) - .PARAMETER Name - Name of the site (required) + .PARAMETER Name + Name of the site (required) .PARAMETER HvServer Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then @@ -10714,7 +10716,7 @@ function remove-hvsite { Write-Error "Could not retrieve ViewApi services from connection object" break } - $siteid=$services1.site.site_list() | where-object {$_.base.displayname -like $sitename} + $siteid=$services1.site.site_list() | where-object {$_.base.displayname -like $name} $services.site.site_delete($siteid.id) [System.gc]::collect()