Skip to content

Instantly share code, notes, and snippets.

@kamermans
Created September 29, 2024 03:07
Show Gist options
  • Save kamermans/9862099d51f89cf296a1ebf8fc104ebe to your computer and use it in GitHub Desktop.
Save kamermans/9862099d51f89cf296a1ebf8fc104ebe to your computer and use it in GitHub Desktop.
PuTTY settings and sessions backup and restore for Windows

This set of scripts backs up and restores your PuTTY settings from the Windows registry

Run PuTTY backup

First, open powershell as an administrator

# Adjust the execution policy to run the script
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

# Backup PuTTY data
.\backup.ps1

Run PuTTY restore

First, open powershell as an administrator

# Adjust the execution policy to run the script
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

# Backup PuTTY data
.\backup.ps1
# backup.ps1
$backupFileName = "$(Get-Date -Format 'yyyy-MM-dd')-putty-backup.reg"
$registryPath = "HKCU\Software\SimonTatham\PuTTY"
reg export $registryPath $backupFileName /y
Write-Output "PuTTY registry settings exported to $backupFileName"
# restore.ps1
param (
[string]$backupFileName = $args[0]
)
if (-not $backupFileName) {
Write-Output "Usage: .\Restore-PuttyRegistry.ps1 <backupFileName>"
exit 1
}
if (-not (Test-Path $backupFileName)) {
Write-Output "File '$backupFileName' not found."
exit 1
}
reg import $backupFileName
Write-Output "PuTTY registry settings restored from $backupFileName"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment