-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ps1
31 lines (22 loc) · 1.02 KB
/
configure.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Add-Type -AssemblyName System.Windows.Forms
function promptForDbFilePath {
$dialog = New-Object -TypeName System.Windows.Forms.OpenFileDialog
$dialog.title = "Select KeepassXC database file"
$dialog.filter = "KeepassXC database files (*.kdbx)|*.kdbx"
$result = $dialog.ShowDialog((New-Object System.Windows.Forms.Form -Property @{TopMost = $true }));
if ($result -eq "OK") {
return $dialog.filename;
}
return $null;
}
Write-Host "Select KeepassXC database file"
$dbFilePath = promptForDbFilePath
if ([string]::IsNullOrEmpty($dbFilePath)) {
Write-Host "No KeepassXC db file selected"
exit -1;
}
$password = Read-Host -AsSecureString "Enter password for selected database"
$passwordEncrypted = $password | ConvertFrom-SecureString;
$configFilePath = "$PSScriptRoot\config.json"
@{ dbFilePath = $dbFilePath; passwordEncrypted = $passwordEncrypted } | ConvertTo-Json -depth 100 | Out-File $configFilePath
Write-Host Generated configuration file: $configFilePath