Powershell: Get-RDMSession: Connection not found

Powershell: Get-RDMSession: Connection not found

avatar
joffrey
Disabled

Hi,

I make a simple loop :

 Get-RDMRepository |  ?{($_.Name -notlike '*XXX*') -and ($_.Name -notlike '*Temp*')} |% {
	Set-RDMCurrentRepository $_
	$s = get-RDMSession | ?{ $_.Name -like '*staging*'}
}

But, on many repository, I get this error:

Get-RDMSession : Connection not found.


Any idea please ??
Thanks you

'Joffrey

All Comments (4)

avatar

Hello,

The Set-RDMRepository cmdlet is used to save the modification of any vault properties.
Please use instead Set-RDMCurrentRepository to switch to another vault and then add the Update-RDMUI cmdlet right after that cmdlet like the following.

Set-RDMCurrentRepository $_
Update-RDMUI


Best regards,

Érica Poirier

avatar

Hmm.. check my code. I use Set-RDMCurrentRepository
I added Update-RDMUI, no change:

 Get-RDMRepository |  ?{($_.Name -notlike '*XXX*') -and ($_.Name -notlike '*Temp*')} |% {
	Set-RDMCurrentRepository $_
	Update-RDMUI
	$s = get-RDMSession | ?{ $_.Name -like '*staging*'}
}


result:

get-RDMSession : Connection not found.
At C:\ps1\rdm_staging.ps1:7 char:7
+     $s = get-RDMSession | ?{ $_.Name -like '*staging*'}
+          ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-RDMSession], Exception
    + FullyQualifiedErrorId : 0,RemoteDesktopManager.PowerShellModule.GetRDMSessionCommand


I don't have this error on all Repo

avatar

Hello,

According to the error message, it seems that some of the vaults do not contain sessions with staging as part of the session's name. You could trap these errors with the try-catch code block like this.

Get-RDMRepository |  ?{($_.Name -notlike '*XXX*') -and ($_.Name -notlike '*Temp*')} |% {
	Set-RDMCurrentRepository $_
	Update-RDMUI
    try {
    	$s = get-RDMSession | ?{ $_.Name -like '*staging*'} -ErrorAction Stop
    }
    catch {

    }
}


Best regards,

Érica Poirier

avatar

I tested your code (and add the Name of the current repo):

I checked all repos with the error. The Staging (it's a group) exists. Some are empty, and some not..
I don't understand

rdm_staging1.png