dsccommunity / xRemoteDesktopSessionHost

This module contains DSC resources for the management and configuration of Microsoft Remote Desktop Session Host (RDSH).
MIT License
35 stars 47 forks source link

xRDGatewayConfiguration fails with Get-RDDeploymentGatewayConfiguration' is not recognized as the name of a cmdlet, function, script file, or operable #97

Open raymonvtu opened 2 years ago

raymonvtu commented 2 years ago

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

Verbose logs showing the problem

Suggested solution to the issue

The DSC configuration that is used to reproduce the issue (as detailed as possible)

Configuration RDS
{
  param (
    [parameter(Mandatory = $true)]
    [string]$MachineName = 'localhost',

    [parameter(Mandatory = $true)]
    [string]$fqdm,

    [parameter(Mandatory = $true)]
    [string]$url,

    [parameter(Mandatory = $true)]
    [string]$thumbPrint
    )

    Import-DscResource -ModuleName xRemoteDesktopSessionHost -ModuleVersion 2.0.0

  Node $MachineName
  {

    LocalConfigurationManager
    {
        RebootNodeIfNeeded = $true
        ConfigurationMode = "ApplyOnly"
    }

    #Install the IIS Role
    WindowsFeature SessionHost {

      Name   = 'RDS-RD-Server'
      Ensure = 'Present'
    }

    #install web access role
    windowsFeature WebAccess {
        name = 'rds-web-access'
        Ensure = 'present'
    }

    windowsFeature broker {
        name = 'rds-connection-broker'
        ensure = 'present'
    }

    windowsFeature gateway {
        name = 'rds-gateway'
        ensure = 'present'
    }
    windowsFeature RDLicensing {
      Name = 'rds-licensing'
      Ensure = 'Present'
    }

    xRDSessionDeployment NewDeployment {

      ConnectionBroker = $fqdm
      SessionHost = $fqdm
      WebAccessServer = $fqdm
      DependsOn = '[windowsFeature]WebAccess'
      }
      xRDSessionCollection collection {

      CollectionName = 'QuickSessionCollection'
      SessionHost = $fqdm
      ConnectionBroker = $fqdm
      DependsOn = '[xRDSessionDeployment]NewDeployment'
      }

      xRDSessionCollectionConfiguration collectionconfig {

      CollectionName = 'QuickSessionCollection'
      ConnectionBroker = $fqdm
      AutomaticReconnectionEnabled = $true
      BrokenConnectionAction = 'Disconnect'
      UserGroup = 'Domain Users'
      DependsOn = '[xRDSessionCollection]collection'
      TemporaryFoldersDeletedOnExit = $true
      SecurityLayer = 'Negotiate'
      EncryptionLevel = 'ClientCompatible'
      AuthenticateUsingNLA = $true
      }

      xRDLicenseConfiguration licenseconfig {

        ConnectionBroker = $fqdm
        LicenseServer = $fqdm
        LicenseMode = 'PerUser'
        DependsOn = '[xRDSessionCollectionConfiguration]collectionconfig'
        }

      xRDGatewayConfiguration GatewayConfig {

        DependsOn = '[xRDSessionCollectionConfiguration]collectionconfig','[windowsFeature]gateway'
        ConnectionBroker = $fqdm
        GatewayServer = $fqdm
        GatewayMode = 'Custom'
        LogonMethod = 'Password'
        UseCachedCredentials = $true
        BypassLocal = $false
        ExternalFqdn = $url
      }

      script CustomScript {

        DependsOn = '[xRDGatewayConfiguration]GatewayConfig','[WindowsFeature]broker'
        GetScript            =  { return @{result = 'result'} }
        TestScript           = { return $false }
        SetScript            = {
          Import-Module -Name RemoteDesktop -Global
          $roles=@(
          'RDWebAccess'
          'RDPublishing'
          'RDRedirector'
          'RDGateway'
          )

          foreach($role in $roles){

            Set-RDCertificate -role $role -Thumbprint $using:thumbPrint  -ConnectionBroker $using:fqdm -force
          }
      }
    }
  } 
}

The operating system the target node is running

Version and build of PowerShell the target node is running

Version of the DSC module that was used

johlju commented 2 years ago

Maybe similar to the issue https://github.com/dsccommunity/xRemoteDesktopSessionHost/issues/79. Maybe it is solved by adding -Global when importing the module RemoteDesktop.

raymonvtu commented 2 years ago

Maybe similar to the issue #79. Maybe it is solved by adding -Global when importing the module RemoteDesktop.

I fixed this problem a while ago and forgot I had this open. Adding Global when importing the module was indeed the fix

johlju commented 2 years ago

The all resources should probably import it using Global. Keep this open until it is fixed for this resource and the others as well.