I am trying to automate my RDS deployment and everything is working good except when it needs to configure session collection settings. This is the error that comes up all the time.
This is the resource that is failing : xRDSessionCollectionConfiguration
PowerShell DSC resource MSFT_xRDSessionCollectionConfiguration failed to execute Set-TargetResource functionality wi
th error message: Failed to lookup RD Session Collection RDS. Error: Exception calling “.ctor” with “1” argument(s): "
Invalid parameter "
What this means Failed to lookup RD Session Collection RDS. There is nothing wrong with the collection. It is available, I can see it in Server Manager, but one thing I notice. When I run Get-RDSessionCollection I receive ResourceType as RemoteApp which is wrong. In servermanger it says Remote Desktop and it should be Remote Desktop because I didn’t publish remote apps. I think that it something wrong with the xRDSessionCollectionConfiguration Resource. I tried 5 times on fresh installed and updated computers. Can someone please tell me how to get more info on this error. Google does not say anything and event viewer tells me exactly the same thing. So I am lost.
I’m not familiar with that resource or this service, but here’s what I’d try:
what if you comment out line 184, or remove the ErrorAction Stop: does that configure your collection? Giving you more clues?
If, after running your DSC Config (even if it fails where you said), the RDSessionCollection is present, does running Get-RDSessionCollection -CollectionName 'RDS' works? If yes then what if you just restart the machine and run the same DSC configuration again? Something tells me that when you run the config the Get-RDSessionCollection might not work straight away. It could be a timing issue (too soon) or session issue (need a refresh)...
Obviously very hard to troubleshoot without having access to your env… Good luck!
Thank you for the reply. I found the issue. Issue is in RDSessionCollection resource. This resource needs to be modified and updated so that works for all users and with standard deployment. In the Get-TargetResource he has “SessionHost” = $localhost and in the Test-TargetResource he is calling the get-targetresource and if we don’t have $localhost this will never work. I checked his example on github and he has this variable $localhost = [System.Net.Dns]::GetHostByName((hostname)).HostName. If we don’t specify this, session host server will never be discovered and you will receive that strange issue. I modified that resource and changed settings in Get-TargetResource and Set-TargetResource and now everything is working as it should. I deleted all $localhost variables and modified the code. I will go through all RDS resources and modify them if I find more issues.
P.S. I will write about this issue on my site so that other users know what to do.