This post was originally published on this site

I have written about authenticating with the Pure1 REST API, and my PowerShell module in the past:

https://www.codyhosterman.com/2019/01/using-the-pure1-rest-api-part-i-powershell/

One of the issues is that if you followed my default instructions, you would need to run the PowerShell window as an admin to be able to create the connection. The answer–now that I think about it is fairly obvious: non-admin users (or admins not running in admin mode) don’t have security rights to it. Duh!

The internal method used in the cmdlet is GetRSAPrivateKey:

You will see a cryptic error: “Exception calling “GetRSAPrivateKey” with “1” argument(s): “Invalid provider type specified.”

So a couple ways to fix this.

MMC

First in the GUI. Launch MMC, and add/remove snapin and choose certificates. Depending on where your cert is dictates which one you choose. My cert is stored in the personal folder on the local machine group:

Cert:LocalMachinemy6D75482829CBDB7FCF8AADD193A71BB4299AC1BD

You can see my cert here:

So right-click and choose Properties > Manage Private Keys…

Click Add then add the user you want to be able to access the private key.

It defaults to full control, but you do not need that, you can just give read access if you prefer:

Now you can run it without being in admin mode:

PowerShell

If you want to do this in PowerShell, it is fairly simple too. This part does need to be run as admin! But once done, the Pure1 module can be run as a regular user.

Grab your cert:

Then grab the permissions of the key:

Now create the permission. In this case the username is “cody” and I want to provide “read” permissions:

Now apply the new permission:

All good now!