Faster way to retrieve multiple passwords at once
I'm trying to find the easiest/fastest way to retrieve multiple items with a password at once in PowerShell.
Right now I'm doing the following:
- List all of the items in a vault
- $All1PassItems += Invoke-Expression "$OnePassAppPath list items --vault $Vault 2>&1" | ConvertFrom-Json (this is fast)
- Run a loop that retrieves the password for each item
- $PWitems = Invoke-Expression "$OnePassAppPath get item $($ItemUUID) --fields username,password,notesPlain,title,url" -ErrorAction Stop | ConvertFrom-Json (this in a loop is slow)
This works well and it gives me what I need, but it's super slow because it has to run a query for each individual item. Is there a more efficient way to do this?
1Password Version:1.0
_Extension Version: Not Provided
OS Version: Not Provided
Sync Type: Not Provided
Comments
-
Not yet but there will be "soon" :smile: We are working on better support for pipelining so that e.g. you can pipe a list of items (or item UUIDs) to
get item
. You will be able to do something likeop list items --vault <vault> | op get item - --fields ...
. So far our tests have shown big performance improvements compared to using a shell loop.0 -
Thanks! Is there any way to be notified when it is implemented?
0 -
I'm happy to comment in this thread once it's implemented.
0 -
@Andy2002a We released v1.3.0 today which adds support for standard input to
op get item
. I hope you like it!0 -
@Andy2002a Not yet unfortunately. We haven't decided yet how exactly we want this work. E.g. I could imagine that "internal" fields like UUID would be specified as
@uuid
instead...
For now you'd have to usejq
but of course that would make selecting the other fields more complicated.
I'm sorry.0 -
Got it thank you.
0 -
:+1: :)
0 -
Just came here to say how much I appreciate this new functionality in v1.3.0 of the CLI tool. Being able to get multiple items at once has increased the speed of our automation scripts by about 3x. So much better now, keep up the good work!
On a side note, I'm partial to using
jp
instead ofjq
.jp
(jmespath.org) is used in Ansible's built-in json_query filter, and I find that much more easier to build queries than jq.EDIT: My 3x remark was the whole script. If you look just at the step where we get items from 1Password, that was reduced from 336 seconds to 45 seconds.
0