Tuesday, June 2, 2015

Load PowerCLI into PoweShell ISE

function Load-PowerCLI
{
    Add-PSSnapin VMware.VimAutomation.Core
    Add-PSSnapin VMware.VimAutomation.Vds
    . "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"


Once execute you may connect to your vSphere using the following command:


Connect-VIServer -Server "Server"

 Replace the "Server" with your vSphere address / hostname,

You will receive a prompt for user name and password -



For some reason, since we are using the ISE interface we need to switch to the new PS-Drive created for us, in order to run PowerCLI commands.

cd vi:\

you may check your connection to the vSphere using a PowerCLI command, example -

get-vm
 
Enjoy!