Public/Get-AppEnhancerDocumentIndex.ps1
|
function Get-AppEnhancerDocumentIndex { <# .SYNOPSIS Retrieves the index values for a specific document in ApplicationXtender. .DESCRIPTION Sends a GET request to the ApplicationXtender REST API to retrieve index metadata for a document identified by its DocId and AppId. The function authenticates using Basic Authentication and returns the document index information as a PowerShell object. .PARAMETER ServerUrl The base URL of the AX WebCore server (e.g., https://yourserver.domain.local). .PARAMETER Credential A PSCredential object containing the username and secure password used for Basic Authentication. .PARAMETER DocId The unique document ID within the specified ApplicationXtender application. .PARAMETER AppId The ApplicationXtender App ID where the document resides. .OUTPUTS [PSCustomObject] Returns a PSCustomObject containing the document index values. If the request fails or the response is not in the expected format, returns $null. .EXAMPLE $cred = Get-Credential $docId = '12345' $appId = 28 $response = Get-AppEnhancerDocumentIndex -ServerUrl "https://axwebserver.local" -Credential $cred -DocId $docId -AppId $appId -Verbose This example retrieves the index values for document ID 12345 in Application ID 28 using the provided credentials. .NOTES Author: Bruce Stump Last Updated: August 19, 2025 Requires: PowerShell 5.1 or later, ApplicationXtender REST API access #> [CmdletBinding()] [OutputType([PSCustomObject])] param ( [Parameter(Mandatory=$true)] [string]$ServerUrl, [Parameter(Mandatory=$true)] [PSCredential]$Credential, [Parameter(Mandatory=$true)] [int]$DocId, [Parameter(Mandatory=$true)] [int]$AppId ) begin {} process { # Convert SecureString to plain text $plainPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto( [Runtime.InteropServices.Marshal]::SecureStringToBSTR($Credential.Password) ) $cred = "$($Credential.Username):$plainPassword" $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($cred)) $queryUrl = "$ServerUrl/AppXtenderReST/api/AXDataSources/ApplicationXtender/axapps/$AppId/axdocindexes/$DocId" $headers = @{ "Authorization" = "Basic $base64AuthInfo" "Content-Type" = "application/vnd.emc.ax+json" } try { Write-Verbose "Sending GET request to: $queryUrl" $response = Invoke-RestMethod -Uri $queryUrl -Headers $headers -Method Get return $response } catch { Write-Error "Failed to retrieve document index: $($_.Exception.Message)" return $null } } end {} } |