Created
May 26, 2020 14:32
-
-
Save ecspresso/7d9df4fc706f306ca2b3735dcc29a0b9 to your computer and use it in GitHub Desktop.
Autoupdate KeePassOTP for KeePass (for any version of PowerShell edition)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$updateurl = 'https://firebasestorage.googleapis.com/v0/b/rookiestyle-43398.appspot.com/o/versioninfo.txt?alt=media&token=89da60c0-f331-4334-94bb-0dccf617818f' | |
$iwr = (New-Object System.Net.WebClient).DownloadString($updateurl) | |
$version = ($iwr.split() | Select-String '^KeePassOTP') -replace 'KeePassOTP:','' | |
if(-not (Test-Path -Path 'HKCU:\Software\keepass')) { | |
New-Item -Path 'HKCU:\Software\keepass' -ItemType Directory | |
} | |
try { | |
$keepassotp = (Get-ItemProperty -Path 'HKCU:\Software\keepass\' -Name 'keepassotp' -ErrorAction Stop).keepassotp | |
} catch { | |
New-ItemProperty -Path 'HKCU:\Software\keepass\' -Value 0 -PropertyType String -Name 'keepassotp' | |
$keepassotp = (Get-ItemProperty -Path 'HKCU:\Software\keepass\' -Name 'keepassotp' -ErrorAction Stop).keepassotp | |
} | |
if($keepassotp -ne $version) { | |
& "${env:ProgramFiles(x86)}\KeePass Password Safe 2\KeePass.exe" --exit-all | |
(New-Object System.Net.WebClient).DownloadString('https://netix.dl.sourceforge.net/project/keepassotp/KeePassOTP.plgx') | Out-File "${env:ProgramFiles(x86)}\KeePass Password Safe 2\Plugins\KeePassOTP.plgx" | |
Set-ItemProperty -Path 'HKCU:\Software\keepass\' -Name 'keepassotp' -Value $version | |
& "${env:ProgramFiles(x86)}\KeePass Password Safe 2\KeePass.exe" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment