How to Build a Test PowerShell DSC Pull Server
Test DSC Pullserver
- Configure a new Windows Server and ensure that it has PowerShell 5 installed.
- Open PowerShell ISE as administrator, enter and execute the following script:
Configuration MyPullServer{ param( [ValidateNotNullOrEmpty()] [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" } } } MyPullServer Start-DscConfiguration -Path .\MyPullServer-Wait -Verbose -Force
- In the PowerShell ISE execute the following sample configuration script:
Configuration SampleConfiguration{ Import-DscResource -ModuleName 'PSDesiredStateConfiguration' Node [GUID recorded above]{ File SomeSpecificConfigurationName{ Ensure = "Present" Type = "Directory" DestinationPath = "c:\windows\logs\SOMELOGDIR" } } } SampleConfiguration -OutputPath c:\some_empty_temp_folder -Verbose New-DscChecksum -Path c:\some_empty_temp_folder -Verbose
- Copy the resulting files from c:\some_empty_temp_folder to c:\Program Files\WindowsPowerShell\DscService\Configuration.
Test DSC Client
- On a test client machine, in the PowerShell prompt execute "[guid]::NewGuid()" and record the resulting guid.
- Open PowerShell ISE and enter and execute the following script:
Configuration MyLCM{ LocalConfigurationManager{ 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" } } } MyLCM -verbose -Path c:\some_empty_temp_folder Set-DscLocalConfigurationManager -ComputerName localhost -Path c:\some_empty_temp_folder
The test client will pull SampleConfiguration every 30 minutes and ensure the existence of c:\windows\logs\SOMELOGDIR.
Document Actions