Copy-RDMSession - WARNING: Invalid connection type

Copy-RDMSession - WARNING: Invalid connection type

avatar

Hi,

I am attempting to split our main vault into independant vault for each root folder.

This is the current script I have to copy the folder structure into the existing vaults:

# Recovering sessions.
Set-RDMCurrentRepository (Get-RDMRepository -Name 'Default')
$Sessions = Get-RDMSession
$RootFolders = ($Sessions | Where-Object{$_.Name -eq $_.Group -and $_.ConnectionType -eq "Group"}).Name
$Folders = $Sessions | Where-Object{$_.ConnectionType -eq "Group" -and $RootFolders -notcontains $_.Name}

# Sorting through the folders.
foreach($RFolder in $RootFolders){
    $ToCopy = $Folders | Where-Object{$_.Group -match "$RFolder\\"}

    # Preparing the sessions for copy.
    $Copy = foreach($Session in $ToCopy){
        $Temp = Copy-RDMSession -PSConnection $Session -IncludePasswordHistory
        $Temp.Group = $Temp.Group.Replace("$RFolder\",'')
        $Temp
    }

    # Moving to the vault.
    Set-RDMCurrentRepository $(Get-RDMRepository -Name $RFolder)

    # Creating the folder structure.
    $Copy | ForEach-Object{New-RDMSession $_}
    Write-Host "$($Copy.Count) folder(s) created."
    Write-Host "Folders copied for: $RFolder"
}


But when running the New-RDMSession command, I get the following warning:

WARNING: Invalid connection type


I've reread the information contained in Get-Help Copy-RDMSession -Full , but I cannot find the reason for the warning.

If you need any more information, feel free to ask.

Best regards,

Alexis De Jaeger

All Comments (5)

avatar

Hello Alexis,

The error is at ($Copy | ForEach-Object{New-RDMSession $_}) line.
New-RDMSession cannot create an entry from a PSConnection object.

What version of the module are you using?
Move-RDMSession allows to move entries to another vault in version 2023.2.0.0, and it is recommnended to use it to do so.
Else, use Set-RDMSession -Session $copy

avatar

Hi Maxime,

I was so focused on on the copy command that I failed to notice I was using the wrong command to apply changes...
I am currently running the 2022.3.1.2 version. Doesn't the PowerShell module update at the same time as the client?

I also need to change the path ('Group' property) of each folder (and in future scripts sessions) prior to moving it, as the 'Rootfolder' no longer exists. Which complicates the move a bit.

My apologies for any obvious questions.

Best regards,

Alexis De Jaeger

avatar

Hello,

The module does not update at the same time as the client. It is recommended to keep the major and minor version (ex: 2022.3.x.x) synced with your RDM version. The module was also renamed to Devolutions.PowerShell since the version 2023.1.0.0.

In your script, replacing your New-RDMSession call with Set-RDMSession should work if the version is previous to 2023.2.0.0.

avatar

Hi Maxime,

Thank you for your answer.
Should I remove the 'RemoteDesktopManager' PowerShell module prior to installing it to avoir conflicts?

I have updated the script in accordance to your suggestion and will be testing it out later today.

Best regards,

Alexis De Jaeger

avatar

Hello Alexis,

Removing the previous module is recommended.
If you encounter a problem, let us know.