VMware Cloud Community
thatbrentguy
Contributor
Contributor

vSphere automation - PowerCLI vs Python/SDK

I am advising about starting to build automation scripts for vSphere/vCenter to inspect and manage configurations between a number of installations.  As I have a completely green field to work with, I want to start out with some reasonable decisions about what tools to use.

My investigation has shown me that the vSphere API is robust and complete.  I can hit its REST endpoints with whatever tool I like and do all the things. Yayy!

As my preferred administrative scripting tool is Python on Linux, I looked at the Python SDK and some of its examples.

Since there are a lot of examples of PowerShell / PowerCLI, I looked at that too.  It seems to me to be more thoroughly abstracted into immediately useful functionality than the Python SDK which seems to require deeper burrowing, iteration and manipulation to do things that PowerCLI has packaged up into cmdlets.

I have successfully tested PowerCLI running on PowerShell on Linux, and I'm aware that there are limitations re WMI and drive mapping that might make me have to use Windows (apparently less problematic with 7.x+ but I'm looking at 6.7 for now).

PowerCLI seems to have a bigger presence within VMware docs and community than Python/other so I suspect it might have better momentum and staying power.

So my educated guess so far is that I should advise to proceed with PowerShell/PowerCLI, on Linux (or Windows if necessary for full functionality).

My request is that you educate me as to why I am right or wrong in my assessment, or how you would approach it if it were yours to do.

3 Replies
scott28tt
VMware Employee
VMware Employee

Moderator: Thread moved to the PowerCLI area - you'll get more specialist guidance here.


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
LucD
Leadership
Leadership

I'm not going to make a comparison between PowerShell and Python.

That might turn out in a religious war :smileygrin:

But, as you already noticed, PowerShell (and the PowerCLI modules), definitely are more present nowadays.

The main reason, imho, PowerShell and PowerCLI coding is more intuitive and 'natural', and hence easy to understand for a beginner.

The basic verb-noun construct for cmdlets and the Get-Help definitely make it a language that is easy to start with.

Concerning the vSphere framework, I can't really judge for the Python SDK, but PowerCLI came, from day 1, with the Get-View cmdlet and the ExtensionData property.

The SOAP calls and properties that are not directly covered by PowerCLI cmdlets are easily accessible.

Although this requires diving into the API Reference.

Concerning the REST API, the situation is a bit different.

Since a REST call is essentially a web request, you can use PowerShell's Invoke-WebRequest.
The way that the PowerCLI powers-that-be implemented some of the REST API collections, is, and again imho, not the 'PowerShell' way to do it.

You will notice that most REST API collections are implemented with what I call a three-cmdlet module.

A Connect, a Disconnect and a Services cmdlet that allows you to list the services in that REST API collection.
This, for me, is a rush job that allowed the PowerCLI-that-be to tick off 'another module implemented'.

To conclude, one of great things about PowerCLI, is the lively community around it.
You will find many blog posts around doing things with PowerShell/PowerCLI.
And there is of course this community with a wealth of samples and answered questions.

But I might be slightly biased Smiley Wink


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

thatbrentguy
Contributor
Contributor

Thanks for the insight, LucD ; I've followed your blog via your RSS feed too.

0 Kudos