import-module remotedesktop remotely

I am trying to do something I feel should be simple but coming up against a barrier in everything I’ve tried.

We have a RemoteApp deployment. I want to run a job every morning to check if “NewConnectionAllowed” is true or false on each host.

import-module remotedesktop $collection = get-rdsessioncollection $collection | foreach-object {get-rdsessionhost -collectionname $_.collectionname} 

This runs fine locally on the remoteapp gateway, RAGTW01

When I run the below from a remote server

invoke-command -Credential $Credential -ComputerName RAGTW01 { import-module remotedesktop $collection = get-rdsessioncollection $collection | foreach-object {get-rdsessionhost -collectionname $_.collectionname} } 

It tells me “A Remote Desktop Services deployment does not exist on RAGTW01” I’ve tried doing it in a scriptblock. I’ve tried new-pssession. How do I get this to work? For awhile I gave up and said I’ll just query the database for this info, but it doesn’t seem to exist in the database. I’m guessing it just polls the hosts to see if they’re accepting new connections.

Anyone have any ideas how I can get this information remotely? Thanks,

submitted by /u/TammyK
[link] [comments]

Leave a Reply