Issues with Add-RDServer in Script Resource

I couldn’t find a published resource that would add a server with the RDS-GATEWAY Role, so I set out to put it in a script resource. When I push the configuration on to the server I get an error stating that “‘Get-RDDeploymentGatewayConfiguration’ is not recognized …” of course that would imply that I failed to import the correct module, in this case RemoteDesktop. Well that is not the case

The configuration I am using is as follows

Configuration GateWayStep3{    
    Import-DscResource –ModuleName  PSDesiredStateConfiguration
    Import-DscResource -ModuleName  xPSDesiredStateConfiguration
    Import-DscResource -ModuleName  xPendingReboot

    Node $AllNodes.Where{$_.Role -eq 'GateWayServer'}.NodeName 
    {
        xPendingReboot RebootPending
        {
            Name = "Check for a pending reboot before the next step"
            SkipCcmClientSDK = $True
        }

        LocalConfigurationManager
        {
            RebootNodeIfNeeded = $False
        } 

        xService Remote_DesktopManagement_Service
        {
            Name         = 'RDMS'
            Ensure       = 'Present'
            State        = 'Running'
        }

        WindowsFeature RDS-Gateway
        {
            Ensure = "Present"
            Name = "RDS-Gateway"     
            DependsOn ="[xService]Remote_DesktopManagement_Service"
        }
        
        WindowsFeature RDS-Web-Access 
        { 
            Ensure = "Present" 
            Name = "RDS-Web-Access" 
            DependsOn ="[xService]Remote_DesktopManagement_Service"
        } 

        WindowsFeature RDS-Connection-Broker 
        { 
            Ensure = "Present" 
            Name = "RDS-Connection-Broker" 
            DependsOn ="[xService]Remote_DesktopManagement_Service"
        } 

        WindowsFeature RDS-RD-Server
        { 
            Ensure = "Present" 
            Name = "RDS-RD-Server" 
            DependsOn ="[xService]Remote_DesktopManagement_Service"
        }
             
        Script Add-GatewayServer
        {
            SetScript = Format-DscScriptBlock -Node $Node -ScriptBlock {
                Import-Module RemoteDesktop;
                Write-Verbose "Server              = $Node.GateWayName";
                Write-Verbose "Connection Broker   = $Node.ConnectionBroker";
                Write-Verbose "GatewayExternalFqdn = $Node.GateWayName";
                Write-Verbose "Role                = RDS-GATEWAY";
                Add-RDServer -Server $Node.GateWayName -Role RDS-GATEWAY -ConnectionBroker $Node.ConnectionBroker -GatewayExternalFqdn $Node.GateWayName -ErrorAction SilentlyContinue;
            }
            TestScript =Format-DscScriptBlock -Node $Node -ScriptBlock  {
                Import-Module RemoteDesktop;
                Write-Verbose "GateWay Mode = $(Get-RDDeploymentGatewayConfiguration | Select -ExpandProperty GateWayMode)";
                $DeployedServers = Get-RDServer -ErrorAction SilentlyContinue;
                if(($DeployedServers | ? Roles -contains "RDS-GATEWAY" | % Server)  -ne $null)
                {
                    Write-Verbose "RDS GateWay deployed!";
                    return $true;
                }
                else
                {
                    Write-Verbose "RDS GateWay NOT deployed!";
                    return $false;
                }
            }
            GetScript = {@{Result = 'Doing Nothing'}} 
            DependsOn = "[WindowsFeature]RDS-Connection-Broker", "[WindowsFeature]RDS-RD-Server" ,"[WindowsFeature]RDS-Web-Access","[WindowsFeature]RDS-Gateway"
        }
    }
}

Output of process is as follows

----------------------------------------------------------------------------
               Gateway - Phase 3
----------------------------------------------------------------------------
 
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalCon
figurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer BGSH-MGMT with user sid (It Just Doesn't Matter).
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Set      ]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Resource ]  [[xPendingReboot]RebootPending]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Test     ]  [[xPendingReboot]RebootPending]
VERBOSE: [BGSP-45-GATE]:                            [[xPendingReboot]RebootPending] No pending reboots found.
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Test     ]  [[xPendingReboot]RebootPending]  in 0.0160 seconds.
VERBOSE: [BGSP-45-GATE]: LCM:  [ Skip   Set      ]  [[xPendingReboot]RebootPending]
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Resource ]  [[xPendingReboot]RebootPending]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Resource ]  [[xService]Remote_DesktopManagement_Service]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Test     ]  [[xService]Remote_DesktopManagement_Service]
VERBOSE: [BGSP-45-GATE]:                            [[xService]Remote_DesktopManagement_Service] Service RDMS exists.
VERBOSE: [BGSP-45-GATE]:                            [[xService]Remote_DesktopManagement_Service] Perform operation 'Query CimInstances' with f
ollowing parameters, ''queryExpression' = SELECT * FROM Win32_Service WHERE Name='RDMS','queryDialect' = WQL,'namespaceName' = root\cimv2'.
VERBOSE: [BGSP-45-GATE]:                            [[xService]Remote_DesktopManagement_Service] Operation 'Query CimInstances' complete.
VERBOSE: [BGSP-45-GATE]:                            [[xService]Remote_DesktopManagement_Service] Service RDMS exists.
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Test     ]  [[xService]Remote_DesktopManagement_Service]  in 0.2680 seconds.
VERBOSE: [BGSP-45-GATE]: LCM:  [ Skip   Set      ]  [[xService]Remote_DesktopManagement_Service]
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Resource ]  [[xService]Remote_DesktopManagement_Service]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Resource ]  [[WindowsFeature]RDS-Gateway]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Test     ]  [[WindowsFeature]RDS-Gateway]
VERBOSE: [BGSP-45-GATE]:                            [[WindowsFeature]RDS-Gateway] The operation 'Get-WindowsFeature' started: RDS-Gateway
VERBOSE: [BGSP-45-GATE]:                            [[WindowsFeature]RDS-Gateway] The operation 'Get-WindowsFeature' succeeded: RDS-Gateway
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Test     ]  [[WindowsFeature]RDS-Gateway]  in 0.2490 seconds.
VERBOSE: [BGSP-45-GATE]: LCM:  [ Skip   Set      ]  [[WindowsFeature]RDS-Gateway]
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Resource ]  [[WindowsFeature]RDS-Gateway]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Resource ]  [[WindowsFeature]RDS-Web-Access]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Test     ]  [[WindowsFeature]RDS-Web-Access]
VERBOSE: [BGSP-45-GATE]:                            [[WindowsFeature]RDS-Web-Access] The operation 'Get-WindowsFeature' started: RDS-Web-Access
VERBOSE: [BGSP-45-GATE]:                            [[WindowsFeature]RDS-Web-Access] The operation 'Get-WindowsFeature' succeeded: RDS-Web-Access
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Test     ]  [[WindowsFeature]RDS-Web-Access]  in 0.2330 seconds.
VERBOSE: [BGSP-45-GATE]: LCM:  [ Skip   Set      ]  [[WindowsFeature]RDS-Web-Access]
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Resource ]  [[WindowsFeature]RDS-Web-Access]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Resource ]  [[WindowsFeature]RDS-Connection-Broker]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Test     ]  [[WindowsFeature]RDS-Connection-Broker]
VERBOSE: [BGSP-45-GATE]:                            [[WindowsFeature]RDS-Connection-Broker] The operation 'Get-WindowsFeature' started: RDS-Connection-Broker
VERBOSE: [BGSP-45-GATE]:                            [[WindowsFeature]RDS-Connection-Broker] The operation 'Get-WindowsFeature' succeeded: RDS-Connection-Broker
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Test     ]  [[WindowsFeature]RDS-Connection-Broker]  in 0.2790 seconds.
VERBOSE: [BGSP-45-GATE]: LCM:  [ Skip   Set      ]  [[WindowsFeature]RDS-Connection-Broker]
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Resource ]  [[WindowsFeature]RDS-Connection-Broker]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Resource ]  [[WindowsFeature]RDS-RD-Server]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Test     ]  [[WindowsFeature]RDS-RD-Server]
VERBOSE: [BGSP-45-GATE]:                            [[WindowsFeature]RDS-RD-Server] The operation 'Get-WindowsFeature' started: RDS-RD-Server
VERBOSE: [BGSP-45-GATE]:                            [[WindowsFeature]RDS-RD-Server] The operation 'Get-WindowsFeature' succeeded: RDS-RD-Server
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Test     ]  [[WindowsFeature]RDS-RD-Server]  in 0.2350 seconds.
VERBOSE: [BGSP-45-GATE]: LCM:  [ Skip   Set      ]  [[WindowsFeature]RDS-RD-Server]
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Resource ]  [[WindowsFeature]RDS-RD-Server]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Resource ]  [[Script]Add-GatewayServer]
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Test     ]  [[Script]Add-GatewayServer]
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Add-RDServer'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Add-RDSessionHost'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Add-RDVirtualDesktopToCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Disable-RDVirtualDesktopADMachineAccountReuse'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Disconnect-RDUser'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Enable-RDVirtualDesktopADMachineAccountReuse'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Export-RDPersonalVirtualDesktopAssignment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDAvailableApp'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDCertificate'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDConnectionBrokerHighAvailability'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDDeploymentGatewayConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDFileTypeAssociation'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDLicenseConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDPersonalVirtualDesktopAssignment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDPersonalVirtualDesktopPatchSchedule'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDRemoteApp'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDRemoteDesktop'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDServer'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDSessionCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDSessionCollectionConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDSessionHost'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDUserSession'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktop'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktopCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktopCollectionConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktopCollectionJobStatus'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktopConcurrency'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktopIdleCount'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktopTemplateExportPath'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDWorkspace'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Grant-RDOUAccess'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Import-RDPersonalVirtualDesktopAssignment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Invoke-RDUserLogoff'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Move-RDVirtualDesktop'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDCertificate'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDPersonalVirtualDesktopPatchSchedule'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDRemoteApp'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDSessionCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDSessionDeployment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDVirtualDesktopCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDVirtualDesktopDeployment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDPersonalVirtualDesktopAssignment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDPersonalVirtualDesktopPatchSchedule'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDRemoteApp'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDServer'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDSessionCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDSessionHost'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDVirtualDesktopCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDVirtualDesktopFromCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Send-RDUserMessage'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDActiveManagementServer'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDCertificate'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDClientAccessName'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDConnectionBrokerHighAvailability'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDDatabaseConnectionString'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDDeploymentGatewayConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDFileTypeAssociation'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDLicenseConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDPersonalVirtualDesktopAssignment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDPersonalVirtualDesktopPatchSchedule'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDRemoteApp'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDRemoteDesktop'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDSessionCollectionConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDSessionHost'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDVirtualDesktopCollectionConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDVirtualDesktopConcurrency'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDVirtualDesktopIdleCount'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDVirtualDesktopTemplateExportPath'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDWorkspace'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Stop-RDVirtualDesktopCollectionJob'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Test-RDOUAccess'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Test-RDVirtualDesktopADMachineAccountReuse'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Update-RDVirtualDesktopCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] GateWay Mode = DoNotUse
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] RDS GateWay NOT deployed!
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Test     ]  [[Script]Add-GatewayServer]  in 5.0580 seconds.
VERBOSE: [BGSP-45-GATE]: LCM:  [ Start  Set      ]  [[Script]Add-GatewayServer]
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Performing the operation "Set-TargetResource" on target "Executing the SetScript with the user supplied credential".
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Add-RDServer'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Add-RDSessionHost'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Add-RDVirtualDesktopToCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Disable-RDVirtualDesktopADMachineAccountReuse'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Disconnect-RDUser'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Enable-RDVirtualDesktopADMachineAccountReuse'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Export-RDPersonalVirtualDesktopAssignment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDAvailableApp'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDCertificate'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDConnectionBrokerHighAvailability'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDDeploymentGatewayConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDFileTypeAssociation'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDLicenseConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDPersonalVirtualDesktopAssignment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDPersonalVirtualDesktopPatchSchedule'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDRemoteApp'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDRemoteDesktop'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDServer'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDSessionCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDSessionCollectionConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDSessionHost'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDUserSession'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktop'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktopCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktopCollectionConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktopCollectionJobStatus'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktopConcurrency'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktopIdleCount'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDVirtualDesktopTemplateExportPath'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Get-RDWorkspace'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Grant-RDOUAccess'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Import-RDPersonalVirtualDesktopAssignment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Invoke-RDUserLogoff'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Move-RDVirtualDesktop'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDCertificate'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDPersonalVirtualDesktopPatchSchedule'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDRemoteApp'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDSessionCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDSessionDeployment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDVirtualDesktopCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'New-RDVirtualDesktopDeployment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDPersonalVirtualDesktopAssignment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDPersonalVirtualDesktopPatchSchedule'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDRemoteApp'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDServer'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDSessionCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDSessionHost'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDVirtualDesktopCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Remove-RDVirtualDesktopFromCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Send-RDUserMessage'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDActiveManagementServer'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDCertificate'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDClientAccessName'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDConnectionBrokerHighAvailability'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDDatabaseConnectionString'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDDeploymentGatewayConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDFileTypeAssociation'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDLicenseConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDPersonalVirtualDesktopAssignment'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDPersonalVirtualDesktopPatchSchedule'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDRemoteApp'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDRemoteDesktop'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDSessionCollectionConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDSessionHost'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDVirtualDesktopCollectionConfiguration'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDVirtualDesktopConcurrency'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDVirtualDesktopIdleCount'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDVirtualDesktopTemplateExportPath'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Set-RDWorkspace'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Stop-RDVirtualDesktopCollectionJob'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Test-RDOUAccess'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Test-RDVirtualDesktopADMachineAccountReuse'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Importing function 'Update-RDVirtualDesktopCollection'.
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Server              = BGSP-45-GATE.45ST.BGSHOSTED.COM
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Connection Broker   = BGSP-45-GATE.45ST.BGSHOSTED.COM
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] GatewayExternalFqdn = BGSP-45-GATE.45ST.BGSHOSTED.COM
VERBOSE: [BGSP-45-GATE]:                            [[Script]Add-GatewayServer] Role                = RDS-GATEWAY
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Set      ]  [[Script]Add-GatewayServer]  in 15.4540 seconds.
PowerShell DSC resource MSFT_ScriptResource  failed to execute Set-TargetResource functionality with error message: The term 
'Get-RDDeploymentGatewayConfiguration' 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. 
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : 192.168.58.130
 
VERBOSE: [BGSP-45-GATE]: LCM:  [ End    Set      ]
The SendConfigurationApply function did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : 192.168.58.130
 
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 22.19 seconds

As you can see the function in question is actually getting imported. I have also run variations of this with “Start-Service RDMS” right before the call to Add-RDServer, just to make sure things were in place.

Also - the process is actually successful, and the server does get added. This error just gets in the way of moving forward, and it is not suppressed with -ErrorAction SilentlyContinue.

Can you help me understand what I have done wrong here?
Thanks

It’s always hard to tell with RDS, honestly. If all you need to do is suppress the error, try setting $ErrorActionPreference instead. -ErrorAction wouldn’t work to suppress a “not found” error.