09-05-2017, 12:48 PM
I got my script for creating objects in ASG working in an 32bit powershell, with help for this tread:
http://forum.asg-rd.com/showthread.php?t...1#pid46501
But I really need to integrate my script into another 64bit powershell script. So I thought that I could start a 32bit session from within 64bit powershell and work around it that way.
Heres my code:
It all goes well until the Connect-RDEnvironment, here's the error I get:
WARNING: Environment could not be connected.
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.
At line:13 char:1
+ Connect-RDEnvironment -Environment "Test" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (
[Connect-RDEnvironment], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,CloudAdminPSModule.CmdLetEnvironment+RDBaseItemChildsGetCommand
It's the "not running in UserInteractive" part that puzzels me. I tried defining the username and password instead of the -PassThrough option, but still gets the same error.
As I said, when running the script in 32bit powershell, it works and the is no "UserInteractive" like a popup or anything..
Any ideas ?
http://forum.asg-rd.com/showthread.php?t...1#pid46501
But I really need to integrate my script into another 64bit powershell script. So I thought that I could start a 32bit session from within 64bit powershell and work around it that way.
Heres my code:
Code:
# Creating 32bit session
$machineName = [Environment]::MachineName;
$session = New-PSSession -ComputerName $machineName -ConfigurationName Microsoft.PowerShell32
# Scriptblock
$block = {
$workingdir = "C:\Program Files (x86)\ASG-Remote Desktop 2016\"
Set-Location $workingdir
[Environment]::CurrentDirectory = Get-Location -PSProvider FileSystem
$path = $workingdir + "ASGRD-PSAPI.dll"
Add-Type -path $path
[reflection.assembly]::LoadFrom($path) | Import-Module
#Connection to the Environment
Connect-RDEnvironment -Environment "Test" -PassThrough
}
# Running the Scriptblock in the 32bit session
invoke-Command -Session $session -ScriptBlock $block
It all goes well until the Connect-RDEnvironment, here's the error I get:
WARNING: Environment could not be connected.
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.
At line:13 char:1
+ Connect-RDEnvironment -Environment "Test" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (

+ FullyQualifiedErrorId : System.InvalidOperationException,CloudAdminPSModule.CmdLetEnvironment+RDBaseItemChildsGetCommand
It's the "not running in UserInteractive" part that puzzels me. I tried defining the username and password instead of the -PassThrough option, but still gets the same error.
As I said, when running the script in 32bit powershell, it works and the is no "UserInteractive" like a popup or anything..
Any ideas ?