I`m attempting to automate deployment of new RD SH 2012 servers, and the following insertion into defined collection via Powershell, but can`t seem to get it to work in unattended mode via Altiris:
import-module RemoteDesktop
$COMP = $env:computername
$DOM = $env:USERDNSDOMAIN
$SRV = $COMP + "." + $DOM
if ("$COMP" -like "RDSH0?") {Add-RDSessionHost -SessionHost $SRV -ConnectionBroker "RDBROKER01.DOMAIN.LAN" -CollectionName "RD_FARM_01"}
if ("$COMP" -like "RDSH2?") {Add-RDSessionHost -SessionHost $SRV -ConnectionBroker "RDBROKER01.DOMAIN.LAN" -CollectionName "RD_FARM_02"}
If executed directly onto the RD SH server, or any other server for a fact, it executes just fine and adds the RDSH server to the designated Collection. The only difference that I see, is that unattended executes via local Admin, while mine is done via Domain Admin. So I modified the script:
$USER = "DOMAIN.LAN\USER"
$PASS = Convertto-securestring "PASSWORD123" -AsPlainText -Force
$Credential = new-object -typename System.Management.Automation.PSCredential ($USER, $PASS)
Invoke-Command -ComputerName RDSH26.DOMAIN.LAN -ScriptBlock {import-module RemoteDesktop; Add-RDSessionHost -SessionHost RDSH26.DOMAIN.LAN -ConnectionBroker "RDBROKER01.DOMAIN.LAN" -CollectionName "RD_FARM_02"} -Credential $Credential
Executing the command from any server with the RD Module, results in the following error:
A Remote Desktop Services deployment does not exist on RDBROKER01.DOMAIN.LAN. This operation can be performed after creating a deployment. For information about creating a deployment, run "Get-Help Set-VDIDeployment" or "Get-Help Set-RDSHDeployment".
All of the required ports are open and the deployment is fully configured.