Managing Linux with PowerShell DSC

Managing Linux with PowerShell DSC

Managing Linux with PowerShell DSC

Managing Linux with PowerShell DSC – After some hard struggle, we know that success will finally come through. This is what happened when me “A pure windows guy” started testing out DSC for Linux.

In this blogpost i would share my experiences on my tests with PowerShell for DSC with Linux so that it can help out folks trying the similar stuff.

Ok so lets get into what is exactly PSDSC for Linux, its a set of resources provided by Microsoft which allows you to manage your Linux VM’s using PowerShell DSC, the similar way we author DSC configuration we can create configs for managing Linux Infrastructure too.

So let me get right into the details.

To start with i had a Test VM built with CentOS 6.6 OS as you can see in my vCenter console below.



Using a set of OSCustomization specs available i configured an IP, Hostname for this vm at the time i deployed it, and i used as always PowerCLI 🙂 for this deployment too.

Next i enabled a ssh session to the vm via Putty and ran the below set of commands to install the necessary packages which consist of perl modules, OMI server and the PSDSC Package.

Next we need to start the OMI server using the below set of commands.

Also note rather than implementing the above steps of downloading and installing the packages you can also download the .rpm files for the same from PowerShell Desired State Configuration for Linux

Here’s a sample view of the commands to install the rpm files.

Note :- Rather than doing this manually over the linux putty session, you can save the above set of commands to a file and use the Invoke-VMScript cmdlet to call them.

The above link would allow you to download an MSI package which when installed would create the necessary folder structures and place the .rpm files and the PSDSC modules.

Here’s a view of the folder structure.



For one of my another testing scenario with only the rpm packages i used the below file



Also here the view for the modules itself.


Once we have all the files , next i used WinSCP to copy over the files to the /temp location of my Linux VM.


Here’s again when PowerCLI would come to your rescue, you can use the Copy-VMGuestFile cmdlet to copy over these files to the linux VM

Once the above steps are completed, i went ahead and installed the modules. using the below set of commands on my linux vm.

Here’s a screencapture from my linux box


Once all the steps are done, lets start building our configuration on the windows vm to test this configuration 🙂

Note that you need to install all the required nx modules on your server/desktop too.

You can do this by heading over to PowerShellGallery to download and install the resource using the

Install-Module cmdlet.

Here’s a view of all nx DSC resources i have on my laptop.

Linux DSC PowerShell

Now we are all set, lets build the configuration.

Heres the script block which consists of my sample configuration also the DSC Push cmdlet “Start-DSCConfiguration” to push the mof files across my linux VM’s.

Once you run the above configuration, you would see the configurations enacted on the Linux VM’s.


Next let me login to the VM and see if we really did change the hostname :), ohh yess! we did


I hope you enjoyed this blogpost on to manage “Linux DSC PowerShell” and found it useful, and i also hope it helps you out with your PSDSC ramblings.

Please follow and like us:

Share this post

One thought on “Managing Linux with PowerShell DSC

Post Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.