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.

Script Repository

Delete all denied approval requests

September 24, 2021 Views: 542

The script deletes all the approval requests that were denied. The script should be executed in Windows PowerShell on the computer where Adaxes service is installed. When prompted, specify the credentials of the Adaxes service account.

Edit Remove
PowerShell
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Prompt for credentials.
$credential = Get-Credential

# Connect to the Adaxes service
$admNS = New-Object("Softerra.Adaxes.Adsi.AdmNamespace")
$admService = $admNS.GetServiceDirectly("localhost")

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

# Get all denied approval requests
$requests = $container.GetApprovalRequests("ADM_APPROVALSTATE_DENIED")

# Delete the requests
foreach ($requestID in $requests)
{
    # Bind to the approval request
    $guid = New-Object "System.Guid" (,$requestID)
    $guid = $guid.ToString("B")
    $requestPath = "Adaxes://<GUID=$guid>"
    $request = $admService.OpenObject($requestPath, $credential.UserName, $credential.GetNetworkCredential().Password, 0)
    
    try
    {
        $requestProcessed = $request.Get("adm-RequestProcessed")
    }
    catch
    {
        continue
    }

    if ($requestProcessed)
    {
        # Delete the request
        $request.DeleteObject("ADM_DELETEOBJECTFLAGS_AUTO")
    }
}
Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers