Figured it would it be better if I posted the whole script I'm using.
If I've understood DSC Pull config correctly (which I very well may NOT have done!) this script should
1) create a MOF file that installs and configures IIS plus create a share 2) Rename the MOF to $guid.mof and place it in the correct folder (CONFIGURATIONS) 3) Create a checksum file for the $guid.mof file 4) Define the LCM config to be used 5) Apply the LCM config on the target machine
Everything works just fine except that the target machine does not start configuring itself.
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true)]
[string]
$Computername
)
Configuration SetPullMode
{
param([string]$guid,[string]$targetnode)
Node $targetnode
{
LocalConfigurationManager
{
AllowModuleOverwrite = 'True'
RebootNodeIfNeeded = 'True'
ConfigurationMode = 'ApplyAndAutoCorrect'
ConfigurationModeFrequencyMins = 30
ConfigurationID = $guid
RefreshMode = 'Pull'
RefreshFrequencyMins = 15
DownloadManagerName = 'WebDownloadManager'
DownloadManagerCustomData = @{
ServerUrl = 'http://PULLSERVER1:8080/PSDSCPullServer.svc';
AllowUnsecureConnection = 'true' }
}
}
}
Configuration RPLVConfig
{
param ($targetNode)
Import-DscResource -Module xWebAdministration, xSmbShare
Node $targetNode
{
#Install the Web Server Role
WindowsFeature IIS
{
Ensure = “Present”
Name = “Web-Server”
}
#Install the Web Server Role
WindowsFeature IISRemoteManagement
{
DependsOn = "[WindowsFeature]IIS"
Ensure = “Present”
Name = “Web-Mgmt-Service”
}
# Stop the default website
xWebsite DefaultSite
{
Ensure = "Present"
Name = "Default Web Site"
State = "Stopped"
PhysicalPath = "C:\inetpub\wwwroot"
DependsOn = "[WindowsFeature]IIS"
}
File WebSite_Folder
{
Ensure = "Present" # You can also set Ensure to "Absent"
Type = "Directory" # Default is "File".
DestinationPath = "D:\del-pkg"
}
#Create the app pool
xWebAppPool DelPKG_AppPool
{
Ensure = "Present"
Name = "del-pkg"
State = "Started"
DependsOn = "[WindowsFeature]IIS"
}
xWebSite DelPKG_Website
{
Ensure = "Present"
Name = "del-pkg"
State = "Started"
PhysicalPath = "d:\del-pkg"
ApplicationPool = "del-pkg"
BindingInfo = @(
@(MSFT_xWebBindingInformation
{
Protocol = "HTTP"
Port = 80
HostName = "del-pkg"
}
)
@(MSFT_xWebBindingInformation
{
Protocol = "HTTP"
Port = 80
HostName = "del-pkg.eeas.europa.eu"
}
)
)
DependsOn = '[WindowsFeature]IIS', '[xWebAppPool]DelPKG_AppPool','[File]WebSite_Folder'
}
Service Web_MGMT_Service
{
Name = "WMSVC"
BuiltInAccount = "LocalService"
StartupType = "Automatic"
State = "Running"
}
Registry Enable_Web_RemoteManage
{
Ensure = "Present" # You can also set Ensure to "Absent"
Key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WebManagement\Server"
ValueName = "EnableRemoteManagement"
ValueData = "1"
ValueType = "Dword"
}
xSmbShare Share1
{
DependsOn = "[File]WebSite_Folder"
Ensure = "present"
Name = "adminpoints$"
Path = "d:\del-pkg\global\software\adminpoints"
}
}
}
#Clean the configuration folder during testing
$MOFFolder = '\\PULLSERVER1\c$\program files\windowspowershell\dscservice\configuration'
del "$MOFFolder\*.*"
$MOF = RPLVConfig -targetNode $Computername
Write-Output "Generating MOF File for $computername"
Write-Output "Generating unique GUID for this DSC"
$guid = [guid]::NewGuid()
$dest = "$MOFFolder\$guid.mof"
Write-Output "Moving $($MOF.Fullname) to Pull Server's configuration folder"
Move-Item $MOF.FullName $dest -force
Write-Output "Generating checksum file"
New-DSCChecksum $dest -Verbose -Force
Write-Output "Configuring LCM on $Computername"
SetPullMode -guid $guid -targetnode $computername
$cim = New-CimSession -ComputerName $computername
Write-Host "Setting LCM on $computername"
Set-DscLocalConfigurationManager -CimSession $cim -Path .\SetPullMode -Verbose
#Set-DSCLocalConfigurationManager -ComputerName $Computername -Path ./SetPullMode -Verbose