diff --git a/backupBitwarden.ps1 b/backupBitwarden.ps1 index 7c888b9..4e9a9d1 100644 --- a/backupBitwarden.ps1 +++ b/backupBitwarden.ps1 @@ -1,6 +1,6 @@ param ( - [switch]$zip, - [switch]$gpg + [Parameter(ParameterSetName='One',Mandatory=$true)][switch]$zip, + [Parameter(ParameterSetName='One')][switch]$gpg ) # get the date/time for the back filename @@ -49,6 +49,8 @@ $itemsWithAttachments | foreach { $_.attachments | foreach { Write-Verbose "Downloading attachment ($($_.id)) with name $($_.fileName) to $folder." bw get attachment $_.id --itemid $itemID --output "$folder\$($_.fileName)" --session $sessionKey + # just writing a new line + Write-Host " " sleep -Milliseconds 500 } } @@ -58,12 +60,14 @@ $zipFilename = "Bitwarden Backup $dateTime.zip" if ($zip) { Write-Host "Zipping the backup together..." Compress-Archive -Path $PSScriptRoot\*.csv, $PSScriptRoot*.json, $PSScriptRoot\attachments -DestinationPath "$PSScriptRoot\$zipFilename" + + if ($gpg) { + Write-Host "Encrypting the backup zip with your bitwarden password..." + gpg.exe --symmetric --cipher-algo AES256 --digest-algo SHA512 --output "$PSScriptRoot\$zipFilename.gpg" "$PSScriptRoot\$zipFilename" + } } -if ($gpg) { - Write-Host "Encrypting the backup zip with your bitwarden password..." - gpg.exe --symmetric --cipher-algo AES256 --digest-algo SHA512 --output "$PSScriptRoot\$zipFilename.gpg" "$PSScriptRoot\$zipFilename" -} + Remove-Variable -Name * -ErrorAction SilentlyContinue bw logout \ No newline at end of file