support Posted March 20, 2022 Share Posted March 20, 2022 Topic: In this forum post we'll describe how you can update multiple records with the same password, by using a Password Reset Dependency and a Powershell API script. Passwordstate has the ability to copy and link password records between two Password Lists, but this means everything with these two records is identical, including the username. If you have some requirement to have the same password to log into two different systems, but with different usernames, this forum post will guide you how to do this. First, let's take a look at these two Password Records. Our goal here is to trigger a reset on "Passwordstate Service Account" record, and then have our API script automatically update the "Passwordstate Sharepoint Account" password to be the same value. Take note of the PasswordID for this second record: Now, let's browse to the Powershell Password Resets page: Add a new Blank Script: And then click on this new script to open the editor. Paste in the code of your choice. The code in this screenshot below will be copied in at the end of this post for your reference. In the screenshot below, you can see you have a number of Variables you can insert into your script. These values are pulled directly from the master Password Record, and in this example, I'll be using the [NewPassword] variable. This just means, when the password for the master record is reset through the User Interface, then that new password it is reset to will be passed to your script: We'll now add in a new Password Reset Dependency on the master record: Click the Add Dependency button: And select the Custom Script you wrote. Also, ignore the Windows Account Dependency type, and Save this config: The Master Password now has "1" dependency, and triggering a Password Reset on this master record will proceed as per normal and queue up the reset. In this example, it's also going to reset the password for the account in Active Directory: Once the master password has successfully reset, it will trigger your Powershell API Script, which in turn triggers a new password reset on the Sharepoint account: And the end result of the two successful Password Resets, means these two separate accounts, will have the same password: Powershell Code to Update an Existing Password, using the Standard API (Requires API Key) $PasswordstateUrl = "https://passwordstate.clickdemo.com" # Define values for the Password List in below array $Body = @{ PasswordID = "1045" Password = [NewPassword] } # Convert Array to Json $jsonData = $Body | ConvertTo-Json # Execute the command $FullUrl = "$PasswordstateUrl/api/passwords" Invoke-Restmethod -Method Put -Uri $FullUrl -ContentType "application/json" -Body $jsonData -Header @{ "APIKey" = "8c5423d3e9a7bf6ad6cf8e457392b3d6" } Regards, Support Mordecai 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now