dsccommunity / dsccommunity/RemoteDesktopServicesDsc

xRDServer: Adding RDS-Web-Access role throws exception

Open
#94 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
36
Forks
46
PR merge metrics
No merged PRs in 30d

Description

Details of the scenario you tried and the problem that is occurring

Using xRDServer ressource to add an RDS-Web-Access server raises exceptions but works anyway.

Verbose logs showing the problem
{
    "Exception":  {
                      "Message":  "The PowerShell DSC resource \u0027[xRDServer]AddWebServer02\u0027 with SourceInfo \u0027::179::9::xRDServer\u0027 threw one or more non-terminating errors while running the Set-TargetResource functionality. These errors are logged to the ETW channel called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.",
                      "Data":  {

                               },
                      "InnerException":  {
                                             "SerializedRemoteException":  "System.Management.Automation.CommandNotFoundException: The term \u0027Get-RDWorkspace\u0027 is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.\r\n   at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)\r\n   at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)\r\n   at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)\r\n   at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)\r\n   at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)\r\n   at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)\r\n   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)\r\n   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)",
                                             "SerializedRemoteInvocationInfo":  "System.Management.Automation.InvocationInfo",
                                             "ErrorRecord":  "The term \u0027Get-RDWorkspace\u0027 is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.",
                                             "WasThrownFromThrowStatement":  false,
                                             "Message":  "The term \u0027Get-RDWorkspace\u0027 is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.",
                                             "Data":  "System.Collections.ListDictionaryInternal",
                                             "InnerException":  null,
                                             "TargetSite":  null,
                                             "StackTrace":  null,
                                             "HelpLink":  null,
                                             "Source":  null,
                                             "HResult":  -2146233087
                                         },
                      "TargetSite":  null,
                      "StackTrace":  null,
                      "HelpLink":  null,
                      "Source":  null,
                      "HResult":  -2146233079
                  },
    "TargetObject":  null,
    "CategoryInfo":  {
                         "Category":  7,
                         "Activity":  "",
                         "Reason":  "InvalidOperationException",
                         "TargetName":  "",
                         "TargetType":  ""
                     },
    "FullyQualifiedErrorId":  "NonTerminatingErrorFromProvider",
    "ErrorDetails":  null,
    "InvocationInfo":  null,
    "ScriptStackTrace":  null,
    "PipelineIterationInfo":  [

                              ]
}

Suggested solution to the issue

I found a workaround by adding a reboot if Add-RDServer fails. This is not a ideal solution as it could result in an infinite loop, but it does the job for me right now.

 xRDSessionDeployment RDDeployment
{
    ConnectionBroker = $MainConnectionBroker
    WebAccessServer = $WebAccessServer1
    SessionHost = $SessionHost
    PsDscRunAsCredential = $AdminCreds
    DependsOn = "[xDSCDomainjoin]JoinDomain"
}

Script AddWebServer02 {
    GetScript = { @{} } # not used
    SetScript = {
        try {
            Import-Module RemoteDesktop
            Add-RDServer -Server $Using:WebAccessServer2 -Role 'RDS-Web-Access' -ConnectionBroker $Using:ConnectionBroker
        }
        catch {
              # The function throws an exception but still works
        }
    }
    TestScript = {
        Import-Module RemoteDesktop
        $servers = Get-RDServer -Role 'RDS-Web-Access' -ConnectionBroker $Using:MainConnectionBroker -ErrorAction SilentlyContinue
        if ($servers -and $Using:WebAccessServer2 -in $servers.Server) { return $true } else { return $false }
    }
    
    PsDscRunAsCredential = $AdminCreds
    DependsOn = "[xRDSessionDeployment]RDDeployment"
}  
The DSC configuration that is used to reproduce the issue (as detailed as possible)

xRDSessionDeployment RDDeployment
{
    ConnectionBroker = $MainConnectionBroker
    WebAccessServer = $WebAccessServer1
    SessionHost = $SessionHost
    PsDscRunAsCredential = $AdminCreds
    DependsOn = "[xDSCDomainjoin]JoinDomain"
}


xRDServer AddWebServer02
{
    ConnectionBroker = $MainConnectionBroker
    Role = 'RDS-Web-Access'
    Server = $WebAccessServer2
    PsDscRunAsCredential = $AdminCreds
    DependsOn = "[xRDServer]AddGateway02"
}
The operating system the target node is running

OsName               : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 1809
WindowsBuildLabEx    : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

Version and build of PowerShell the target node is running
Name                           Value
----                           -----
PSVersion                      5.1.17763.1852
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.1852
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
Version of the DSC module that was used

2.0.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the xRDServer resource configuration for AddWebServer02 and reproduce the RDS-Web-Access deployment on Windows Server 2019 using the reported PowerShell and module versions. Investigate the reported Get-RDWorkspace exception around Add-RDServer, then verify that deployment completes without an exception and that the web-access server is present in Get-RDServer.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.