Jump to content

Recommended Posts

Posted

Dear Chris,

 

I'm here fighting with exact same issue.

Already upgraded to build 8519 - still import returns the same...

Would you mind to share the latest version of your ps script here?

Thanks in advance.


Cheers!

-Andrii

Posted

Here I've broken out the function - I call it with a line in a foreach that loops through a pre-built array of records:

 

Add-PWSRecord $record.list $record.title $record.UserName $record.AccountType $record.Password $record.url

 

of course assuming that $globalapi is set to your global anon api key and that $pwsurl is set to your TLD (everything between "https://" and "/api/passwords")

 

function Add-PWSRecord {
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory = $true,Position = 0)]
        [ValidateNotNullOrEmpty()][string]$body_listID,
        [Parameter(Mandatory = $true,Position = 1)]
        [ValidateNotNullOrEmpty()][string]$body_title,
        [Parameter(Mandatory = $true,Position = 2)]
        [ValidateNotNullOrEmpty()][string]$body_username,
        [Parameter(Mandatory = $true,Position = 3)]
        [ValidateNotNullOrEmpty()][string]$body_accounttype,
        [Parameter(Mandatory = $true,Position = 4)]
        [ValidateNotNullOrEmpty()][string]$body_pw,
        [Parameter(Position = 5)][string]$body_url
    )
    $body= @{
PasswordlistID = $body_listID
Title = $body_title
UserName = $body_username
AccountType = $body_accounttype
Password = $body_pw
URL = $body_url
APIKey = $globalapi
    }
    $jsonPasswordData = $body | ConvertTo-Json

    $uri = "https://$pwsurl/api/passwords"

    $result= Invoke-Restmethod -Method Post -Uri $uri -ContentType "application/json; charset=utf-8" -Body $jsonPasswordData
    $output= 0
}

 

It helped in my testing to construct a $body manually (I use ninite.com/vscode for a sandbox instead of ISE) and run the Invoke-Restmethod command manually with it - allowed me to test better without having to keep resetting my .csv source file.

 

if you can get a manual one to land but not using your script, post it up here.  I'll be glad to look.. I'm no expert, but I may see something.. and if not, there's much better resources around than me!

 

Cheers!

-Grib

 

Posted
1 minute ago, Chris Gribbin said:

Here I've broken out the function

 

Btw - I did this because there's no way you want to sort through my giant mess to get to the invoke- command..  I'm also in the middle of a full re-write using some of the advise support gave me and a few new tricks I learned during my troubleshooting to find the bug.

Posted

Hey guys,

1st of all: sorry my late response.

So, what did worked for me, after I upgraded to build 8519:

 - create a folder with administrative account;

 - import with a different, non-administrative account;

 - convert a Folder Permission model to propogate down permissions, and added a Administrative account to the list.

 - now I can look through the password lists, and see all the entries.

 

In all other scenarios I still get the DB error (described in the initial post).

 

Cheers,

Andrii

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...