Automate PowerCLI Install across your Windows Environment using PowerShell DSC

Automate PowerCLI Install across your Windows Environment using PowerShell DSC

Automate PowerCLI Install using PowerShell DSC

I have some cool stuff to share today, I was exploring the various internal DSC resources in the past week, and something which caught my eye was the “Package” DSC resource module.

Automate PowerCLI

What this module really allows you to do is to automate the configuration deployment of packages across your organization. During my DSC testing i was trying to install various packages on servers using this resource module.

Then finally it struck me why cant i Automate PowerCLI binary install itself.

One great thing i was able to achieve was to Automate PowerCLI binaries install across my windows test environment, it feels really awesome when you see that “It Just Works!”

To learn more about DSC, head over to the Windows PowerShell Team Blog, Blog 2.

You also need to have WMF 4.0 / WMF 5.0 installed on your servers for DSC to work.

Now lets get into how i achieved it.

Note :- In my test setup i had a set of 4 vm’s running on vSphere 6.0, all the servers are Windows 2012 R2 and have PowerShell v4 in them.

automate powercli

Now let’s explore the list of readily available resources which come by default.

To get them you will need to run a Get-DSCResource in the powershell console.

automate powercli

As you can see we have the package and the file resource, we would be using both these resources for our DSC configuration.

Also you will need to configure winrm on the test machines, you can do this by executing the below command on the powershell console and also remember to accept the defaults.

Next to start off with our script, we will need to copy over the powercli binary VMware-PowerCLI-6.0.0-3205540.exe to a share location, in my test setup i copied it over to c:\ drive of the push server ( from where the configurations are being pushed)

automate powercli


This is the location which would be used by the File resource to copy over the binary to the servers if they are non existent.

Next let me walk through the DSC configuration to install the package, i have updated comments for each and every step.

Next once we have the configuration ready, lets create the MOF files which would be pushed across the three servers.

We can get them by invoking the configuration we created.

automate powercli

Next lets use the Start-DscConfiguration cmdlet to apply the configuration to nodes. This would be the Push mode of applying the configuration, we can also go for a Pull mode if we have a larger environment.

Once we invoke this command, the configurations will start getting applied on the destination servers,

automate powercli

automate powercli

You can also run the Get-DSCConfiguration on each individual server to get the status of configurations applied on the server

automate powercli

The end result is what we all have been waiting for, and its fantastic :), you would see powercli installed on all the three servers.

Here’s a view from Add Remove Programs from one of the server where the configuration got applied.

automate powercli

Now moving own, let’s dig deep into more advanced DSC, my next blog post talks about a custom DSC resource built to manage snapshots using PwerCLI

I hope you enjoyed this blog post on Automate PowerCLI install using DSC with VMware and found the information useful.

Do Check out my other posts on DSC and PowerCLI

Please follow and like us:

Share this post

2 thoughts on “Automate PowerCLI Install across your Windows Environment using PowerShell DSC

Post Comment