Forum / Remote Desktop Manager - PowerShell Repository

Creating New Sessions from VMware vRO Workflow

  • Create an Issue
  • Cancel

I setup a VMWare vRO workflow to call the PowerShell script on a remote Windows servers and run into an issue when trying to create a new session. The same script works fine when it's ran locally on the Windows server using the same AD service account vRO is using. Anything special I need to do when when making a remote PS call?

7/14/2017 8:16:41 AM [Line# 329] Get-RDMDataSource -Name MOXRdm
7/14/2017 8:16:44 AM [Line# 337] ConvertTo-SecureString
7/14/2017 8:16:44 AM [Line# 341] Set-RDMCurrentDataSource -ID 3385fd55-ba20-4a76-b37d-181d6d42981d -Username svc.vRA.rw@infinitecampus.com -Password $securesvcpass
7/14/2017 8:16:44 AM [Line# 353] Get-RDMSession -Name westco-app001
7/14/2017 8:16:44 AM [Line# 384] Create a new session for westco-app001
7/14/2017 8:16:44 AM [Line# 390] Initialize the session type
7/14/2017 8:16:44 AM [Line# 396] Initialize the session type
7/14/2017 8:16:44 AM [Line# 402] New-RDMSession -Host westco-app001 -Type RDPConfigured -Name westco-app001 -Group ccc
7/14/2017 8:16:44 AM [Line# 404] Error: Failed New-RDMSession -Host westco-app001 -Type RDPConfigured -Name westco-app001 -Group ccc -> System.Management.Automation.CmdletInvocationException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Devolutions.RemoteDesktopManager.Managers.AddOnManager.AddOnServiceProvider.CreateNewConnection(String name, String host, String group, String template, ConnectionKind kind)
at RemoteDesktopManager.AddOn.AddOnServices.CreateNewConnection(String name, String host, String group, String template, ConnectionKind kind)
at RemoteDesktopManager.PowerShellModule.NewRDMSessionCommand.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
--- End of inner exception stack trace ---
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
7/14/2017 8:16:44 AM [Line# 674] Found issue and broke out

Sample code extracted from my script:


$datasource = $null;
$msgstr = $null;
$securesvcpass = $null;

#Get the data source to use
Write-MOXLog ("[Line# " + (Get-MOXCurrentLineNumber) + "] Get-RDMDataSource -Name $remoteDataSourceName");
try { $datasource = Get-RDMDataSource -Name $remoteDataSourceName -ErrorAction Stop }
catch { $msgstr = "Error: Failed to get datasource $remoteDataSourceName -> $($_.Exception.Messagee)" Write-MOXLog ("[Line# " + (Get-MOXCurrentLineNumber) + "] $msgstr"); $issueFound = $true }


#set the retrieved datasource as the current datasource
if ($issueFound -eq $false)
{
Write-MOXLog ("[Line# " + (Get-MOXCurrentLineNumber) + "] ConvertTo-SecureString");
try { $securesvcpass = ConvertTo-SecureString $($cred.svcpwd) -asplaintext -force -ErrorAction Stop }
catch { $msgstr = "Error: Failed ConvertTo-SecureString -> $($_.Exception.Messagee)" Write-MOXLog ("[Line# " + (Get-MOXCurrentLineNumber) + "] $msgstr"); $issueFound = $true }

Write-MOXLog ("[Line# " + (Get-MOXCurrentLineNumber) + "] Set-RDMCurrentDataSource -ID $($datasource.ID) -Username $($cred.svcacct) -Password `$securesvcpass");
try { Set-RDMCurrentDataSource -ID $datasource.ID -Username $($cred.svcacct) -Password $securesvcpass -ErrorAction Stop }
catch { $msgstr = "Error: Failed Set-RDMCurrentDataSource -> $($_.Exception.Messagee)" Write-MOXLog ("[Line# " + (Get-MOXCurrentLineNumber) + "] $msgstr"); $issueFound = $true }
}

if ($issueFound -eq $false)
{
Write-MOXLog ("[Line# " + (Get-MOXCurrentLineNumber) + "] New-RDMSession -Host $($([string]$rs.DEVICENAME).ToLower()) -Type $sessionType -Name $($([string]$rs.DEVICENAME).ToLower()) -Group $($([string]$rs.CLOUDTYPE).ToLower())");
try { $session = New-RDMSession -Host $($([string]$rs.DEVICENAME).ToLower()) -Type $sessionType -Name $($([string]$rs.DEVICENAME).ToLower()) -Group $($([string]$rs.CLOUDTYPE).ToLower()) -ErrorAction Stop -ErrorVariable errmsg }
catch { $msgstr = "Error: Failed New-RDMSession -Host $($([string]$rs.DEVICENAME).ToLower()) -Type $sessionType -Name $($([string]$rs.DEVICENAME).ToLower()) -Group $($([string]$rs.CLOUDTYPE).ToLower()) -> $($errmsg)" Write-MOXLog ("[Line# " + (Get-MOXCurrentLineNumber) + "] $msgstr"); $issueFound = $true }
}

if ($issueFound -eq $false)
{
Write-MOXLog ("[Line# " + (Get-MOXCurrentLineNumber) + "] Set-RDMSession -Session `$session -Refresh");
try { Set-RDMSession -Session $session -Refresh -ErrorAction Stop }
catch { $msgstr = "Error: Failed New-RDMSession -> $($_.Exception.Messagee)" Write-MOXLog ("[Line# " + (Get-MOXCurrentLineNumber) + "] $msgstr"); $issueFound = $true }
}

Clock3 yrs

Hello,

The PS Remote calls are difficult to handle and support because this involves a lot of configurations that can not be simply connected directly to our product.
This is why we have created synchronizers like the Active Directory Synchronizer or the VMWare Synchronizer.
Does one of these tools can help you to create your entries?

About your script, do you run it as an administrator?
When you run it locally, is it the same user profile as when you run it remotely?

Best regards,



Érica Poirier

signaturesignature

Clock3 yrs

The account used to run the script locally and remotely are the same account and has a profile setup on the remote system. I am currently working on work around by using a schedule task to run locally on the remote system with the designated AD service account that's used to run the scheduled task.

Clock3 yrs