vSphereDSC – VmwDatacenter

A new DSC resource in the vSphereDSC module, the VmwDatacenter resource. This is a rather smallish resource, ideal for a Monday 🙂



A Datacenter can only be created in a limited number of locations in a vSphere tree. You can create them in the RootFolder, or in a Yellow folder, but you can not “nest” Datacenters. The new vSphereDSC module release contains some sample Configurations for creating and removing Datacenters.

If you look in the source files of the vSphereDSC  module, you’ll notice I followed the same layout for the Datacenter class,  I already described in vSphereDSC – vmwFolder.


The code where I need to use PowerCLI to interact with the vSphere environment is again located in the vSphereDSCHelper.ps1 file.

One noteworthy point in the code is where we need to test if the Datacenter is created in an acceptable location, the RootFolder or a Yellow folder that doesn’t have a Datacenter in its path. Datacenters can not be nested.


Not the most elegant piece of code, but it does seem to do the trick.

The new version of the vSphereDSC module is available on Github and in the PSGallery.


And please, send me some feedback


Leave a Reply

Your email address will not be published.


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