@@ -94,7 +94,7 @@ function Set-TargetResource
9494 [string ]$EndpointName ,
9595
9696 # Port number of the DSC Pull Server IIS Endpoint
97- [Uint32 ]$Port = $ ( if ( $IsComplianceServer ) { 7070 } else { 8080 } ) ,
97+ [Uint32 ]$Port = 8080 ,
9898
9999 # Physical path for the IIS Endpoint on the machine (usually under inetpub)
100100 [string ]$PhysicalPath = " $env: SystemDrive \inetpub\$EndpointName " ,
@@ -116,14 +116,11 @@ function Set-TargetResource
116116 # Location on the disk where the Configuration is stored
117117 [string ]$ConfigurationPath = " $env: PROGRAMFILES \WindowsPowerShell\DscService\Configuration" ,
118118
119- # Is the endpoint for a DSC Compliance Server
120- [boolean ]$IsComplianceServer ,
121-
122119 # Location on the disk where the RegistrationKeys file is stored
123120 [string ]$RegistrationKeyPath = " $env: PROGRAMFILES \WindowsPowerShell\DscService" ,
124121
125122 # Add the IISSelfSignedCertModule native module to prevent self-signed certs being rejected.
126- [boolean ]$AcceptSelfSignedCertificates
123+ [boolean ]$AcceptSelfSignedCertificates = $true
127124 )
128125
129126 # Initialize with default values
@@ -150,41 +147,18 @@ function Set-TargetResource
150147 $IsBlue = $true ;
151148 }
152149
150+ $isDownlevelOfBlue = $false ;
151+ if ($os.Major -eq 6 -and $os.Minor -lt 3 )
152+ {
153+ $isDownlevelOfBlue = $true ;
154+ }
155+
153156 # Use Pull Server values for defaults
154157 $webConfigFileName = " $pathPullServer \PSDSCPullServer.config"
155158 $svcFileName = " $pathPullServer \PSDSCPullServer.svc"
156159 $pswsMofFileName = " $pathPullServer \PSDSCPullServer.mof"
157160 $pswsDispatchFileName = " $pathPullServer \PSDSCPullServer.xml"
158161
159- # Update only if Compliance Server install is requested
160- if ($IsComplianceServer )
161- {
162- $webConfigFileName = " $pathPullServer \PSDSCComplianceServer.config"
163- $svcFileName = " $pathPullServer \PSDSCComplianceServer.svc"
164- $pswsMofFileName = " $pathPullServer \PSDSCComplianceServer.mof"
165- $pswsDispatchFileName = " $pathPullServer \PSDSCComplianceServer.xml"
166- }
167-
168- # check for the existance of Windows authentication, this is needed for the Compliance Server
169- if (($Ensure -eq " Present" ))
170- {
171- Write-Verbose " Check IIS Windows Authentication"
172- # only important if Present, Get-WindowsFeature works under 2008 R2 and newer
173- if ((Get-WindowsFeature - name Web- Windows- Auth | Where Installed).count -eq 0 )
174- {
175- # enable the feature
176- # Checking for Windows Server 2008 R2:
177- if ([Environment ]::OSVersion.Version.ToString().StartsWith(" 6.1." ))
178- {
179- Add-WindowsFeature - Name Web- Windows- Auth
180- }
181- else
182- {
183- Install-WindowsFeature - Name Web- Windows- Auth
184- }
185- }
186- }
187-
188162 # ============ Absent block to remove existing site =========
189163 if (($Ensure -eq " Absent" ))
190164 {
@@ -200,7 +174,6 @@ function Set-TargetResource
200174 return
201175 }
202176 # ===========================================================
203-
204177
205178 Write-Verbose " Create the IIS endpoint"
206179 PSWSIISEndpoint\New-PSWSEndpoint - site $EndpointName `
@@ -223,68 +196,67 @@ function Set-TargetResource
223196 Update-LocationTagInApplicationHostConfigForAuthentication - WebSite $EndpointName - Authentication " basic"
224197 Update-LocationTagInApplicationHostConfigForAuthentication - WebSite $EndpointName - Authentication " windows"
225198
226-
227199 if ($IsBlue )
228200 {
229201 Write-Verbose " Set values into the web.config that define the repository for BLUE OS"
230- # PSWSIISEndpoint\Set-AppSettingsInWebconfig -path $PhysicalPath -key "dbprovider" -value $eseprovider
231- # PSWSIISEndpoint\Set-AppSettingsInWebconfig -path $PhysicalPath -key "dbconnectionstr"-value $esedatabase
232- # ESE database is not present in current build
233- PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " dbprovider" - value $jet4provider
234- PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " dbconnectionstr" - value $jet4database
202+ PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " dbprovider" - value $eseprovider
203+ PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " dbconnectionstr" - value $esedatabase
235204 Set-BindingRedirectSettingInWebConfig - path $PhysicalPath
236205 }
237206 else
238207 {
239- Write-Verbose " Set values into the web.config that define the repository for non-BLUE Downlevel OS"
240- $repository = Join-Path " $rootDataPath " " Devices.mdb"
241- Copy-Item " $pathPullServer \Devices.mdb" $repository - Force
208+ if ($isDownlevelOfBlue )
209+ {
210+ Write-Verbose " Set values into the web.config that define the repository for non-BLUE Downlevel OS"
211+ $repository = Join-Path " $rootDataPath " " Devices.mdb"
212+ Copy-Item " $pathPullServer \Devices.mdb" $repository - Force
242213
243- PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " dbprovider" - value $jet4provider
244- PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " dbconnectionstr" - value $jet4database
245- }
214+ PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " dbprovider" - value $jet4provider
215+ PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " dbconnectionstr" - value $jet4database
216+ }
217+ else
218+ {
219+ Write-Verbose " Set values into the web.config that define the repository later than BLUE OS"
220+ Write-Verbose " Only ESENT is supported on Windows Server 2016"
246221
247- if ($IsComplianceServer )
248- {
249- Write-Verbose " Compliance Server: Set values into the web.config that indicate this is the admin endpoint"
250- PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " AdminEndPoint" - value " true"
222+ PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " dbprovider" - value $eseprovider
223+ PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " dbconnectionstr" - value $esedatabase
224+ }
251225 }
252- else
253- {
254- Write-Verbose " Pull Server: Set values into the web.config that indicate the location of repository, configuration, modules"
255226
256- # Create the application data directory calculated above
257- $null = New-Item - path $rootDataPath - itemType " directory" - Force
258-
259- $repository = Join-Path $rootDataPath " Devices.mdb"
260- Copy-Item " $pathPullServer \Devices.mdb" $repository - Force
227+ Write-Verbose " Pull Server: Set values into the web.config that indicate the location of repository, configuration, modules"
261228
262- $null = New-Item - path " $ConfigurationPath " - itemType " directory" - Force
229+ # Create the application data directory calculated above
230+ $null = New-Item - path $rootDataPath - itemType " directory" - Force
263231
264- PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " ConfigurationPath" - value $ConfigurationPath
232+ $repository = Join-Path $rootDataPath " Devices.mdb"
233+ Copy-Item " $pathPullServer \Devices.mdb" $repository - Force
265234
266- $null = New-Item - path " $ModulePath " - itemType " directory" - Force
235+ $null = New-Item - path " $ConfigurationPath " - itemType " directory" - Force
267236
268- PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " ModulePath " - value $ModulePath
237+ PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " ConfigurationPath " - value $ConfigurationPath
269238
270- $null = New-Item - path " $RegistrationKeyPath " - itemType " directory" - Force
239+ $null = New-Item - path " $ModulePath " - itemType " directory" - Force
271240
272- PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " RegistrationKeyPath " - value $RegistrationKeyPath
241+ PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " ModulePath " - value $ModulePath
273242
274- if ($AcceptSelfSignedCertificates )
275- {
276- Copy-Item " $pathPullServer \IISSelfSignedCertModule.dll" $env: windir \System32\inetsrv - Force
277- Copy-Item " $env: windir \SysWOW64\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PullServer\IISSelfSignedCertModule.dll" $env: windir \SysWOW64\inetsrv - Force
243+ $null = New-Item - path " $RegistrationKeyPath " - itemType " directory" - Force
278244
279- & $script :appCmd install module / name:" IISSelfSignedCertModule(32bit)" / image:$env: windir \SysWOW64\inetsrv\IISSelfSignedCertModule.dll / add:false / lock:false
280- & $script :appCmd add module / name:" IISSelfSignedCertModule(32bit)" / app.name:" PSDSCPullServer/"
281- }
282- else
245+ PSWSIISEndpoint\Set-AppSettingsInWebconfig - path $PhysicalPath - key " RegistrationKeyPath" - value $RegistrationKeyPath
246+
247+ if ($AcceptSelfSignedCertificates )
248+ {
249+ Copy-Item " $pathPullServer \IISSelfSignedCertModule.dll" $env: windir \System32\inetsrv - Force
250+ Copy-Item " $env: windir \SysWOW64\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PullServer\IISSelfSignedCertModule.dll" $env: windir \SysWOW64\inetsrv - Force
251+
252+ & $script :appCmd install module / name:" IISSelfSignedCertModule(32bit)" / image:$env: windir \SysWOW64\inetsrv\IISSelfSignedCertModule.dll / add:false / lock:false
253+ & $script :appCmd add module / name:" IISSelfSignedCertModule(32bit)" / app.name:" PSDSCPullServer/"
254+ }
255+ else
256+ {
257+ if ($AcceptSelfSignedCertificates -and ($AcceptSelfSignedCertificates -eq $false ))
283258 {
284- if ($AcceptSelfSignedCertificates -and ($AcceptSelfSignedCertificates -eq $false ))
285- {
286- & $script :appCmd delete module / name:" IISSelfSignedCertModule(32bit)" / app.name:" PSDSCPullServer/"
287- }
259+ & $script :appCmd delete module / name:" IISSelfSignedCertModule(32bit)" / app.name:" PSDSCPullServer/"
288260 }
289261 }
290262}
@@ -301,7 +273,7 @@ function Test-TargetResource
301273 [string ]$EndpointName ,
302274
303275 # Port number of the DSC Pull Server IIS Endpoint
304- [Uint32 ]$Port = $ ( if ( $IsComplianceServer ) { 7070 } else { 8080 } ) ,
276+ [Uint32 ]$Port = 8080 ,
305277
306278 # Physical path for the IIS Endpoint on the machine (usually under inetpub)
307279 [string ]$PhysicalPath = " $env: SystemDrive \inetpub\$EndpointName " ,
@@ -323,13 +295,10 @@ function Test-TargetResource
323295 # Location on the disk where the Configuration is stored
324296 [string ]$ConfigurationPath = " $env: PROGRAMFILES \WindowsPowerShell\DscService\Configuration" ,
325297
326- # Is the endpoint for a DSC Compliance Server
327- [boolean ]$IsComplianceServer ,
328-
329298 # Location on the disk where the RegistrationKeys file is stored
330299 [string ]$RegistrationKeyPath ,
331300
332- # Are self-signed certs being accepted for client auth.
301+ # Are self-signed certs being accepted for client auth.
333302 [boolean ]$AcceptSelfSignedCertificates
334303 )
335304
@@ -361,19 +330,6 @@ function Test-TargetResource
361330 }
362331 # the other case is: Ensure and exist, we continue with more checks
363332
364- # check for the existance of Windows authentication, this is needed for the Compliance Server
365- if (($Ensure -eq " Present" ))
366- {
367- Write-Verbose " Check IIS Windows Authentication"
368- # only important if Present, Get-WindowsFeature works under 2008 R2 and newer
369- if ((Get-WindowsFeature - name Web- Windows- Auth | Where Installed).count -eq 0 )
370- {
371- $DesiredConfigurationMatch = $false
372- Write-Verbose " Required Windows authentication is not installed, does not match the desired state."
373- break
374- }
375- }
376-
377333 Write-Verbose " Check Port"
378334 $actualPort = $website.bindings.Collection [0 ].bindingInformation.Split(" :" )[1 ]
379335 if ($Port -ne $actualPort )
0 commit comments