Skip to main content
January 26, 2022
Question

List all Guest Users

  • January 26, 2022
  • 6 replies
  • 150 views

Hi Support,

I am trying to list:
1. all Guest users
2. All Active Users
3. All Users
4. All Guest Users and Vaults that they have access to

All Active Users:
op list users | jq -c '.[] | select(.state | contains("A"))'
jq: error: A/0 is not defined at , line 1:
.[] | select(.state | contains(A))
jq: 1 compile error

All Guest Users:
op list users | jq -c '.[] | select(.type | contains("R"))'
jq: error: R/0 is not defined at , line 1:
.[] | select(.type | contains(R))
jq: 1 compile error


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided

6 replies

February 7, 2022

Hey @PeterCharleston ,

The jq commands you are using where the state's value is wrapped in double quotes (eg. contains("A")) looks good to me, I tried it on my machine and it works as well.

Would you be able to validate the output of the op list users command to ensure that it's a properly formatted JSON object?

February 8, 2022

Hi Justin

Which version of CLI and jq are you using?

the command produce arrays in Powershell 5.1

$opsUsersState = op list users | jq -c '.[] | select(.state)'
PS C:\Users\PeterCharleston> $opsUsersState.GetType()

IsPublic IsSerial Name BaseType


True True Object[] System.Array

$opsUserList = op list users | jq -c '.[]'
PS C:\Users\PeterCharleston> $opsUSerList.GetType()

IsPublic IsSerial Name BaseType


True True Object[] System.Array

I can get specific values like email:

$listOfEmails = $(op list users | jq -r '.[] | .email')
PS C:\Users\PeterCharleston> $listOfEmails.GetType()

IsPublic IsSerial Name BaseType


True True Object[] System.Array

February 10, 2022

Hi Justin

Which version of CLI and jq are you using?

the command produce arrays in Powershell 5.1

$opsUsersState = op list users | jq -c '.[] | select(.state)'
PS C:\Users\PeterCharleston> $opsUsersState.GetType()

IsPublic IsSerial Name BaseType


True True Object[] System.Array

$opsUserList = op list users | jq -c '.[]'
PS C:\Users\PeterCharleston> $opsUSerList.GetType()

IsPublic IsSerial Name BaseType


True True Object[] System.Array

I can get specific values like email:

$listOfEmails = $(op list users | jq -r '.[] | .email')
PS C:\Users\PeterCharleston> $listOfEmails.GetType()

IsPublic IsSerial Name BaseType


True True Object[] System.Array

February 10, 2022

Hey @PeterCharleston

Here are the commands that you can use to get the following results:
- get all Guest users

op list users | jq -c '.[] | select(.type == \"G\")'

  • get all Active users

    op list users | jq -c '.[] | select(.state == \"A\")'

  • get all users

    op list users | jq -c '.[]'

  • get all Guest users and the vaults they have access to

    \> $users = (op list users | jq -r '.[] | select(.type == \"G\").email')
    \> foreach ($u in $users) {op list vaults --user $u}

The trick is to escape the quotation marks in the command. For example, "G" becomes \"G\". This discrepancy is present in Powershell.

February 11, 2022

Hey Eddy

that is awesome thanks

I was trying to escape with ` before but not working.

I had written a horrible script which got the job done but this is tons better

regards
Peter

February 11, 2022

Glad to hear that it worked out! :smile: