How to Build a Test PowerShell DSC Pull Server

Test DSC Pullserver

    1. Configure a new Windows 2012 Server
    2. Install Windows Management Framework 4.0 and reboot
    3. Install Windows Management Framework 5.0 April Preview or later and reboot1
    4. Open the PowerShell ISE as administrator and type the following: find-module | install-module -force
    5. Enter and execute the following script:
      Configuration SomeMasterConfigurationName{
      			[String] $certificateThumbprint
      		Import-DSCResource -ModuleName xPSDesiredStateConfiguration
      		Node localhost{
      			WindowsFeature DSCServiceFeature{
      				Ensure = "Present"
      				Name = "DSC-Service"
      		xDSCWebService PSDSCPullServer{
      			Ensure = "Present"
      			EndPointName = "PSDSCPullServer"
      			CertificateThumbprint = $certificateThumbprint
      			PhysicalPath = "$env:SystemDrive\inetpub\wwwroot\PSDSCPullServer"
      			ConfigurationPath = "$env:ProgramFiles\WindowsPowerShell\DscService\Configuration"
      			ModulePath = "$env:ProgramFiles\WindowsPowerShell\DscService\Modules"
      			Port = 80
      			IsComplianceServer = $false
      			State = "Started"
      			DependsOn = "[WindowsFeature]DSCServiceFeature"
      		xDSCWebService PSDSCComplianceServer{
      			Ensure = "Present"
      			EndPointName = "PSDSCComplianceServer"
      			CertificateThumbprint = "AllowUnencryptedTraffic"
      			PhysicalPath = "$env:SystemDrive\inetpub\wwwroot\PSDSCComplianceServer"
      			Port = 81
      			IsComplianceServer = $true
      			State = "Started"
      			DependsOn = "[WindowsFeature]DSCServiceFeature"
      SomeMasterConfigurationName -CertificateThumbPrint "AllowUnencryptedTraffic"
      Start-DscConfiguration -Path .\SomeMasterConfigurationName -Wait -Verbose -Force
    6. In the PowerShell prompt execute "[guid]::NewGuid()" and record the resulting guid.
    7. In the PowerShell ISE execute the following sample configuration script:
      Configuration SomeMasterConfigurationName{
      	Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
      	Node [GUID recorded above]{
      		File SomeSpecificConfigurationName{
      			Ensure = "Present"
      			Type = "Directory"
      			DestinationPath = "c:\windows\logs\SOMELOGDIR"
      SomeMasterConfigurationName -OutputPath c:\some_empty_temp_folder -Verbose
      New-DscChecksum -Path c:\some_empty_temp_folder -Verbose
    8. Copy the resulting files from c:\some_empty_temp_folder to c:\Program Files\WindowsPowerShell\DscService\Configuration.
    9. On a test client machine, open the PowerShell ISE and enter and execute the following script:
      Configuration SomeMasterConfigurationName{
      		ConfigurationID = "[GUID recorded above]"
      		RefreshMode = "PULL"
      		DownloadManagerName = "WebDownloadManager"
      		RebootNodeIfNeeded = $true
      		ConfigurationModeFrequencyMins = 30
      		ConfigurationMode = "ApplyAndAutoCorrect"
      		DownloadManagerCustomData = @{
      			ServerUrl = "http://[IP Address or Hostname of the Pull Server]/PSDSCPullServer.svc"; AllowUnsecureConnection = "TRUE"
      SomeMasterConfigurationName -verbose -Path c:\some_empty_temp_folder
      Set-DscLocalConfigurationManager -ComputerName localhost -Path c:\some_empty_temp_folder

The test client now has a policy to ensure the existence of c:\windows\logs\SOMELOGDIR.

1This is optional, see the DSC module documentation if WFM 5 is required

Document Actions