> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/rdm/knowledge-base/troubleshooting-articles/test-secret-server-access-with-a-powershell-script.md).

# Test secret server access with a PowerShell script

Use the following PowerShell script to verify that a client workstation can connect to Secret Server and perform a basic secret search.

1. Save the code in a file called `searchsecret.ps1`.
2. Change the script as needed to match your Secret Server and username/password/domain.
3. Change the `$searchterm` to match your search.

This will allow you to test the connectivity between your workstation and your Secret Server.

```powershell
$url = 'http<area>://mysecretserver/webservices/sswebservice.asmx'
$username = 'myusername'
$password = 'mypassword'
$domain = 'mydomain'   # leave blank for local users

$searchterm = 'VPN'
$proxy = New-WebServiceProxy -uri $url -UseDefaultCredential

# Get a token for further use by authenticating using username/password.
$result1 = $proxy.Authenticate($username, $password, '', $domain)
if ($result1.Errors.length -gt 0){
$result1.Errors[0]
exit
}
else
{
$token = $result1.Token
}

# search secrets with our searchterm (authenticate by passing in our token)
Write-Host 'Searching for: ' $searchterm
$result2 = $proxy.SearchSecrets($token, $searchterm,$null,$null)
if ($result2.Errors.length -gt 0){
$result2.Errors[0]
}
else
{
Write-Host 'Got search results: ' $result2.SecretSummaries.length

# If you want the data as XML

# $xml = convertto-xml $result2.SecretSummaries -As string -Depth 20

# $xml

$result2.SecretSummaries | ForEach-Object { Write-Host 'SecretId:' $_.SecretId '  Name:' $_.SecretName  ' FolderId:' $_.FolderId }

# if ($result2.SecretSummaries.length -gt 0) {

# $result2.SecretSummaries[0]

# }

}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.devolutions.net/rdm/knowledge-base/troubleshooting-articles/test-secret-server-access-with-a-powershell-script.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
