Script repository

Export a report

Updated on: Jan 18, 2026, Views: 2111

Reports, Export data

The script generates a report and exports it to a file. The script should be executed in Windows PowerShell. When prompted, specify the credentials of the Adaxes service account (entered during Adaxes installation).

The script generates a report with its default columns. For details on specifying arguments for report generation, see Generating reports.

Parameters

  • $serviceHost - the host name of the computer where Adaxes service is installed.
  • $reportDN - the distinguished name (DN) of the report to export. For information on how to get the DN, see Get the DN of a directory object.
  • $documentType - the type of the report document that will be created. For available document types, see ADM_REPORTDOCUMENTTYPE_ENUM.
  • $documentContent - the contents be included into the report document. For available content types, see ADM_REPORTDOCUMENTCONTENT_ENUM.
  • $filePath - the path to the file that will be created.
Import-Module Adaxes

$serviceHost = "localhost" # TODO: modify me
$reportDN = "CN=My Report,CN=Reports,CN=Reports Root,CN=Configuration Objects,"+
    "CN=Adaxes Configuration,CN=Adaxes" # TODO: modify me
$documentType = "ADM_REPORTDOCUMENTTYPE_PDF"
$documentContent = "ADM_REPORTDOCUMENTCONTENT_TABLE,
    ADM_REPORTDOCUMENTCONTENT_GENERATIONDATE,
    ADM_REPORTDOCUMENTCONTENT_REPORTDESCRIPTION,
    ADM_REPORTDOCUMENTCONTENT_TOTALCOUNT" # TODO: modify me
$filePath = "C:ReportsMy Report.PDF" # TODO: modify me

# Prompt for credentials.
$credential = Get-Credential

# Bind to the report.
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly($serviceHost)
$report = $admService.OpenObject("Adaxes://$reportDN", $credential.UserName, $credential.GetNetworkCredential().Password, 0)

# Arguments for report generation
$configuration = $report.GetConfiguration()
$arguments = $configuration.CreateReportArguments()
$arguments.Columns = $configuration.Generator.Columns.Columns

# Generate the report.
$listItems = $report.Generate($arguments)

# Wait till all report items are fetched.
while (!$listItems.Completed)
{
    Sleep -Milliseconds 100
}

# Bind to the 'Reports' container.
$reportsRootContainerPath = $admService.Backend.GetConfigurationContainerPath("ReportsRoot")
$reportsRootContainer = $admService.OpenObject($reportsRootContainerPath, $credential.UserName, $credential.GetNetworkCredential().Password, 0)

# Create report document.
$reportDocument = $reportsRootContainer.CreateDocument($documentType, $report)
$reportDocument.Content = $documentContent
$reportDocument.EnableObjectLinks = $True

# Save to file.
$bytes = $reportDocument.CreateDocument($NULL, $arguments, $listItems, $NULL)
Set-Content -Path $filePath -Value $bytes -Encoding Byte

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.