VMware Horizon Community
OldrichSrubar
Contributor
Contributor

Assign user in Dedicated pool with Powershell

Hi guys,

I need to solve situation where user assigment in Horizon dedicated pool must be automatic. Well, it's not a problem itself, I have one idea in my head where I will use AD groups and task scheduler with powershell script inside. But problem is that I am not able to find any usable cmdlet for assigment operation.

I was searching VMware Docs and there is something about Update-UserOwnership cmdlet that could solve my problem. However, even I imported all modules from PowerCLI to PowerShell I cannot find it there, this cmdlet doesn't exist.

Reference here: Updating Virtual Machine Ownership

I also imported VMware.v.Helper module but I didn't find anything useful, too.

Is there some cmdlet or short script which can help me to solve this fundamental Horizon operation in Powershell?

Thank you.

12 Replies
andiwe79
Enthusiast
Enthusiast

This cmdlet is unfortunately only available within the PowerCLI on the Connection Servers itself.
Start the PowerCLI there with the Start Menu entry.

Would love to do this remote too.

Best regards

Andreas

0 Kudos
OldrichSrubar
Contributor
Contributor

No way, I tried it from PowerCLI and View PowerCLI as well but without success.

pastedImage_0.png

0 Kudos
andiwe79
Enthusiast
Enthusiast

Your Screenshot is from Standard PowerCLI 6.5

What das View PowerCLI on the Connection Servers say?

0 Kudos
OldrichSrubar
Contributor
Contributor

Firstly it fails to load in the snapin and it cannot find cmdlet as well.

pastedImage_0.png

0 Kudos
andiwe79
Enthusiast
Enthusiast

It should look like this:

2018-02-28 15_07_12-mRemoteNG - confCons.xml - RDS02.png

0 Kudos
andiwe79
Enthusiast
Enthusiast

Maybe insufficient user rights?

0 Kudos
OldrichSrubar
Contributor
Contributor

Ahh lol, really run as administrator helped to run it in View PowerCLI but anyway I am still missing possibility to run it remotely from some management server, not especially only on Connectivity servers 😞

0 Kudos
sjesse
Leadership
Leadership

What version of horizon and powercli are you using. Looking at your screenshots your trying to load snapins, in the latest versions of powercli those don't work, you need to use modules.

Try adding this at the top instead of add snapin part if you have the latest

Get-Module -Name VMware* -ListAvailable | Import-Module

0 Kudos
andiwe79
Enthusiast
Enthusiast

PowerCLI from PowerShell Gallery does not have this functionality (at least i did not find it :smileycry:).
But you are right, upgrading to latest Version should be mandatory.

Best regards

Andreas

0 Kudos
sjesse
Leadership
Leadership

Powercli from the powercli gallery should have it.

PowerShell Gallery | VMware.VimAutomation.HorizonView 7.1.0.5307191

from my understanding everything powercli related now should be installed from the powershell gallery. The problem is the new ones vs the ones from 6.2.1 are alot harder to use.  I'd look at

https://blogs.vmware.com/euc/2017/01/vmware-horizon-7-powercli-6-5.html

for information on this.

0 Kudos
andiwe79
Enthusiast
Enthusiast

Yes i agree they are more difficult.
That's why using the local View PowerCLI was comfortable for when i tried this last year.

This Guy has managed this with a new command:
https://www.retouw.nl/powercli/adding-manual-desktops-in-horizon-view-and-assigning-them-using-power...

Great!

Magneet
Hot Shot
Hot Shot

that guy is me, what is needed it the vmware.hv.helper module from the powercli example scripts at GitHub - vmware/PowerCLI-Example-Scripts

What you can now do is this:

Set-HVMachine -HvServer $vcs -MachineName machine.fqdn -User "domain\user"

or

Get-HVMachine -MachineName machine.fqdn | Set-HVMachine -User user@domain

thanx to another contributor of the module Smiley Happy