I have a script which I can run locally on our ConnectionBroker, though the session has to be elevated, which manages our RDRemoteApp collections. We're trying to automate processes and remote the requirement of having someone actually log onto the ConnectionBroker to run scripts manually. To do so, we are trying to use Invoke-Command to run the script remotely.
Even though we pass credentials for a user that is in domain administrator group, the following script gives us an error when run remotely:
$server = "ConnectionBrokerName"
$password = ConvertTo-SecureString "password" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ("DOMAIN\domain_admin", $password)
Get-RDRemoteApp -CollectionName $Using:$collectionName
Invoke-Command -Credential $cred -ComputerName $server -ScriptBlock $sb
This will return an error like:
A Remote Desktop Services deployment does not exist on ConnectionBrokerName.DOMAIN.COM. This operation can be performed after creating a deployment. For information about creating a
deployment, run "Get-Help New-RDVirtualDesktopDeployment" or "Get-Help New-RDSessionDeployment".
- CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
- FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-RDRemoteApp
- PSComputerName : ConnectionBrokerName