Users

All Posts (5)

avatar

ying

Creating New Sessions from VMware vRO Workflow

avatar
avatar
avatar

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.

Creating New Sessions from VMware vRO Workflow

avatar
avatar
avatar

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 }

}

Get-RDMSession is not returning my sessions consistently on Windows 2016 server

avatar
avatar
avatar

Thanks Erica, that seemed to do the trick on all the systems.

Get-RDMSession is not returning my sessions consistently on Windows 2016 server

avatar
avatar
avatar

Issue does not appear to be limited to just Windows 2016. Able to duplicate issues on Windows 2012 R2 server also. Notice that Win 8.1 now behaving the same and not pull any data also. The original PowerShell ISE session can on the windows 8.1 box is still pull all the sessions from the SQL db though.

Get-RDMSession is not returning my sessions consistently on Windows 2016 server

avatar
avatar
avatar

running on RDM ver: 12.5.4.0

using remote SQL 2014 database

using AD credential to connect to SQL database

AD credential has Administrator permissions

PowerShell version on Windows 2016

Major Minor Build Revision

----- ----- ----- --------

5 1 14393 1066

same code seems to be working consistently on Windows 8.1

PowerShell version on Windows 8.1

Major Minor Build Revision

----- ----- ----- --------

5 0 10586 117

$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 }

}

Get-RDMCurrentDataSource

$Lists = Get-RDMSession -IncludeSubFolders

$Lists.count

1 - 5 of 5 items