Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Deployments are now tested for WebAccess and SessionHosts as well
- Resource can extend an existing deployment with more session hosts and web access servers
- ConnectionBroker is only remaining key since the broker can only broker one deployment
- Servers can be also removed from the deployment.
- Test function now uses `Test-DscParameterState` internally.
Comment on lines +36 to +37
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Grammar and punctuation consistency for Changed > xRDSessionDeployment

  • Use “can also be removed” (natural word order).
  • Drop trailing periods to match neighboring bullets.
  • Prefer explicit “Test-TargetResource” over “Test function” for clarity.
-  - Servers can be also removed from the deployment.
-  - Test function now uses `Test-DscParameterState` internally.
+  - Servers can also be removed from the deployment
+  - Test-TargetResource now uses `Test-DscParameterState` internally
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Servers can be also removed from the deployment.
- Test function now uses `Test-DscParameterState` internally.
- Servers can also be removed from the deployment
- Test-TargetResource now uses `Test-DscParameterState` internally
🧰 Tools
🪛 LanguageTool

[grammar] ~30-~30: There might be a mistake here.
Context: ...ses Test-DscParameterState internally. - xRDServer - Improve error handling in ...

(QB_NEW_EN)

🤖 Prompt for AI Agents
In CHANGELOG.md around lines 29 to 30, the two bullets under "Changed >
xRDSessionDeployment" have awkward word order, inconsistent punctuation, and an
ambiguous reference; change "Servers can be also removed from the deployment."
to "Servers can also be removed from the deployment" (move "also" and remove
trailing period), and change "Test function now uses `Test-DscParameterState`
internally." to "Test-TargetResource now uses `Test-DscParameterState`
internally" (use explicit name and drop trailing period) so the bullets match
neighboring items in style and clarity.

- xRDServer
- Improve error handling in Set-TargetResource function for Add-RDServer
cmdlet, fixes [issue #111](https://github.com/dsccommunity/xRemoteDesktopSessionHost/issues/111).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ function Get-TargetResource
$deployed = Get-RDServer -ConnectionBroker $ConnectionBroker -ErrorAction SilentlyContinue

@{
SessionHost = [System.String[]] ($deployed | Where-Object Roles -Contains 'RDS-RD-SERVER' | ForEach-Object Server)
SessionHost = [string[]]($deployed | Where-Object Roles -Contains 'RDS-RD-SERVER' | ForEach-Object Server)
ConnectionBroker = $deployed | Where-Object Roles -Contains 'RDS-CONNECTION-BROKER' | ForEach-Object Server
WebAccessServer = $deployed | Where-Object Roles -Contains 'RDS-WEB-ACCESS' | ForEach-Object Server
WebAccessServer = [string[]]($deployed | Where-Object Roles -Contains 'RDS-WEB-ACCESS' | ForEach-Object Server)
}
}

Expand Down Expand Up @@ -87,11 +87,23 @@ function Set-TargetResource
Add-RDServer -Server $server -Role 'RDS-RD-SERVER' -ConnectionBroker $ConnectionBroker
}

foreach ($server in ($currentStatus.SessionHost | Where-Object { $_ -notin $SessionHost }))
{
Write-Verbose "Removing server '$server' from deployment."
Remove-RDServer -Server $server -Role 'RDS-RD-SERVER' -ConnectionBroker $ConnectionBroker -Force
}

foreach ($server in ($WebAccessServer | Select-Object -Skip 1 | Where-Object { $_ -notin $currentStatus.WebAccessServer }))
{
Write-Verbose "Adding server '$server' to deployment."
Write-Verbose "Adding Web Server '$server' to deployment."
Add-RDServer -Server $server -Role 'RDS-WEB-ACCESS' -ConnectionBroker $ConnectionBroker
}

foreach ($server in ($currentStatus.WebAccessServer | Where-Object { $_ -notin $WebAccessServer }))
{
Write-Verbose "Removing Web Server '$server' from deployment."
Remove-RDServer -Server $server -Role 'RDS-WEB-ACCESS' -ConnectionBroker $ConnectionBroker -Force
}
}

#######################################################################
Expand All @@ -112,41 +124,17 @@ function Test-TargetResource
)

Write-Verbose 'Checking RDSH role is deployed on this node.'
$currentStatus = Get-TargetResource @PSBoundParameters

if ($currentStatus.ConnectionBroker -ne $ConnectionBroker)
{
Write-Verbose -Message "Found connection broker '$($currentStatus.ConnectionBroker)', expected '$ConnectionBroker'"
return $false
}
$desiredState = $PSBoundParameters
$currentState = Get-TargetResource @PSBoundParameters

if ($WebAccessServer.Count -gt 0 -and $null -eq $currentStatus.WebAccessServer)
{
Write-Verbose -Message "Desired list of Web Access Servers is empty, while $($WebAccessServer.Count) Web Access Servers should have been configured."
return $false
}

$compare = Compare-Object -ReferenceObject $WebAccessServer -DifferenceObject $currentStatus.WebAccessServer
if ($null -ne $compare)
{
Write-Verbose -Message "Desired list of Web Access Servers not equal`r`n$($compare | Out-String)"
return $false
}

if ($SessionHost.Count -gt 0 -and $null -eq $currentStatus.SessionHost)
{
Write-Verbose -Message "Desired list of session hosts is empty, while $($SessionHost.Count) session hosts should have been configured."
return $false
}

$compare = Compare-Object -ReferenceObject $SessionHost -DifferenceObject $currentStatus.SessionHost
if ($null -ne $compare)
{
Write-Verbose -Message "Desired list of session hosts not equal`r`n$($compare | Out-String)"
return $false
}
$result = Test-DscParameterState `
-CurrentValues $currentState `
-DesiredValues $desiredState `
-SortArrayValues `
-Verbose:$VerbosePreference

$true
return $result
}

Export-ModuleMember -Function *-TargetResource
Loading