Start a new topic

Import all saved Putty Sessions to RoyalTS

Hi,


as the support told me, there is a function to import saved Putty Sessions.
Now, it would be great to import all saved Putty Sessions to RoyalTS at once.


regards,

Benedikt


1 person likes this idea

Hi Benedikt,


sorry for the late reply! Actually we do have such functionality on our roadmap. But I can't offer any ETA yet.


Regards,

Patrik

Is this available yet ?

Hi Terence,


unfortunately not. It had been pushed back all the time because this topic wasn't very active. I will keep this open to see if there's an increase of interest. I guess most people with a huge amount of sessions probably just wrote a small powershell script to import all the sessions.


Regards,
Stefan

 Just in case it's useful to anyone i adapted the RoyalTS tutorial doc to work with a SuperPutty Sessions file.
Just export from SuperPutty to sessions.xml or whatever and use this scr1pt.

 It assumes you have installed the RoyalDocument.PowerShell module into your session.

param(
    [string]$SuperPuttyFile = ".\Sessions.XML",
    [string]$OutFileName = "outputcsv.rtsz"
)

function CreateRoyalFolderHierarchy() {
    param(
        [string]$folderStructure,
        [string]$splitter,
        $Folder
    )
    $currentFolder = $Folder

    $folderStructure -split $splitter | % {
        $folder = $_
        $existingFolder = Get-RoyalObject -Folder $currentFolder -Name $folder -Type RoyalFolder
        if ($existingFolder) {
            Write-Verbose "Folder $folder already exists - using it"
            $currentFolder = $existingFolder
        }
        else {
            Write-Verbose "Folder $folder does not exist - creating it"
            $newFolder = New-RoyalObject -Folder $currentFolder -Name $folder -Type RoyalFolder
            $currentFolder = $newFolder
        }
    }
    return $currentFolder
}

if(Test-Path $OutFileName) {Remove-Item $OutFileName}

[xml]$xml = Get-Content -Path $SuperPuttyFile
$store = New-RoyalStore -UserName "PowerShellUser"
$doc = New-RoyalDocument -Store $store -Name "Powershell import from CSV" -FileName $OutFileName

$xml.ArrayOfSessionData.SessionData | ForEach-Object {
    $server = $_
    Write-Host "Importing $($server.Name)"

    $count = $server.SessionId -split "/"
    $sessionFolder = ($server.sessionID -split "/")[0..($count.count - 2)] -Join "/"
    $lastFolder = CreateRoyalFolderHierarchy -folderStructure $sessionFolder -Splitter  "\/" -Folder $doc

    $newConnection = New-RoyalObject -Folder $lastFolder -Type RoyalSSHConnection -Name $server.SessionName
    $newConnection.URI = $server.Host
}
Out-RoyalDocument -Document $doc -FileName $OutFileName
Text

 

Thanks for sharing, Richard! Much appreciated!

Login or Signup to post a comment