KNOWLEDGE PORTAL

Pulling a User Account

Summary

**Do not use in production environment without professional assistance**

When working with Secret Server it is important to know what groups and roles a user is part of. This information can be pulled using the below API. 

To view this script on the Cyberhill Github page, click here.


Function Get-SSUserById {
    Param
    (
         [Parameter(Mandatory=$true, Position=0)]
         [string] $URI,
         [Parameter(Mandatory=$true, Position=1)]
         [string] $APIKey,
         [Parameter(Mandatory=$true, Position=2)]
         [int] $UserID,
         [Parameter(Mandatory=$False, Position=3)]
         [boolean] $includeInactive = $False
    )

    try
    {
    $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
    $headers.Add("Authorization", "Bearer $APIKey")
    $URI = "$URI/api/v1/users/$UserID" + "?" + "includeInactive=$includeInactive"
    
    $secrets = Invoke-RestMethod $URI -Method Get -Headers $headers
    return $secrets
    }
    catch
    {
        $result = $_.Exception.Response.GetResponseStream();
        $reader = New-Object System.IO.StreamReader($result);
        $reader.BaseStream.Position = 0;
        $reader.DiscardBufferedData();
        $responseBody = $reader.ReadToEnd() | ConvertFrom-Json
        Write-Host "ERROR: ($responseBody.error)"
        return;
    }
} 
You might also be interested in
Notes from the Hill image
What Most Industries Are Still Missing About Generative AI
The flashiest part of AI is the output—but the heavy lifting happens before that. When I meet with teams trying to scale AI, the same core gaps come up over…
LEARN MORE
Folder Information
When creating a folder, it is just as important to know what the API is looking for as it is to be able to make the API call to create…
LEARN MORE
Getting a Token for Use With the API
To start using the API you need to get a token. There are a few ways to do this.
LEARN MORE