For the complete documentation index, see llms.txt. This page is also available as Markdown.

Test Secret Server access with a PowerShell script

When a Delinea Secret Server entry cannot authenticate or does not return any secrets, testing the connection outside of Remote Desktop Manager shows whether the problem comes from the workstation, the network, or the Secret Server account. Remote Desktop Manager communicates with Secret Server through its REST API: it requests an OAuth2 token from <Secret Server URL>/oauth2/token, then queries <Secret Server URL>/api/v1/secrets. The following PowerShell script performs the same two calls.

  1. Save the code below in a file called searchsecret.ps1.

  2. Replace the values of $url, $username, $password, and $domain with your Secret Server URL and credentials.

  3. Replace the value of $searchterm with the name, or part of the name, of a secret you can access.

  4. Run the script from the workstation where Remote Desktop Manager is installed.

$url = 'https://mysecretserver/SecretServer'
$username = 'myusername'
$password = 'mypassword'
$domain = 'mydomain'   # leave blank for local users

$searchterm = 'VPN'

# Request an OAuth2 token with the username and password.
$loginName = if ($domain) { "$domain\$username" } else { $username }
$body = @{
    username   = $loginName
    password   = $password
    grant_type = 'password'
}

try {
    $token = (Invoke-RestMethod -Method Post -Uri "$url/oauth2/token" -Body $body -ContentType 'application/x-www-form-urlencoded').access_token
}
catch {
    Write-Host 'Authentication failed:' $_.Exception.Message
    exit
}

# Search secrets with the search term, authenticating with the token.
Write-Host 'Searching for:' $searchterm
$headers = @{ Authorization = "Bearer $token" }
$query = 'filter.searchText=' + [uri]::EscapeDataString($searchterm)

try {
    $result = Invoke-RestMethod -Method Get -Uri "$url/api/v1/secrets?$query" -Headers $headers
    Write-Host 'Got search results:' $result.records.Count
    $result.records | ForEach-Object { Write-Host 'SecretId:' $_.id '  Name:' $_.name '  FolderId:' $_.folderId }
}
catch {
    Write-Host 'Search failed:' $_.Exception.Message
}

If the script authenticates and returns your secrets, the workstation can reach Secret Server, and the issue is in the configuration of the entry in Remote Desktop Manager. If the script fails, the error message points to the network, certificate, or account problem to solve on the Secret Server side.

If your Secret Server account requires two-factor authentication, the token request fails unless you add the one-time code in an OTP header, as Remote Desktop Manager does.

See also

Last updated

Was this helpful?