<commit_before>---
title:  VMware Provisioning with PowerShell DSC
date:   2015-04-10
featured-image: posts/vmware-provisioning-with-powershell-dsc/vmware_plus_powershell.png
excerpt: I've written about the idea of [VMware Provisioning with PowerShell DSC before and now I want to show how you can accomplish this using a working example. Below is an admittedly basic but functional custom DSC module to deploy VMs using VMware's PowerCLI.
comments: true
categories: [DevOps, DSC, PowerShell, VMware]
tags: [DevOps, DSC, PowerShell, VMware]
---

>UPDATE - I've started a series of posts about POSHOrigin. A PowerShell module and DSC resource that takes this to the next level. Check it out here.

I've written about the idea of [VMware Provisioning with PowerShell DSC](http://devblackops.io/vmware-provisioning-with-dsc/) before and now I want to show how you can accomplish this using a working example. Below is an admittedly basic but functional custom DSC module to deploy VMs using VMware's [PowerCLI](https://www.vmware.com/support/developer/PowerCLI/). I plan on continuing to add features to this DSC module that enhance VM provisioning and configuration, adding some helper cmdlets for working with DSC, as well as create additional custom DSC resources for the following:

1. Virtual Datacenter creation
2. Cluster creation
  * DRS configuration
  * HA configuration
3. Datastore creation / configuration
4. Network creation
5. Others? Let me know here

### Get It

Download the module from [GitHub](https://github.com/brandolomite/POSHOrigin_vSphere). All comments and contributions are welcome.

### Requirements

1. [Windows Management Framework 5](http://www.microsoft.com/en-us/download/details.aspx?id=45883) - This module is built using DSC classes which are only available as part of PowerShell 5. WMF 5 is still in preview so think carefully if you want to use this in production.
2. [PowerCLI](https://www.vmware.com/support/developer/PowerCLI/) - I am currently using version 6.0 Release 1 but I believe any recent version of PowerCLI will work. Note that I have not tested any other version with this.
3. Provisioning server - This is the Windows system where PowerCLI will need to be installed and is the target for your DSC configuration. I recommend this be separate from your DSC pull server.

### Example Configuration

Below is an example DSC configuration for defining two VMs to be deployed from a given template and ensuring vCPU and RAM match the configuration.

>Please note that this is storing vCenter credentials in **PLAIN TEXT** in the DSC configuration. **DO NOT DO THIS IN ANYTHING BUT A SANDBOX ENVIRONMENT**. For a good overview of setting up certificates with DSC please check [here](http://blogs.msdn.com/b/powershell/archive/2014/01/31/want-to-secure-credentials-in-windows-powershell-desired-state-configuration.aspx).
<commit_msg>Fix GitHub link to project<commit_after>---
title:  VMware Provisioning with PowerShell DSC
date:   2015-04-10
featured-image: posts/vmware-provisioning-with-powershell-dsc/vmware_plus_powershell.png
excerpt: I've written about the idea of [VMware Provisioning with PowerShell DSC before and now I want to show how you can accomplish this using a working example.
  Below is an admittedly basic but functional custom DSC module to deploy VMs using VMware's PowerCLI.
comments: true
categories: [DevOps, DSC, PowerShell, VMware]
tags: [DevOps, DSC, PowerShell, VMware]
---

>UPDATE - I've started a series of posts about POSHOrigin.
A PowerShell module and DSC resource that takes this to the next level.
Check it out [here](http://devblackops.io/poshorigin-part-1-summary/){:target="_blank"}.

I've written about the idea of [VMware Provisioning with PowerShell DSC](http://devblackops.io/vmware-provisioning-with-dsc/) before and now I want to show how you can accomplish this using a working example.
Below is an admittedly basic but functional custom DSC module to deploy VMs using VMware's [PowerCLI](https://www.vmware.com/support/developer/PowerCLI/).I plan on continuing to add features to this DSC module that enhance VM provisioning and configuration, adding some helper cmdlets for working with DSC, as well as create additional custom DSC resources for the following:

1. Virtual Datacenter creation
2. Cluster creation
  * DRS configuration
  * HA configuration
3. Datastore creation / configuration
4. Network creation
5. Others? Let me know here

### Get It

Download the module from [GitHub](https://github.com/devblackops/POSHOrigin_vSphere). All comments and contributions are welcome.

### Requirements

1. [Windows Management Framework 5](http://www.microsoft.com/en-us/download/details.aspx?id=45883) - This module is built using DSC classes which are only available as part of PowerShell 5. WMF 5 is still in preview so think carefully if you want to use this in production.
2. [PowerCLI](https://www.vmware.com/support/developer/PowerCLI/) - I am currently using version 6.0 Release 1 but I believe any recent version of PowerCLI will work. Note that I have not tested any other version with this.
3. Provisioning server - This is the Windows system where PowerCLI will need to be installed and is the target for your DSC configuration. I recommend this be separate from your DSC pull server.

### Example Configuration

Below is an example DSC configuration for defining two VMs to be deployed from a given template and ensuring vCPU and RAM match the configuration.

>Please note that this is storing vCenter credentials in **PLAIN TEXT** in the DSC configuration. **DO NOT DO THIS IN ANYTHING BUT A SANDBOX ENVIRONMENT**. For a good overview of setting up certificates with DSC please check [here](http://blogs.msdn.com/b/powershell/archive/2014/01/31/want-to-secure-credentials-in-windows-powershell-desired-state-configuration.aspx).

{'fraction_non_alphanumeric': 0.06867614317520124, 'fraction_numerical': 0.012159616372666552, 'mean_word_length': 4.615384615384615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5998412', 'n_tokens_mistral': 1651, 'n_tokens_neox': 1555, 'n_words': 757}