PortValhalla/scripts/Windows/Software/PuTTY/Install.ps1

30 lines
1,016 B
PowerShell
Raw Normal View History

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) {
Write-Host "Backing up PuTTY";
$tempDir = $context.GetTempDirectory();
2023-06-08 00:28:33 +00:00
$fileName = Join-Path "$tempDir" $configFile;
& reg export "HKCU\Software\SimonTatham" "$fileName" /y;
$context.Backup($tempDir, $context.SoftwareArchive($softwareName));
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
}