VMware Cloud Community
ibuamod
Contributor
Contributor

How can I run a powercli script from CMD ( in Jenkins)

How can I run a powercli script from CMD ( in Jenkins)
0 Kudos
4 Replies
ibuamod
Contributor
Contributor

I use the command 

#TO OPEN POWERCLI FROM CMD
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noe -c ". \"C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1\" $true"
 
0 Kudos
LucD
Leadership
Leadership

Since you are still using that init script, it looks like you are running an older PowerCLI version.

Since 6.5.1 there is no need anymore to that, the PowerShell module autoload feature will take care of loading the required modules.

When you are at 6.5.1 or later, you can look at Automating with Jenkins and PowerShell on Windows - Part 1 on how to run a PowerShell script as Jenkins job.

Using PowerCLI in such a script requires no extra effort (since you don't need that init script anymore).


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ibuamod
Contributor
Contributor

So is it better to upgrade powerCli to the latest? 
0 Kudos
LucD
Leadership
Leadership

Depends on the vSphere version you are running.

You can check in the compatibility matrix.

But yes, from 6.5.1 onwards, you don't need that init script anymore.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos