Hi, we needed a quicker way to interact with LastPass credentials besides actually logging in and collecting the data, which we tried and had a number of issues and mixed results.
We installed lastpass cli library with cygwin and once everything was in place, ran the necessary commands through Cygwin command prompt, and managed to get a specific account’s saved username and password.
Next we tried it on Powershell and Command Prompt, and besides some minor changes in the prompts/commandlets, they still worked. The below are what we’re using to manually login and request the password from a particular account saved in our lastpass account, so we know they are working manually.
cd cygwin64\bin
.\lpass login lastpass@email.com --trust
[lastpass master pass]
.\lpass show “[lastpass credential name]” --password
Now, in order to use the within an automation, we ended up splitting the above code and testing it in parts. We saved it in .txt files and tested/ran it in parts to see if we can get it to work, and even tested it manually before moving forward.
The parts are the login part first:
[cd ‘C:\cygwin64\bin’
.\lpass login [lastpass@email.com] --trust
[lastpass master password]
]
And the credential request:
[cd ‘C:\cygwin64\bin’
$CurrentPass = .\lpass show “[lastpass credential name]” --password
]
When we open Powershell, and copy paste the above prompts in full, it is working, logging in, then credential fetching.
When we manually login, and then just run a UiPath process using Invoke Powershell command with the password fetching commands, the process is collecting the password and saving it in a variable.
Also, as you can see from the above 2 parts, they are both saved with a [new line]/Enter at the end, as without it, the commands do not work properly, both manually and through UiPath. We are also ticking the IsScript option in the properties, and also tested passing and receiving parameters from the script, which did work for us, as I mentioned the second part did work properly on its own.
Our issue is the login part. When we run that script through the Invoke Powershell activity, we are getting the below error:
Please enter the LastPass master password for [lastpass@email.com].
NotSpecified: (:String) , RemoteException
Master Password: Error: Failed to enter correct password.
The term ‘[lastpass master password]’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Attached is a screenshot from the activity’s properties.
After seeing the above error, we tried to pass the password as a paramter. We were trying with the password directly as it worked manually and to try the simplest version first. So we changed the script to the below:
[Param(
[Parameter(Mandatory=$true)]
[string]$Master_Pass
)
cd ‘C:\cygwin64\bin’
.\lpass login [lastpass@email.com] --trust
$Master_Pass
]
Properties for the above:
We’re getting the below error after running the above:
Please enter the LastPass master password for [lastpass@email.com].
NotSpecified: (:String) , RemoteException
Master Password: Error: Failed to enter correct password.