Book Image

Learning PowerCLI for VMware VSphere

By : Robert van den Nieuwendijk
Book Image

Learning PowerCLI for VMware VSphere

By: Robert van den Nieuwendijk

Overview of this book

Table of Contents (17 chapters)
Learning PowerCLI
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using the vSphere CLI commands from PowerCLI


If you installed both VMware vSphere PowerCLI and VMware vSphere CLI on the same computer, you can use the vSphere CLI Perl commands from PowerCLI. Using the VMware vSphere CLI commands, you can perform tasks that you cannot do with PowerCLI natively, such as configuring IPsec on your ESXi host with the vicfg-ipsec command.

The Add-vCLIfunction function creates a function string for each Perl script in the vSphere CLI bin directory. The function strings are executed using the PowerShell Invoke-Expression cmdlet. This creates a PowerShell function for each vSphere CLI Perl script.

function Add-vCLIfunction {
  <#
  .SYNOPSIS
    Adds the VMware vSphere Command-Line Interface Perl scripts
    as PowerCLI functions.
 
  .DESCRIPTION
    Adds all the VMware vSphere Command-Line Interface Perl
    scripts as PowerCLI functions.
    VMware vSphere Command-Line Interface has to be installed on
    the system where you run this function.
    You can...