BigDaddyO Posted November 9, 2016 Posted November 9, 2016 My company has dictated that I can no longer use KeePass command line to retrieve credentials for my automated testing and I'm to use secretserver from thycotic. Secret Server is a web based application that can only be automated from a WebAPI. I have never done this type of thing with AutoIT and I'm not sure where to start. I have been sent the generic How-To get started link but it's all PowerShell: https://thycotic.force.com/support/s/article/REST-API-PowerShell-Scripts-Getting-Started How would I either: a. Convert the powershell script into AutoIT. (This is what I would prefer) or b. Launch the Powershell script from AutoIT and retrieve the values back into AutoIT. Below are the examples from that website. 2 - Windows Authentication $api = "http:// <secret server url>/api/v1" $endpoint = "$api/secrets/3844" $secret = Invoke-RestMethod $endpoint -UseDefaultCredentials 3 - Searching Secrets expandcollapse popuptry { $api = "http:// <secret server url>/api/v1" $tokenRoute = "http:// <secret server url>/oauth2/token"; $creds = @{ username = "< user name >" password = "< password >" grant_type = "password" } $token = "" $response = Invoke-RestMethod $tokenRoute -Method Post -Body $creds $token = $response.access_token; #Write-Host $token $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add("Authorization", "Bearer $token") $filters = "?filter.HeartbeatStatus=1&filter.includeRestricted=true&filter.searchtext=< mySearchText >" Write-Host "------------------------------" Write-Host "----- Secret Search Values -----" Write-Host "------------------------------" #?filter.searchfields=username&filter.searchfields=displayname&filter.searchfields=filter.searchText=mister&filter.includeinactive=true" -Headers $headers $result = Invoke-RestMethod "$api/secrets$filters" -Headers $headers Write-Host $result.filter.searchFields Write-Host $result.total foreach($secret1 in $result.records) { Write-Host $secret1.id" - "$secret1.name" - "$secret1.folderId - $secret1.lastHeartBeatStatus } Write-Host "------------------------------" Write-Host "----- Secret Lookup Values -----" Write-Host "------------------------------" #?filter.searchfields=username&filter.searchfields=displayname&filter.searchfields=filter.searchText=mister&filter.includeinactive=true" -Headers $headers $result = Invoke-RestMethod "$api/secrets/lookup$filters" -Headers $headers Write-Host $result.filter.searchFields Write-Host $result.total foreach($secret in $result.records) { Write-Host $secret.id" - "$secret.value } Write-Host "------------------------------" } catch [System.Net.WebException] { Write-Host "----- Exception -----" Write-Host $_.Exception Write-Host $_.Exception.Response.StatusCode Write-Host $_.Exception.Response.StatusDescription $result = $_.Exception.Response.GetResponseStream() $reader = New-Object System.IO.StreamReader($result) $reader.BaseStream.Position = 0 $reader.DiscardBufferedData() $responseBody = $reader.ReadToEnd() | ConvertFrom-Json Write-Host $responseBody.errorCode " - " $responseBody.message foreach($modelState in $responseBody.modelState) { $modelState } } Thanks in advance for any help you can provide. Mike
Danyfirex Posted November 9, 2016 Posted November 9, 2016 Hello. You can handle REST API using WinHttp UDF. About second option there are many examples in forum about get powershell output. do a forum search. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
junkew Posted November 9, 2016 Posted November 9, 2016 I was helped with this FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
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