It’s Cybersecurity Awareness Month! Join our interactive training session, or learn about security and AI from 1Password experts.
Forum Discussion
Former Member
4 years agoExport specific data from vault
Hello, any help would be greatly appreciated on this. I have to export a list of logins from a specific Vault as part of a divestiture with the company I work for. I have been attempting to pull th...
Former Member
4 years agoHey there @jwilson5607
I've gotten your script to work locally with some modifications, but Instead of exporting to Excel, I just printed the fields of interest, as I don't have that specific Export-Excel
module on my Windows test device.
function Get-1passworditems {
[CmdletBinding()]
param ([Parameter(Mandatory=$true)][string]$vaultuuid)
#Ensure variables are empty and ready to go
$results = @()
$data = @()
$item = @()
$vault = @()
#Get Initial list of item uuids
$results = op item list --vault $vaultuuid --format=json
Write-Host ($results)
$vault = op vault get $vaultuuid --format json
Write-Host ($vault)
$vaultObj = $vault | ConvertFrom-Json
Write-Host ("vaultName: " + $vaultObj.name)
#Convert from JSON to powershell objects
$data = $results | ConvertFrom-Json
foreach($item in $data){
Start-Sleep -Seconds 1
$name = op item get $item.id --vault $vaultuuid --field username
Write-Host ("name: " + $name + " uuid: " + $data.id + " title: " + $data.title)
}
}
Some things I modified are:
- the $vault = op vault get $vaultuuid
should specify the --format json
flag
- the $vault
output should be converted from JSON to access its name in subsequent commands
With these changes I am able to output the vault name, item username, item id, and item title.
As for the error you encountered, I have a feeling that could be caused by continuous execution of op
commands after one of them has returned an error, please do let me know if you keep seeing it.