Forum / Remote Desktop Manager - PowerShell Repository

Programmatically changing the SSH recording file name

  • Create an Issue
  • Cancel

A customer needed to standardize the recording file name for ALL of his entries. The result is below. Note that it makes use of a Global Variable at the system level ($LOGROOT$) for the root of the path, a great real-life example of that feature.

It also uses a standardized way of organizing entries using typed folders. $COMPANY_NAME$ will go up the parenting chain of the entry looking for a folder of the COMPANY sub-type, then take the NAME field of that folder.

cls;
Write-Host;
Write-Host "Fixing SSH sessions"
Write-Host;
$PuttySessions = Get-RDMSession | where {$_.Kind -eq "Putty"}
foreach ($session in $PuttySessions)
{
if (![string]::IsNullOrEmpty($session.Putty.RecordingFileName))
{
Write-Host (" Processing : " + $session.Name);
$session.Putty.RecordingFileName = '$LOGROOT$\$COMPANY_NAME$\Configurations\$NAME$-$DATE_TEXT_ISO$-$TIME_TEXT_ISO$.txt';
Set-RDMSession $session;
}
}
Write-Host;
Write-Host "DONE!"
Write-Host;



Maurice Côté

signaturesignature

Clock5 yrs

Just to add that this changes the value only when one had been set. If you want to do this to ALL of your putty sessions you must remove the

if (![string]::IsNullOrEmpty($session.Putty.RecordingFileName))
and corresponding accolades.



Maurice Côté

signaturesignature

Clock5 yrs

Maurice,
Thanks for this!

If we are using SSH sessions or Telnet sessions, would we substitute Putty for "SSH Shell" or "Telnet" respectively?

Clock5 yrs

I answered my own question. When I ran Get-RDMSession | where {$_.Kind -eq "Putty"} it returned my list of sessions but, when I replaced Putty with Telnet or SSH Session, it came back blank.

Clock5 yrs

I saved this script to a file and then ran it inside the powershell in RDM and it worked!

It should be noted for those of you not well versed in PowerShell (like me) that you will need to run:

Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

Then I was able to run the script I saved to my desktop.

Thanks again Maurice!

Clock5 yrs