2023-07-12 20:37:31 +00:00
|
|
|
#!/bin/pwsh
|
2024-08-07 19:05:32 +00:00
|
|
|
. "$PSScriptRoot/../../../Common/Scripts/Context.ps1";
|
2023-06-07 19:57:00 +00:00
|
|
|
|
2023-06-08 00:28:33 +00:00
|
|
|
$null = New-Module {
|
|
|
|
$softwareName = "PuTTY";
|
|
|
|
$configFile = "$($softwareName).reg";
|
|
|
|
|
2023-06-30 10:19:54 +00:00
|
|
|
function Backup-PuTTY([Context] $context) {
|
2023-06-30 12:23:20 +00:00
|
|
|
Write-Host "Backing up PuTTY";
|
2023-06-16 18:25:43 +00:00
|
|
|
$tempDir = $context.GetTempDirectory();
|
2023-06-08 00:28:33 +00:00
|
|
|
$fileName = Join-Path "$tempDir" $configFile;
|
|
|
|
& reg export "HKCU\Software\SimonTatham" "$fileName" /y;
|
2023-08-01 01:34:56 +00:00
|
|
|
$context.Backup($tempDir, $context.SoftwareArchive($softwareName));
|
2023-06-16 18:25:43 +00:00
|
|
|
Remove-Item -Recurse $tempDir;
|
2023-06-08 00:28:33 +00:00
|
|
|
}
|
2023-07-02 13:16:24 +00:00
|
|
|
|
|
|
|
function Restore-PuTTY([Context] $context) {
|
|
|
|
Write-Host "Restoring PuTTY";
|
|
|
|
Write-Information "Installing PuTTY";
|
|
|
|
choco install -y putty;
|
|
|
|
|
|
|
|
Write-Information "Restoring configuration";
|
|
|
|
$tempDir = $context.GetTempDirectory();
|
|
|
|
$fileName = Join-Path "$tempDir" $configFile;
|
|
|
|
$context.Restore($context.SoftwareArchive($softwareName), $tempDir);
|
2023-08-06 20:36:04 +00:00
|
|
|
& reg import "$fileName";
|
2023-07-02 13:16:24 +00:00
|
|
|
Remove-Item -Recurse $tempDir;
|
|
|
|
}
|
2023-06-07 19:57:00 +00:00
|
|
|
}
|