hakan Posted February 7, 2018 Share Posted February 7, 2018 Hi, Is it possible to sync Active Directory with Passwordstate? If I create a Service Account with a specific name like svc_[SERVERNAME] or if the service account is in a specific group in AD, then automatically add a entry in passwordstate with the accountname, password and other information? Or do anyone know how to add entries via script (Powershell, TSQL) ? Regards Hakan Link to comment Share on other sites More sharing options...
Sarge Posted February 7, 2018 Share Posted February 7, 2018 10 hours ago, hakan said: If I create a Service Account with a specific name like svc_[SERVERNAME] or if the service account is in a specific group in AD, then automatically Sure is. Refer to page 213 of the user manual. https://www.clickstudios.com.au/downloads/version8/Passwordstate_User_Manual.pdf 10 hours ago, hakan said: Or do anyone know how to add entries via script (Powershell, TSQL) ? You can also do it via PowerShell using Passwordstates REST API. Outdated documentation, but still relevant: https://clickstudios.com.au/downloads/version6/API/ support 1 Link to comment Share on other sites More sharing options...
support Posted February 8, 2018 Share Posted February 8, 2018 Thanks again Sarge, Just wanted to point out that updated API documentation can be found under your Help Menu in Passwordstate - look for Web API Documentation. If this is the path you want to take, and you need any help with this, we're happy to assist. i'm sure between the little community we have we can come up with some examples:) Regards, Support Link to comment Share on other sites More sharing options...
hakan Posted February 8, 2018 Author Share Posted February 8, 2018 Hi What I want is to add a new Service Account in Active Directory, the Password State automatically find the new Service Account and add an entry with Title, Username, Password in correct Password List. Is that possible? Regards, Hakan Link to comment Share on other sites More sharing options...
hakan Posted February 8, 2018 Author Share Posted February 8, 2018 Hi again if I trying with WEB API: # PowerShell Request #JSON data for the object $jsonData = ' { "PasswordListID":"96", "Title":"North American Core Router 1", "UserName":"narouter1", "Password":"StenS-Lun#3$2yc" } ' $PasswordstateUrl = 'https://passwordstate/winapi/passwords' $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData -UseDefaultCredentials I got folling error: Invoke-Restmethod : [{"errors":[{"message":"Invalid API Call"},{"phrase":"Error = Object reference not set to an instance of an object.}]}] At line:14 char:15 + ... $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -Co ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand -UseDefaultCredentials : The term '-UseDefaultCredentials' 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. At line:15 char:33 + -UseDefaultCredentials + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (-UseDefaultCredentials:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Thanks Hakan Link to comment Share on other sites More sharing options...
support Posted February 8, 2018 Share Posted February 8, 2018 Hello, Can you tell me if the parameter -UseDefaultCredentials is on the same line as Invoke-Restmethod? We can't show it on the same line in our documentation without causing display issues. Regards Click Studios Link to comment Share on other sites More sharing options...
Sarge Posted February 9, 2018 Share Posted February 9, 2018 9 hours ago, hakan said: What I want is to add a new Service Account in Active Directory, the Password State automatically find the new Service Account and add an entry with Title, Username, Password in correct Password List. Is that possible? Yes, but the password will need to be reset by Passwordstate first. Since AD passwords aren't decryptable Passwordstate has no way to determine what the password is without it being reset. 9 hours ago, hakan said: The term '-UseDefaultCredentials' is not recognized as the name of a cmdlet As Support said, there's a line break in your code causing the argument to be interpreted as a cmdlet. This is what we use... #GET REQUIRED PASSWORDS FROM PASSWORDSTATE API $PwdStateURL = 'https://passwordstate.domain.com.au/api/passwords/777' $ExecutePwdStateCall = Invoke-Restmethod -Method GET -Uri $PwdStateURL -Header @{ "APIKey" = "abc123abc123abc123abc123abc123" } [string]$script:user = $ExecutePwdStateCall.Username [string]$script:pass = $ExecutePwdStateCall.Password Link to comment Share on other sites More sharing options...
hakan Posted February 9, 2018 Author Share Posted February 9, 2018 hi first thanks allot for your help so far. Yes I just copy the script from the homepage so the -UseDefaultCredentials was on its own row. Have tried to use it on the same row but got following errer: # PowerShell Request #JSON data for the object $jsonData = ' { "PasswordListID":"96", "Title":"North American Core Router 1", "UserName":"narouter1", "password":"StenS-Lun#3$2^yc" } ' $PasswordstateUrl = 'https://passwordstate.[Domain].[com]/winapi/passwords' $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData -UseDefaultCredentials The error: Invoke-Restmethod : [{"errors":[{"message":"Invalid API Call"},{"phrase":"Error = Object reference not set to an instance of an object.}]}] At line:14 char:15 + ... $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -Co ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand Regards Hakan Link to comment Share on other sites More sharing options...
Sarge Posted February 9, 2018 Share Posted February 9, 2018 36 minutes ago, hakan said: cannot be found that accepts argument '_'. The code you've posted doesn't contain any underscore (_) characters; so I assume the underscore (_) character is in your $PasswordstateUrl variable which you've modified here for privacy? If that's the case, try wrapping the URL in quotation marks instead. $PasswordStateURL = "https://passwordstate/winapi/passwords" Link to comment Share on other sites More sharing options...
hakan Posted February 9, 2018 Author Share Posted February 9, 2018 Hi Sarge I did removed the underscore because when I had it i´ve got the following error : About the $PasswordStateURL = "https://passwordstate/winapi/passwords" I used it like this and i dont know if it´s right: About the $PasswordStateURL = "https://passwordstate.domain.com/winapi/passwords" , because i don´t have any passwords folder under winapi in IIS The code with underscore(_): # PowerShell Request #JSON data for the object $jsonData = ' { "PasswordListID":"96", "Title":"North American Core Router 1", "UserName":"narouter1", "password":"StenS-Lun#3$2^yc" } ' $PasswordstateUrl = 'https://passwordstate.domain.com/winapi/passwords' $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData _ -UseDefaultCredentials The Error with underscore (_): Invoke-RestMethod : A positional parameter cannot be found that accepts argument '_'. At line:14 char:15 + ... $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -Co ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Invoke-RestMethod], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeRestMethodCommand Regards Håkan Link to comment Share on other sites More sharing options...
support Posted February 9, 2018 Share Posted February 9, 2018 Hi Hakan, There is not meant to be any underscore. What I don't understand is your post above without the underscore, seems to give the exact same error as the post with the underscore. Are you sure you posted the correct error for that initial one? Regards Click Studios Link to comment Share on other sites More sharing options...
hakan Posted February 9, 2018 Author Share Posted February 9, 2018 Hi in the WIN API help for add Passwords there is an _ between -Body $jsonData and -UseDefaultCredentials, am I doing this all wrong ? This is the error with underscore: (all the blue is rund in powershell ISE with admin rights on database server) # PowerShell Request #JSON data for the object $jsonData = ' { "PasswordListID":"96", "Title":"North American Core Router 1", "UserName":"narouter1", "password":"StenS-Lun#3$2^yc" } ' $PasswordstateUrl = "https://passwordstate.[domain].[com]/winapi/passwords" $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData _ -UseDefaultCredentialsInvoke-RestMethod : A positional parameter cannot be found that accepts argument '_'. At line:14 char:15 + ... $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -Co ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Invoke-RestMethod], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeRestMethodCommand And this is the error without underscore: (all the blue is rund in powershell ISE with admin rights on database server) # PowerShell Request #JSON data for the object $jsonData = ' { "PasswordListID":"96", "Title":"North American Core Router 1", "UserName":"narouter1", "password":"StenS-Lun#3$2^yc" } ' $PasswordstateUrl = "https://passwordstate.[domain].[com]/winapi/passwords" $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData -UseDefaultCredentialsInvoke-Restmethod : [{"errors":[{"message":"Invalid API Call"},{"phrase":"Error = Object reference not set to an instance of an object.}]}] At line:14 char:15 + ... $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -Co ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand Regards Hakan Link to comment Share on other sites More sharing options...
support Posted February 9, 2018 Share Posted February 9, 2018 Hi Hakan, As mentioned, no underscore should be used - we only have this in our documentation to show a line break where the command is too wide to fit into the documentation page. I've just tested your script above, and it works fine for me. Can you go to the Help menu in Passwordstate, click on the 'Web API Documentation' menu, and then on the 'Windows Integrated API Documentation' button. Does this page error for you? If so, then whoever upgraded your Passwordstate instance did not follow the upgrade instructions. To fix this, Open the User Manual from the Help menu Go to the KB Articles section and look for 'Configure WinAPI After Version 8 Upgrade' This will show you what configuration is required. Also, and I'm sure you're aware of this, you can only use the WinAPI from a Windows machine, and you must have an account in Passwordstate which matches the account you are logged onto Windows with. We hope this helps. Regards Click Studios 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