# get the date/time for the back filename $dateTime = get-date -format ("yyyyMMdd-HHmmss") $env:Path += ";$PSScriptRoot\lib" bw config server https://bitwarden.johnhgaunt.com if ($sessionKey -eq $null) { $username = Read-Host "Please enter your bitwarden email" $password = Read-Host -assecurestring "Please enter your bitwarden password" $password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password)) $code = Read-Host "Please enter your 2fa code (hit enter if not used)" if ($code -eq "") { $sessionKey = $(bw login $username $password --raw) } else { $sessionKey = $(bw login $username $password --method 0 --code $code --raw) } } #convertfrom-json $(bw list organizations --session $sessionKey) Write-Host "Exporting vault to both CSV and JSON files." bw export $password --output "$PSScriptRoot\Bitwarden User $username Export $dateTime.csv" --format csv --session $sessionKey bw export $password --output "$PSScriptRoot\Bitwarden User $username Export $dateTime.json" --format json --session $sessionKey Write-Host "Looking for Organizations..." $organizations = $(convertfrom-json $(bw list organizations --session $sessionKey)) Write-Host "Found $(($organizations | measure).count) Organiztaions." # (convertfrom-json $(bw list items --session $sessionKey)) | where attachments # $itemsWithAttachments | % { $folder=$_.name; $itemID=$_.id; $_.attachments | % { bw get attachment $_.id --itemid $itemID --output "C:\Users\jgaunt\3D Objects\Bitwarden\$folder\$_.fileName" --session $sessionKey; sleep -Milliseconds 500 } } # bw get attachment $attachmentID --itemid $itemID --output $file --session $sessionKey