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
1 2 3 |
$session = New-PSSession -ComputerName CONNECTION-SERVER.DOMAIN.LOCAL Invoke-Command -ScriptBlock {Add-PSSnapin VMware.View.Broker} -Session $session |
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
1 |
Export-PSSession -Session $session -Module VMware.View.Broker -OutputModule Exported.VMware.View |
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
1 2 3 |
Remove-PSSession -Session $session Import-Module Exported.VMware.View -Force |
If you run a View cmdlet, such as Get-DesktopVM or Get-Pool you get the following 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
Now reload the module and retry a view cmdlet
1 2 3 |
Import-Module Exported.VMware.View -Force Get-DesktopVM |
And there you have it, running a View cmdlet without setting up a remote session first.
Permalink //
It’s work. Thank for post.