21-02-2018, 06:06 PM
I use an automation tool to deploy servers, this uses NSH scripting which I call powershell scripts from, where required.
I am trying to get the automation to add an RDP connection in to ASG RD 2018.
I have ASGRD 2018 x86 installed and the environment set up, on the server where the powershell script runs, to add the entry in to ASG RD.
The NSH script calls powershell x86 and the .ps1 script, passing the name of the server to it:
The PowerShell script works fine if I run it locally on the server:
However, in our automation tool, when the connection to the environment is attempted, I am getting the following errors:
WARNING: Environment is not connected. Command could not be executed.Connect-RDEnvironment : Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
Any suggestions?
I am trying to get the automation to add an RDP connection in to ASG RD 2018.
I have ASGRD 2018 x86 installed and the environment set up, on the server where the powershell script runs, to add the entry in to ASG RD.
The NSH script calls powershell x86 and the .ps1 script, passing the name of the server to it:
Code:
nexec ${host} cmd /c "C:/Windows/SysWOW64/WindowsPowerShell/v1.0/powershell.exe -inputformat none -ExecutionPolicy Bypass C:/tmp/AddServerToVisionApp.ps1 -server_name $SERVER"
The PowerShell script works fine if I run it locally on the server:
Code:
#0.5 - Testing
param(
[STRING]$Server_Name
)
#establish connection to the correct API dll to import modules
$workingdir = "C:\Program Files (x86)\ASG-Remote Desktop 2018\"
Set-Location $workingdir
[Environment]::CurrentDirectory = Get-Location -PSProvider FileSystem
$path = $workingdir + "ASGRD-PSAPI.dll"
Add-Type -path $path
[reflection.assembly]::LoadFrom($path) | Import-Module
#pass the hostname of the server to $servername
$servername = $Server_Name
#connect to the ASGRD environment
Connect-RDEnvironment -Environment [DELETED SENSITIVE INFO]
# create new connection, the perentitemid can be the root or the id of a subfolder
New-RDBaseItem -ParentItemId 3938b5a5-d1fb-4905-b60b-7fc89184be9c -ItemType Connection -Text $servername
#create path to the item created – must be the full path to the item
$serverpath = Join-Path -path "Connections\IAAS\" -ChildPath $servername
#get the id of the connection created
$serverid = Get-RDBaseItemId -ItemPath $serverpath
#set the destination (address it connects to) to the same as the hostname
Set-RDPropertiesConnection -ItemId $serverid -Destination $servername
However, in our automation tool, when the connection to the environment is attempted, I am getting the following errors:
WARNING: Environment is not connected. Command could not be executed.Connect-RDEnvironment : Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
Any suggestions?