Script repository

Processed approval requests initiated during the last X days

Updated on: Jan 18, 2026, Views: 4666

Approval requests

The script outputs the list of approved, denied or cancelled requests for operations initiated during the last X days. When prompted, specify the credentials of the Adaxes service account (entered during the software installation).

Parameters

  • $daysNumber - Specifies the number of days to search for.
  • $state - the state of the requests to output. Can be 1 (approved requests), 2 (denied requests), or 3 (canceled requests).
Import-Module Adaxes

$daysNumber = 30 # TODO: modify me
$state = 1 # TODO: modify me

$admNS = New-Object("Softerra.Adaxes.Adsi.AdmNamespace")
$admService = $admNS.GetServiceDirectly("localhost")

# Prompt for credentials.
$credential = Get-Credential

# Bind to the 'Approval Requests' container.
$containerPath = $admService.Backend.GetConfigurationContainerPath("ApprovalRequests")
$searcher = $admService.OpenObject($containerPath.ToString(), $credential.UserName, $credential.GetNetworkCredential().Password, 0)

# Set search parameters.
$startDateTime = ((Get-Date).AddDays(-$daysNumber)).ToFileTime()
$searcher.SearchFilter = "(&(objectCategory=adm-ApprovalRequest)(adm-ApprovalState=$state)(adm-ApprovalRequestCreationTime>=$startDateTime))"
$searcher.PageSize = 500
$searcher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"

try
{
    # Execute search.
    $searchResult = $searcher.ExecuteSearch()

    # Iterate through the requests.
    foreach ($requestId in $searchResult.FetchAll())
    {
        $request = $admService.OpenObject($requestId.AdsPath, $credential.UserName, $credential.GetNetworkCredential().Password, 0)

        Write-Host "Date: " $request.CreationDate
        Write-Host "Operation:" $request.DescriptionOfOperationToApprove
        Write-Host "ProcessedBy:" $request.ProcessedBy.Get("name")
        Write-Host "Requestor:" $request.Requestor.Get("name")
        Write-Host
    }
}
finally
{
    $searchResult.Dispose()
}

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    We use cookies to improve your experience.
    By your continued use of this site you accept such use.
    For more details please see our privacy policy and cookies policy.