Invoke-Command not running with elevated privilages even though credentials are being passed
We have a server which is acting as a remote desktop connection broker, gateway and host. We want to be able to automate some of our administrative tasks so we don't have to have someone log into the machine. Here is a summary of the issue:
- I can remote into the machine using a set of credentials which have domain administrator privileges. If I run Get-RDRemoteApp from a regular PowerShell window I get the error:
Get-RDRemoteApp : A Remote Desktop Services deployment does not exist on XXXXXXXXX.........
2) I then "Run ISE as Administrator" on the same machine in the same session, and Get-RDRemoteApp returns the list of applications in the collection we have
3) From a different machine, I use Invoke-Command, with the -Credentials passed in, like this:
$password_sec = ConvertTo-SecureString $password -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($admin_user, $password_sec)
$sb =
{
Import-Module RemoteDesktop
Import-Module RemoteDesktopServices
Get-RDRemoteApp -CollectionName
}
Invoke-Command -Credential $cred -ComputerName $server -ScriptBlock $sb
This returns the "Get-RDRemoteApp : A Remote Desktop Services deployment does not exist on XXXXXXXXX........." error. It appears that Invoke-Command is not running with elevated permissions for some reason. I've read that if the credentials of the user passed in have administrative rights, there should be no issue.
Is it possible that there is no way to remotely administrate remote desktop servers?