PowerCLITools Community Module: Now on GitHub
Over the last few years I have built up a number of functions to use alongside the out of the box functionality in PowerCLI. I’ve posted some of the content before on this blog, but have at last got round to publishing all of the content that I am able to share, in a module available on GitHub - I’ve named it the PowerCLITools Community Module in the hope that some others might want to contribute content to it or improve what I have already put together.
This took a fair amount of effort since it is not possible for me to share everything that I have as part of my locally stored version of this toolkit. Some of it was developed by others I was working on projects with (and are not as necessarily so keen to share certain parts of their work) and some can’t be shared for commercial reasons. However, I found some time recently to split out everything that could be shared into a new module and also updated some of the code - typically to add some nice features in PowerShell v3 and later which weren’t available when a lot of the code was developed during PowerShell v2 days.
Since the content has been developed over a few years, consistency and standardisation of approach may not be 100% there. A quick look back over them showed some looking a bit dated - I have spent a bit of time tidying them up, but part of the reason for sharing them was to take feedback and some prompting on where they could be improved. If I left them until I thought they were just right I’d probably never end up publishing them. So your feedback is the impetus I need to go and improve them :-)
A lot of the functions are there to fill in gaps in cmdlet coverage with PowerCLI and there are a few which I made more for convenience where I have bundled together a few existing cmdlets into one function. These don’t particularly add a lot of value, but maybe demonstrate how you can tighten up your scripts a bit
Pre-Requisites
Ensure that VMware PowerCLI is installed. Functions have been tested against v5.8 R1.
Installation
- Download all files comprising the PowerCLITools module. Ensure the files are unblocked and unzip them. 2) Create a folder for the module in your module folder path, e.g. C:\Users\username\Documents\WindowsPowerShell\Modules\PowerCLITools 3) Place the module files in the above folder
So it should look something like this:
The below command will make all of the functions in the module available
Import-Module PowerCLITools
To see a list of available functions:
Get-Command -Module PowerCLITools
Add-vCenterLicense Get-ClusterAverageCpuMemory Get-CurrentVIServer Get-SnapshotCreator Get-vCenterLicense Get-VMCreationDate Get-VMDiskData Get-VMHostAlarm Get-VMHostDumpCollector Get-VMHostiSCSIBinding Get-VMHostLicense Get-VMHostNetworkAdapterCDP Get-VMHostSyslogConfig Get-VMIPAddressFromNetwork Get-VMSCSIID Install-vSphereClient Install-vSpherePowerCLI New-vCenterPermission New-vCenterRole New-VMFromSnapshot Remove-vCenterLicense Set-VMHostDumpCollector Set-VMHostiSCSIBinding Set-VMHostLicense Set-VMHostSyslogConfig Set-VMHostToCurrentDateandTime Test-VIServerConnection Update-ESXiSSL Update-VMNotesWithOwner Update-VMScsiDeviceOrder
Nested Modules
You will note that each function is itself a nested module of the PowerCLITools module. In this blog post I describe why I make my modules like this.
VI Properties
If you take a look inside the PowerCLITools.Initialise.ps1 file you’ll notice a number of VI Properties. Some of these are required by some of the functions in the module and some are just there for my convenience and make using my PowerCLI session simpler. You can add and remove VI Properties as to your own personal preference, but watch out that some are actually needed. You can find out more about VI Properties here.
Feedback
I really hope people find these functions useful. I have a number of ideas on where some can be improved, but please provide your own feedback as it’ll be the nudge I need to actually go and make the changes :-)