Hello,
Looking for some instructions on the use of PowerShell and Horizon 7.6. I have tried following instructions at VMware and elsewhere but it only leads to errors. None of the scripts run. Here is what I am trying to do or have done:
- My workstation is Windows 10
As admin, launched PowerShell and executed the following commands:
- Install-Module -Name VMware.PowerCLI -RequiredVersion 10.1.1.8827524
- Install-Module -Name Vmware.PowerCLI
Now I want to simply query the Horizon environment for Pool info, VM info, etc.
Should I be doing this ON the Connection server rather than on my Windows 10 Desktop?
Any help would be greatly appreciated.
I think I figured it out...
Load the module and queried the VM's like this:
Import-Module VMware.VimAutomation.HorizonView
Import-Module VMware.VimAutomation.cis.Core
Get-Module -ListAvailable 'VMware.Hv.Helper' | Import-Module
Get-Module -ListAvailable VMware* | Import-Module
$CS = Connect-HVServer -Server "YourServerName"
Get-HVMachineSummary | Out-GridView
Get-HVMachineSummary -State AGENT_UNREACHABLE | Out-GridView
Disconnect-HVServer -Server "YourServerName" -Confirm:$false
Seemed to work. I'm just winging it here.
Next step is to run the following.
You can check the following on github. (Lots of examples scripts)
Hi aWanderer,
You can run the scripts from your workstation where you installed the powershell module.
After installing the module, you need to import the desired modules before you can use them. Then you use the connect command to connect to your connection server and retrieve the info you need.
I've created a blog post about this recently, you can check it out here: https://itpro.peene.be/vmware-horizon-powerschell-scripting-viewapi/
I use it for writing monitoring scripts for PRTG, but you can use the information on my blog for any other scripting needs.
Hope this helps you.
Regards.
Thank you very much for the help all.
In the blog, it says
"Import-Module VMware.VimAutomation.Core"
It errors but I do see on my system VMware.VimAutomation.cis.Core so I tried Import-Module VMware.VimAutomation.cis.Core and it worked.
Is this the correct import?
As it is, I now have the following and it seems to load fine:
Import-Module VMware.VimAutomation.cis.Core
Import-Module VMware.VimAutomation.HorizonView
Get-Module -ListAvailable 'VMware.Hv.Helper' | Import-Module
The Set-PowerCLIConfiguration command throws an error:
Set-PowerCLIConfiguration -Scope Allusers -ParticipateInCEIP $false
Set-PowerCLIConfiguration : The term 'Set-PowerCLIConfiguration' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Set-PowerCLIConfiguration -Scope Allusers -ParticipateInCEIP $false
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-PowerCLIConfiguration:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
When all is done, I want to be able to do something like this:
Get-PoolEntitlement
When I try to connect to the Connection server, I receive this error:
Connect-HVServer : Could not establish trust relationship for the SSL/TLS secure channel with authority
I am using this command to connect:
Connect-HVServer -Server "theServerName"
Oops... using the FQDN worked
Hi aWanderer
The set-PowerCLICOnfiguration is only needed to disable the warning message about data sharing with VMWare when you execute certain powerCLI commands. No need to worry about it.
What's the error message you get when you import the vmware.vimautomation.core module? Did you install both modules?
Install-Module -Name VMware.VimAutomation.Core
Install-Module -Name VMware.VimAutomation.HorizonView
As far as I know there's no get-poolentitlement command available. You'll have to search around to see how to get the entitlements using PowerCLI (Google can help here )
Regards.
Try this:
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
Just returns
Set-PowerCLIConfiguration : The term 'Set-PowerCLIConfiguration' is not recognized
That's ok. We can forget about that. I'm trying to figure out how to get a list of VM's, Pools, etc. Trying to work through learning how to query things. I can't find any examples that work for me.
I am connected though. So far, I have this
#Install-Module -Name VMware.VimAutomation.Core
#Install-Module -Name VMware.VimAutomation.HorizonView
Import-Module VMware.VimAutomation.cis.Core
Import-Module VMware.VimAutomation.HorizonView
Get-Module -ListAvailable 'VMware.Hv.Helper' | Import-Module
$CS = Connect-HVServer -Server "ServerName"
$Services1 = $Global:DefaultHVServers.ExtensionData
I think I figured it out...
Load the module and queried the VM's like this:
Import-Module VMware.VimAutomation.HorizonView
Import-Module VMware.VimAutomation.cis.Core
Get-Module -ListAvailable 'VMware.Hv.Helper' | Import-Module
Get-Module -ListAvailable VMware* | Import-Module
$CS = Connect-HVServer -Server "YourServerName"
Get-HVMachineSummary | Out-GridView
Get-HVMachineSummary -State AGENT_UNREACHABLE | Out-GridView
Disconnect-HVServer -Server "YourServerName" -Confirm:$false
Seemed to work. I'm just winging it here.
Thanks all for the help. Much appreciated.