Skip to content

Commit e0b196c

Browse files
authored
Add support for overwriting the hostname and/or certificate thumbprint on the listener - Fixes #23 (#101)
* Added support for changing the hostname and/or certificate thumbprint on the listener. * Updated changelog.
1 parent e2b99a6 commit e0b196c

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## [Unreleased]
77

8+
- WSManDsc
9+
- Added support for changing the hostname and/or certificate thumbprint on the listener - fixes [Issue #23](https://github.com/dsccommunity/WSManDsc/issues/23).
10+
811
### Added
912

1013
- Added build task `Generate_Conceptual_Help` to generate conceptual help

source/DSCResources/DSC_WSManListener/DSC_WSManListener.psm1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,26 @@ function Test-TargetResource
462462
) -join '' )
463463
$desiredConfigurationMatch = $false
464464
}
465+
466+
if ($PSBoundParameters.ContainsKey('Hostname') -and $listener.Hostname -ne $Hostname)
467+
{
468+
Write-Verbose -Message ( @(
469+
"$($MyInvocation.MyCommand): "
470+
$($script:localizedData.ListenerOnWrongHostnameMessage) `
471+
-f $Transport, $listener.Hostname, $Hostname
472+
) -join '' )
473+
$desiredConfigurationMatch = $false
474+
}
475+
476+
if ($PSBoundParameters.ContainsKey('CertificateThumbprint') -and $listener.CertificateThumbprint -ne $CertificateThumbprint)
477+
{
478+
Write-Verbose -Message ( @(
479+
"$($MyInvocation.MyCommand): "
480+
$($script:localizedData.ListenerOnWrongCertificateThumbprintMessage) `
481+
-f $Transport, $listener.CertificateThumbprint, $CertificateThumbprint
482+
) -join '' )
483+
$desiredConfigurationMatch = $false
484+
}
465485
}
466486
else
467487
{

source/DSCResources/DSC_WSManListener/en-US/DSC_WSManListener.strings.psd1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ ConvertFrom-StringData @'
1212
TestingListenerMessage = Testing Listener.
1313
ListenerOnWrongPortMessage = {0} Listener is on port {1}, should be on {2}. Change required.
1414
ListenerOnWrongAddressMessage = {0} Listener is bound to {1}, should be {2}. Change required.
15+
ListenerOnWrongHostnameMessage = {0} Listener Hostname is {1}, should be {2}. Change required.
16+
ListenerOnWrongCertificateThumbprintMessage = {0} Listener Certificate Thumbprint is {1}, should be {2}. Change required.
1517
ListenerDoesNotExistButShouldMessage = {0} Listener does not exist but should. Change required.
1618
ListenerExistsButShouldNotMessage = {0} Listener exists but should not. Change required.
1719
ListenerDoesNotExistAndShouldNotMessage = {0} Listener does not exist and should not. Change not required.

0 commit comments

Comments
 (0)