Sort Vault Items by Revision Date Using the CLI

OK, it’s a bit challenging for me to debug this, because I don’t have the CLI installed myself, so I can’t do my own testing. I did find a site that showed sample output of the bw list items command:

[{"object":"item","id":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa","organizationId":null,"folderId":null,"type":1,"reprompt":0,"name":"post-test","notes":null,"favorite":false,"login":{"username":"ryan","password":"terrible-password","totp":null,"passwordRevisionDate":null},"collectionIds":[],"revisionDate":"2021-11-30T11:44:25.846Z"}]

Using this, I am able to reproduce your results (i.e., it apparently doesn’t work).

I conclude that either the format of the output of the bw list items CLI command or the behavior of the ConvertFrom-Json PowerShell commandlet has changed since March, or perhaps @Chris_Magnuson proposed the above command sequence on the theory that it would work, but without actually testing it.

Hopefully, someone with more experience using the CLI (and/or PowerShell) can step in to debug this further.

Update (2023-01-30):

@snovvman The code originally proposed by @Chris_Magnuson can be fixed by inserting “.\” before the “bw” command, by using parentheses to enclose the expression “.\bw list items | ConvertFrom-Json”, and by removing the parameter “-Descending” from the sorting command. The top post has now been edited to incorporate these corrections. In addition, alternative PowerShell expressions have been proposed below (here and here).

1 Like