Faster way to retrieve multiple passwords at once

Andy2002aAndy2002a
edited June 8 in CLI

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

  • felix_1pfelix_1p

    Team Member

    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 like op list items --vault <vault> | op get item - --fields .... So far our tests have shown big performance improvements compared to using a shell loop.

  • Andy2002aAndy2002a
    edited June 10

    Thanks! Is there any way to be notified when it is implemented?

  • felix_1pfelix_1p

    Team Member

    I'm happy to comment in this thread once it's implemented.

  • felix_1pfelix_1p

    Team Member

    @Andy2002a We released v1.3.0 today which adds support for standard input to op get item. I hope you like it!

  • @felix_1p thanks this is way faster now!

    Is it possible to return the UUID of an object when using the --fields parameter?

  • felix_1pfelix_1p

    Team Member

    @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 use jq but of course that would make selecting the other fields more complicated.
    I'm sorry.

  • Got it thank you.

  • ag_anaag_ana

    Team Member

    :+1::)

  • rnotrnot
    edited July 22

    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 of jq. 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.

  • BenBen AWS Team

    Team Member

    Those are incredible results, @rnot. Thanks for sharing, as well as for the suggestion re: jp.

    Ben

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file