Powershell Implicit Remoting with Horizon View PowerCLI Cmdlets

With the release of PowerCLI 6.5 came a updated way of interacting with your Horizon View Infrastructure; the release of a Horizon 7  module! The module provides access to all of the public api, and it can be installed and run anywhere, no longer are you limited to running it from the View Connection Server.

However, if you have not yet moved up to Horizon View 7 and are looking to run the View cmdlets locally from your workstation, give Powershell Implicit Remoting a whirl.

The process involves starting a remote session on a connection server, exporting the View 5 / 6 cmdlets we’re interested in to a local module and then loading that module. When a cmdlet is called, Powershell takes care of setting up a session in the background and you can run the cmdlets from your own workstation!

So, create a remote session and load in the relevant snapin

Now we’ll create a local module called Exported.VMware.View which contains the exported cmdlets from the module VMware.View.Broker that resides on the remote server

Now we’ll remove the session we have open and reload the module. Removing the existing session gives us reassurance we’re not just pulling back results from the session we just created

If you run a View cmdlet, such as Get-DesktopVM or Get-Pool you get the following error:

Powershell Implicit Remoting error

This the same error if you were to log on to the Connection Server, start Powershell and try to run a View cmdlet without loading the Snapin. So we need to tweak something to ensure that the snapin is loaded when the exported cmdlets are run.

A little poking around in the module psm1 file (look for it in your powershell module path by typing $PSModulePath or (Get-Module -ListAvailable Exported.VMware.View).path) and I found that the following edit needs to be made and then our cmdlets will run as expected – note the line numbers

ModuleEdit

Now reload the module and retry a view cmdlet

And there you have it, running a View cmdlet without setting up a remote session first.

1 Comment

Leave a Reply to Sergey Cancel reply

Your email address will not be published. Required fields are marked *