Introduction to View PowerCLI
Windows PowerShell is a command-line and scripting environment that is designed for Microsoft Windows. PowerShell uses the .NET object model and provides administrators with management and automation capabilities. As with any other console environment, you work with PowerShell by running commands, which are called cmdlets in PowerShell.
The command-line syntax for the View PowerCLI cmdlets is the same as generic PowerShell syntax. See the Microsoft documentation for more information about using PowerShell.
VMware View 4.5 includes 45 View PowerCLI cmdlets. You can use these cmdlets in conjunction with the vSphere PowerCLI cmdlets, which provide an administrative interface to the VMware vSphere product. If you have installed vSphere PowerCLI on a Connection Server instance, these cmdlets are loaded automatically when you launch View PowerCLI.
You can reference virtual machines and vCenters by ID in View PowerCLI, but you cannot pass such entries as objects. You must provide a full path to other vSphere objects such as resource pools and folders. You can use the View PowerCLI cmdlets to examine the configuration of vCenter Servers within VMware View.
The View PowerCLI cmdlets are located in the PowershellServiceCmdlets.dll file in the directory C:\Program Files\VMware\VMware View\Server\bin. This file constitutes the VMware.View.Broker snapin. The script configuration file for the View PowerCLI cmdlets is named InitViewCmdlets.ps1, and this file is located in the Extras folder in the View installation directory. You can edit and extend the script to define cmdlet aliases, to configure the environment, or to set startup actions.
Start the PowerShell Console with View PowerCLI Loaded
You can run the View PowerCLI cmdlets directly on a View Connections Server host that has the following software installed.
To use the View PowerCLI cmdlets to change the configuration of View, you must be logged into a View Connection Server instance as a user in a role with sufficient privileges, such as the Administrators role. If your role is a read-only role, you cannot update configuration data. For more information, see the VMware View Administration document.
To start the PowerShell console with View PowerCLI loaded
Select Start > All Programs > VMware > View PowerCLI.
If you see an error message stating that the script configuration file cannot be loaded because the execution of scripts is disabled, type the following PowerShell command and restart the PowerShell console.
Set-ExecutionPolicy Unrestricted
Displaying Help for a View PowerCLI cmdlet
To list all View PowerCLI cmdlets, type this command in the PowerShell console.
Get-Command -PSSnapin VMware.View.Broker | more
You can get help for a specific cmdlet by using the Get-Help cmdlet in the PowerShell console. For example, to get help on the Add-ViewVC cmdlet.
Get-Help Add-ViewVC | more
For more detailed information, add the -full parameter.
Get-Help Add-ViewVC -full | more
Alternatively, you can use the help alias for Get-Help.
help Add-ViewVC -full | more
Error Handling
View PowerCLI cmdlets handle all errors as non-terminating errors that halt the execution of a cmdlet but do not terminate a pipeline. You can examine the $error automatic variable to determine the nature of an error. You can set the standard PowerShell $ErrorActionPreference and $errorView automatic variables to control how PowerShell handles non-terminating errors and how it displays them in the shell.
Error When Piping and Specifying Objects at the Same Time
If you attempt to pipe an object into a cmdlet and specify an object of the same type to that cmdlet, the cmdlet fails with the following error.
The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
For example, the following cmdlet usage would produce this error.
Get-Pool -pool_id Pool1 | Update-ManualPool -pool_id Pool2 -displayName “Manual Pool 2”
Escaping Characters in vCenter Path Names
If you specify a path to a vCenter folder that includes certain special characters in the name of an entity, you must escape these characters. Escape Sequences for Special Characters shows the escape sequences for special characters.
Do not escape the slashes in the path name itself. For example, you would represent the path to the folder /datacenter_01/vm/img%-12 as /datacenter_01/vm/img%25-12.
Cmdlet Parameters Requiring Escape Sequences lists the cmdlets and parameters that require you to use escape sequences in entity names.