RemoteDesktopServices module wont load as soon as the server is a DC (2012R2)

John Worth 96 Reputation points
2020-11-05T14:14:39.747+00:00

Getting rid of an SBS2011 setup for a charity, making use of their 2012R2 license, currently migrating services to the 2012R2 box, but RD Gateway is sucking my will to live.

Loading the PS module RemoteDesktopServices throws an error ONLY once the server had been promoted to a domain controller. Demoting, removing Active Directory Domain Services then re-installing RD Gateway gets the module working again. Why can I not load the module once the server is a DC? I have RD Gateway and this module working on many other sites on DC's.

I even spun up another 2012R2 vm and set it up again from scratch, same deal, literally the second it becomes a DC the module wont load.

'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\RemoteDesktopServices\TSPSProvider.dll'.
Import-Module : An error occurred attempting to create an instance of the provider 'RemoteDesktopServices'.
At line:1 char:1

  • Import-Module RemoteDesktopServices -verbose -force
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : ObjectNotFound: (RemoteDesktopServices:String) [Import-Module], ProviderNotFoundExceptio
    n
  • FullyQualifiedErrorId : ProviderCtorException,Microsoft.PowerShell.Commands.ImportModuleCommand
Remote Desktop
Remote Desktop
A Microsoft app that connects remotely to computers and to virtual apps and desktops.
4,499 questions
{count} votes

Accepted answer
  1. John Worth 96 Reputation points
    2020-11-06T12:59:43.78+00:00

    Fixed my own problem by sidestepping the RemoteDesktopServices module.

    @Anonymous thanks for that input, I'm 100% confident that would have been a working answer, however in my case I didn't want to spin up a second host for the minimal use RDGateway I needed.

    making use of the WMI route in PS I was able to assign the cert to the RDGateway service:

    # Gets us the incoming cert details from Certify  
    param($result)  
      
    # Thumbprint of the new certificate  
    $newCertHash=($result.ManagedItem.CertificateThumbprintHash)  
      
    # Convert to byte array  
    $ByteArray = ($newCertHash -Split "(?<=\G\w{2})(?=\w{2})" | ForEach {[Convert]::ToByte($_,16)})  
      
    # Set certificate via WMI because RemoteDesktopServices module is a pile of shite  
    $wmi = (Get-WmiObject -Class "Win32_TSGatewayServerSettings" -Namespace "root\cimv2\terminalservices")  
    $wmi.SetCertificate($ByteArray)  
      
    # Restart RD Gateway Service  
    Restart-Service TSGateway  
    
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2020-11-05T14:21:40.927+00:00

    A better option is to clean install the operating system, patch fully, add hyper-v role only on host. Stand up two virtual machines, one for active directory domain services, other as RDS / application server.

    --please don't forget to Accept as answer if the reply is helpful--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.