Signing back into the Community for the first time? You'll need to reset your password to access your account. Find out more.
Forum Discussion
Former Member
3 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
3 years agoI will give yours a go here in a bit, I DID manage to get things SOMEWHAT working. I have removed the sleep statement in the foreach loop as I was testing it without it this time. I have approximately 4200 entries in this vault in particular I am needing to export from. Supports suggestion was to setup a 1password connect server, but I am not sure that it would work the way I want it to, and the cost for setting it up seems a bit much for the use it would get.
```
function Get-1passworditems {
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)][string]$vault
)
#Create initial set of empty variables/arrays
#Array for exporting the data to excel
$results = @()
#Vault details for worksheet name/id info
$vaultdetails = @()
$vaultdetailsconverted = @()
#Summary items in vault - keys such as ID, type, name, etc
$vaultitems = @()
#Array for the $vaultitem records converted from JSON format
$vaultitemsconverted = @()
#Start process of getting data
#Get Vault Details
Write-Host "Getting Vault info and item list" -ForegroundColor Green
$vaultdetails = op vault get $vault --format=json
$vaultdetailsconverted = $vaultdetails | ConvertFrom-Json
$vaultdetailsconverted
$vaultitems = op item list --vault $vault --categories Login --format=json
$vaultitemsconverted = $vaultitems | ConvertFrom-Json
Write-Host -ForegroundColor Yellow "Items in the data set to parse: $($vaultitemsconverted.count)"
#Start looping through the item details to extract username and password
Write-Host -ForegroundColor Green "Starting to get item details"
foreach($id in $vaultitemsconverted){
$c++
$obj = @()
$item =@()
$obj1 =@()
$username = @()
$password = @()
$item = op item get $id.id --vault $vaultdetailsconverted.id --format=json
$obj = $item | ConvertFrom-Json
foreach($field in $obj.fields){
if($field.id -eq "username"){
$username = $field.value
}elseif ($field.id -eq "password") {
$password = $field.value
}else {
}
}
$obj1 = New-Object psobject -Property @{
Vault_ID = $obj.vault.id
Vault_Name = $obj.vault.name
User_Name = $username
Password = $password
Tags = $id.Tags
Item_ID = $id.ID
Title = $id.Title
}
$results += $obj1
Write-host -ForegroundColor Green "$c of $(($vaultitemsconverted.id).count)"
}
$results | Export-Excel -Path C:\Scripts\Results\1password_vault_info.xlsx -AutoSize -AutoFilter -FreezeTopRow
}
```
You could remove the export-excel part to see if you are getting what I am - I know I tested this on my personal 1password account and was able to retrieve all 150 results in there.