PowerCLI

 View Only
  • 1.  Just want to start PowerCLI from Powershell

    Posted Dec 05, 2014 01:15 AM

    Hi, I have used Windows PowerShell for some time but am  new to VMware PowerCLI. I just installed PowerCLI version 5.5.  I know how to launch the shell in the VMware program group, but I don't want to administer from there. I want to administer from Window PowerShell. How does one execute the PowerCLI cmdlets from PowerShell? I have searched and can find no information on this.

    Thanks



  • 2.  RE: Just want to start PowerCLI from Powershell

    Posted Dec 05, 2014 05:55 AM

    Depends what you want.

    If you just want the PowerCLI cmdlet, you can do

    Add-PSSnapin -Name VMware*

    Now you will able to execute all PowerCLI cmdlets (starting with a Connect-VIServer).

    The PowerCLI Start menu entry also runs a script, called %programfiles%\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1

    This defines some functions and the PowerCLI prompt.

    If you want to have these as well, you can execute the script from PS prompt.



  • 3.  RE: Just want to start PowerCLI from Powershell

    Posted Dec 05, 2014 03:17 PM

    Thanks for your answer, I knew about adding this snap-in. The problem was that the snap-in didn't exist because it doesn't get installed when you install PowerCLI,  You actually have to go out and find the snap-in, download it, extract it, then MANUALLY copy it to the PowerShell modules directory.I  found the snap-in at the VMware labs site, which also had those instructions. Seems like there isn't adequate documentation included with PowerCLI itself.

    So after taking those additional steps, I was able to run the command to add the snap-in, and now am able to run the cmdlets from PowerShell.



  • 4.  RE: Just want to start PowerCLI from Powershell
    Best Answer

    Posted Dec 05, 2014 03:45 PM

    So here is the complete answer:

    Go to this site :

    https://labs.vmware.com/flings/powercli-extensions

    (For some reason, the snapin VMware.VimAutomation.Extensions is not included in the PowerCLI install package itself)

    Follow these instructions:

    1. Download and Install PowerCLI 5.5 R1 from this site or the VMware downloads page.
    2. Download the PowerCLI Extensions module from the download button on the site indicated above
    3. To install the PowerShell module (snapin, extension) - extract the downloaded ZIP file to your modules directory, for example (C:\Users\Documents\WindowsPowerShell\Modules) In my case it was C:\Windows\System32\WindowsPowerShell\v1.0\Modules.  Alternately, you may also  extract it to another location and copy the VMware.VimAutomation.Extensions folder to the modules directory.
    4. Verify that in the above modules folder there is a sub-folder called VMware.VimAutomation.Extensions.

    Once the module is extracted or copied to the modules directory, then open Powershell and run the following command:

    Add-PSSnapin VMware.VimAutomation.Core

    Now you should be able to run the VMware PowerCLI cmdlets.