Install Web Platform Installer and Azure SDK using PowerShell DSC

Did you ever wanted to configure a developer machine in less than two minutes with minimal scripting effort?

Say Hi to DSC!

DSC (Desired State Configuration) is really fun when you need to enforce a configuration or state on a Windows machine. It is shipped as part of PowerShell v4 and requires WinRM to communicate with remote machines.

Here is the configuration I use to accomplish the installation of Web Platform Installer, WebDeploy v3.5 & the Azure SDK v2.3.

$configurationData = @{
    AllNodes = @( 
        @{
            NodeName = 'localhost'
            WebPiSourcePath = Join-Path $PSScriptRoot WebPi
            WebPiCmdPath = "$env:ProgramFiles\Microsoft\Web Platform Installer\WebPiCmd-x64.exe"
        }
    );
}

Configuration DevToolsConfiguration
{
    Node $AllNodes.NodeName
    {    
        Package WebPi_Installation
        {
            Ensure = "Present"
            Name = "Microsoft Web Platform Installer 5.0"
            Path = Join-Path $($Node.WebPiSourcePath) wpilauncher.exe
            ProductId = '4D84C195-86F0-4B34-8FDE-4A17EB41306A'
            Arguments = ''
        }

        Package WebDeploy_Installation
        {
            Ensure = "Present"
            Name = "Microsoft Web Deploy 3.5"
            Path = $Node.WebPiCmdPath
            ProductId = ''
            Arguments = "/install /products:WDeploy /AcceptEula"
            DependsOn = @("[Package]WebPi_Installation")
        }

        Package AzureSDK_2_3_Installation
        {
            Ensure = "Present"
            Name = "Windows Azure Libraries for .NET – v2.3"
            Path = $Node.WebPiCmdPath
            ProductId = ''
            Arguments = "/install /products:WindowsAzureSDK_2_3 /AcceptEula"
            DependsOn = @("[Package]WebDeploy_Installation")
        }
    }
}

Now all we need to do is create the MOF file from this configuration and and apply it to the local machine.

$configPath = Join-Path $PSScriptRoot _configurations\push

#Create the MOF file using the configuration data
DevToolsConfiguration -OutputPath $configPath\DevToolsConfiguration –ConfigurationData $configurationData

#Make it happen - invoke configuration
Start-DscConfiguration -Path $configPath\DevToolsConfiguration -Wait -Verbose -Force

That's it! You now have a machine with Web Deploy & the Azure SDK installed. That is impressive for 3 PowerShell statements.

Let me know what you think!

DSC is available as part of Windows 8.1 and Windows Server 2012 R2; you can start building configuration files in Windows PowerShell ISE if you’re running either of those new operating systems. If you’re running Windows 7, Windows Server 2008 R2, or Windows Server 2012, install Windows Management Framework 4.0 to get the benefits of DSC. Learn more about how to get started from the DSC documentation on Microsoft TechNet.

DSC-WebPi sample

I am the proud father of two little gems. A beer & wine enthusiasm. For everything else, I work and play with Azure at day, and I am an Azure MVP & Advisor at night.
Montreal, Canada