Skip to content

Commit

Permalink
Add support for overwriting the hostname and/or certificate thumbprin…
Browse files Browse the repository at this point in the history
…t on the listener - Fixes #23 (#101)

* Added support for changing the hostname and/or certificate thumbprint on the listener.

* Updated changelog.
  • Loading branch information
corydwood committed Sep 27, 2023
1 parent e2b99a6 commit e0b196c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

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

### Added

- Added build task `Generate_Conceptual_Help` to generate conceptual help
Expand Down
20 changes: 20 additions & 0 deletions source/DSCResources/DSC_WSManListener/DSC_WSManListener.psm1
Expand Up @@ -462,6 +462,26 @@ function Test-TargetResource
) -join '' )
$desiredConfigurationMatch = $false
}

if ($PSBoundParameters.ContainsKey('Hostname') -and $listener.Hostname -ne $Hostname)
{
Write-Verbose -Message ( @(
"$($MyInvocation.MyCommand): "
$($script:localizedData.ListenerOnWrongHostnameMessage) `
-f $Transport, $listener.Hostname, $Hostname
) -join '' )
$desiredConfigurationMatch = $false
}

if ($PSBoundParameters.ContainsKey('CertificateThumbprint') -and $listener.CertificateThumbprint -ne $CertificateThumbprint)
{
Write-Verbose -Message ( @(
"$($MyInvocation.MyCommand): "
$($script:localizedData.ListenerOnWrongCertificateThumbprintMessage) `
-f $Transport, $listener.CertificateThumbprint, $CertificateThumbprint
) -join '' )
$desiredConfigurationMatch = $false
}
}
else
{
Expand Down
Expand Up @@ -12,6 +12,8 @@ ConvertFrom-StringData @'
TestingListenerMessage = Testing Listener.
ListenerOnWrongPortMessage = {0} Listener is on port {1}, should be on {2}. Change required.
ListenerOnWrongAddressMessage = {0} Listener is bound to {1}, should be {2}. Change required.
ListenerOnWrongHostnameMessage = {0} Listener Hostname is {1}, should be {2}. Change required.
ListenerOnWrongCertificateThumbprintMessage = {0} Listener Certificate Thumbprint is {1}, should be {2}. Change required.
ListenerDoesNotExistButShouldMessage = {0} Listener does not exist but should. Change required.
ListenerExistsButShouldNotMessage = {0} Listener exists but should not. Change required.
ListenerDoesNotExistAndShouldNotMessage = {0} Listener does not exist and should not. Change not required.
Expand Down

0 comments on commit e0b196c

Please sign in to comment.