Jump to content

hakan

Members
  • Content Count

    9
  • Joined

  • Last visited

About hakan

  • Rank
    Newbie

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. It working thanks for great support
  2. Hi it´s V8.2 (Build 8242) and our GenericField1 is used för computername. Sorry I missed the ending brackets, I have thoose in my code } ' Regards Hakan
  3. Hi I got this error when trying to add a password with additional fields: Invoke-Restmethod : [{"errors":[{"message":"Invalid API Call"},{"phrase":"Error = Object reference not set to an instance of an object.}]}] At line:60 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 My code I try to execute is : $ServerName = 'my ServerName' $Title = 'My title' $UserName = 'my UserName' $Description = 'my description' $AccountType = 'MS SQL Server' $jsonData = ' { "PasswordListID":"39", "Title": "'+$ServerName+' '+$Title+'", "GenericField1":'+$ServerName+'", "Description":'+$Description+'", "UserName":"'+$UserName+'", "password":"'+$passwordState+'", "APIKey":"my api key" $PasswordstateUrl = 'https://passwordstate/api/passwords' $result = Invoke-Restmethod -Method Post -Uri $PasswordstateUrl -ContentType "application/json" -Body $jsonData } ' If I remove "GenericField1":'+$ServerName+'", "Description":'+$Description+'", the script is working Thanks hakan
  4. 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 _ -UseDefaultCredentials 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 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 -UseDefaultCredentials 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
×