Author Posts

August 28, 2017 at 11:23 pm

Hi All,
I have setup a Powershell DSC Pull server on Windows Server 2016. This looks all fine, now my next step is to setup a pull client.

I have also setup a sample config to check a windows service. This has a mof file and a checksum file.

The computer-specific file for the client configuration is a mof meta file.

Set-DSCLocalConfigurationManager localhost –Path C:\Configs\TargetNodes –Verbose
Get-DscConfigurationStatus (Success)
Start-DscConfiguration -Path C:\Configs\AudioServiceConfig -ComputerName GLODC01 (this gave me an output of "running")
Get-DscConfigurationStatus (Failure)

I'm not sure why I get the failure. Now firewalls. Any ideas?

————————- SCRIPT FOR DSC PULL SERVER CONFIG ——————–

# DSC configuration for Pull Server using registration

# The Sample_xDscWebServiceRegistration configuration sets up a DSC pull server that is capable for client nodes
# to register with it and retrieve configuration documents with configuration names instead of configuration id

# Prerequisite: Install a certificate in "CERT:\LocalMachine\MY\" store
# For testing environments, you could use a self-signed certificate. (New-SelfSignedCertificate cmdlet could generate one for you).
# For production environments, you will need a certificate signed by valid CA.
# Registration only works over https protocols. So to use registration feature, a secure pull server setup with certificate is necessary

# The Sample_MetaConfigurationToRegisterWithLessSecurePullServer register a DSC client node with the pull server

# =================================== Section Pull Server =================================== #
configuration Sample_xDscWebServiceRegistration
{
param
(
[string[]]$NodeName = 'localhost',

[ValidateNotNullOrEmpty()]
[string] $certificateThumbPrint,

[Parameter(HelpMessage='This should be a string with enough entropy (randomness) to protect the registration of clients to the pull server. We will use new GUID by default.')]
[ValidateNotNullOrEmpty()]
[string] $RegistrationKey # A guid that clients use to initiate conversation with pull server
)

Import-DSCResource -ModuleName xPSDesiredStateConfiguration

Node $NodeName
{
WindowsFeature DSCServiceFeature
{
Ensure = "Present"
Name = "DSC-Service"
}

xDscWebService PSDSCPullServer
{
Ensure = "Present"
EndpointName = "PSDSCPullServer"
Port = 8080
PhysicalPath = "$env:SystemDrive\inetpub\wwwroot\PSDSCPullServer"
CertificateThumbPrint = $certificateThumbPrint
ModulePath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Modules"
ConfigurationPath = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Configuration"
State = "Started"
DependsOn = "[WindowsFeature]DSCServiceFeature"
RegistrationKeyPath = "$env:PROGRAMFILES\WindowsPowerShell\DscService"
AcceptSelfSignedCertificates = $true
UseSecurityBestPractices = $true
}

File RegistrationKeyFile
{
Ensure = 'Present'
Type = 'File'
DestinationPath = "$env:ProgramFiles\WindowsPowerShell\DscService\RegistrationKeys.txt"
Contents = $RegistrationKey
}
}
}

# Sample use (please change values of parameters according to your scenario):
$thumbprint = '‎64caa82b0d513322f4cf09d8a90ea607a0831831'
$registrationkey = [guid]::NewGuid()

Write-Host $registrationKey

Sample_xDscWebServiceRegistration -RegistrationKey $registrationkey -certificateThumbPrint $thumbprint

———————–SCRIPT TO SETUP MACHINE MOF FILE ———————————–

configuration LCMPullMode
{
param
(
[string]$ComputerName,
[string]$GUID
)

node $ComputerName
{
LocalConfigurationManager
{
ConfigurationID = $GUID
ConfigurationMode = 'ApplyAndAutocorrect'
RefreshMode = 'Pull'
DownloadManagerName = 'WebDownloadManager'
DownloadManagerCustomData = @{
ServerUrl = 'https://glopsdsc:8080/PSDSCPullServer.svc'
AllowUnsecureConnection = 'true' }
RebootNodeIfNeeded = $true
}
}
}

LCMPullMode -ComputerName GLODC01 -GUID 96a3f61f-bacf-46c6-a915-0b309e2534a5

———————————SCRIPT TO SETUP A DSC CONFIG ——————————-

configuration AudioServiceConfig
{
param([string[]] $computerName)

node $computerName
{
Service Audio
{
Name = 'Audiosrv'
StartupType = 'Automatic'
State = 'Running'
}
}
}

AudioServiceConfig -ComputerName GLODC01

August 29, 2017 at 8:35 pm

Change to:

Start-DscConfiguration -Path C:\Configs\AudioServiceConfig -ComputerName GLODC01 -Wait -Verbose

And let's see if you get something more interesting.