0 votes

I've been attempting to run the "Management History" report located in Reports -> All Reports -> Miscellaneous->Logging based on this script in the repository. I've been using this documentation in order to provide the parameters to the report, however, the script fails.

Here's my script:

`

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

$serviceHost  = "***Adaxes Server FQDN***" # TODO: modify me
$reportDN = "CN=Management history,CN=Logging,CN=Miscellaneous,CN=Reports,CN=Reports Root,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes" # TODO: modify me
$documentType = "ADM_REPORTDOCUMENTTYPE_CSV"
$documentContent  = "ADM_REPORTDOCUMENTCONTENT_TABLE" # TODO: modify me
$filePath = "C:\Users\user\Desktop\auditevidence\managementhistory.csv" # 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

#Parameter Values
#param-ObjectTypes Checkbox List
$Users = "ADAXESPARAMID:{abe4fd4b-fbee-457a-b0e6-361e7c2a4325}"
$Computers = "ADAXESPARAMID:{3188db7a-6203-47d0-b231-73137eb5e54b}"
$Groups = "ADAXESPARAMID:{ba5d243f-4bd8-4a97-b93c-16073f55c702}"
$Contacts = "ADAXESPARAMID:{821e49b4-40e7-47b0-b564-8a9a809dca8e}"
$OUs = "ADAXESPARAMID:{e61c5598-7f48-4da9-a439-d052d0463884}"
$checkedItemIds = @($Groups)
$arguments.SetParameterValue("param-ObjectTypes", $checkedItemIds)

#param-Initiator Checkbox List
$UserInit = "ADAXESPARAMID:{69d21a6a-6a24-4f9c-9dd3-52060fd229af}"
$SchedTaskInit = "ADAXESPARAMID:{7d623323-069a-423a-963e-a2312b516626}"
$checkedInitItemIds = @($UserInit,$SchedTaskInit)
$arguments.SetParameterValue("param-Initiator", $checkedInitItemIds)

#param-Days Drop-down List
$24hours = "ADAXESVALUEID:{ee3d87a6-765a-4817-a516-bc8b5145b8fe}"
$7days = "ADAXESVALUEID:{857bcfbc-7ffd-49dd-ba20-070eb018f046}"
$15days = "ADAXESVALUEID:{3aa38677-9515-4641-b0b3-fbf9da09fd80}"
$30days = "ADAXESVALUEID:{d570e783-3a7a-4307-b590-8a30fc599332}"
$60days = "ADAXESVALUEID:{a8c6eff6-9cfd-4841-ac2b-6433b13134b5}"
$90days = "ADAXESVALUEID:{4dc0e46e-8230-41d0-b8b3-979b32657353}"
$180days = "ADAXESVALUEID:{78357603-26d5-4c7b-9a70-a45bfe58a1b4}"
$270days = "ADAXESVALUEID:{ca85e53c-3b86-4cee-b2af-279816921b11}"
$365Days = "ADAXESVALUEID:{936484f7-80c0-41b7-aed4-7c0bee7ee99d}"
$arguments.SetParameterValue("param-Days", $365Days)

#param-ShowServiceSender Check Box
$arguments.SetParameterValue("param-ShowServiceSender", 1)

#param-ErrorsOnly Check Box
$arguments.SetParameterValue("param-ErrorsOnly", 0)

# 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

This is the output: 2023-08-15 11_37_27-di-itpaw-3 - Remote Desktop Connection \(Privileged Access Workstation \(Apps\)\).png

I'm fairly proficient with PowerShell, however, I'm new to using the ADSI Adaxes functionality and I'm not sure where to begin troubleshooting.

by (60 points)

1 Answer

0 votes
by (272k points)

Hello,

The script from the repository works just fine. Pay attention to the type of document. The repository script is generating a PDF file while you are trying to get a CSV file. To achieve the desired, try using the below script.

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

$serviceHost  = "***Adaxes Server FQDN***" # TODO: modify me
$reportDN = "CN=Management history,CN=Logging,CN=Miscellaneous,CN=Reports,CN=Reports Root,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes" # TODO: modify me
$documentType = "ADM_REPORTDOCUMENTTYPE_CSV"
$filePath = "C:\Users\user\Desktop\auditevidence\managementhistory.csv" # 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

#Parameter Values
#param-ObjectTypes Checkbox List
$Users = "ADAXESPARAMID:{abe4fd4b-fbee-457a-b0e6-361e7c2a4325}"
$Computers = "ADAXESPARAMID:{3188db7a-6203-47d0-b231-73137eb5e54b}"
$Groups = "ADAXESPARAMID:{ba5d243f-4bd8-4a97-b93c-16073f55c702}"
$Contacts = "ADAXESPARAMID:{821e49b4-40e7-47b0-b564-8a9a809dca8e}"
$OUs = "ADAXESPARAMID:{e61c5598-7f48-4da9-a439-d052d0463884}"
$checkedItemIds = @($Groups)
$arguments.SetParameterValue("param-ObjectTypes", $checkedItemIds)

#param-Initiator Checkbox List
$UserInit = "ADAXESPARAMID:{69d21a6a-6a24-4f9c-9dd3-52060fd229af}"
$SchedTaskInit = "ADAXESPARAMID:{7d623323-069a-423a-963e-a2312b516626}"
$checkedInitItemIds = @($UserInit,$SchedTaskInit)
$arguments.SetParameterValue("param-Initiator", $checkedInitItemIds)

#param-Days Drop-down List
$24hours = "ADAXESVALUEID:{ee3d87a6-765a-4817-a516-bc8b5145b8fe}"
$7days = "ADAXESVALUEID:{857bcfbc-7ffd-49dd-ba20-070eb018f046}"
$15days = "ADAXESVALUEID:{3aa38677-9515-4641-b0b3-fbf9da09fd80}"
$30days = "ADAXESVALUEID:{d570e783-3a7a-4307-b590-8a30fc599332}"
$60days = "ADAXESVALUEID:{a8c6eff6-9cfd-4841-ac2b-6433b13134b5}"
$90days = "ADAXESVALUEID:{4dc0e46e-8230-41d0-b8b3-979b32657353}"
$180days = "ADAXESVALUEID:{78357603-26d5-4c7b-9a70-a45bfe58a1b4}"
$270days = "ADAXESVALUEID:{ca85e53c-3b86-4cee-b2af-279816921b11}"
$365Days = "ADAXESVALUEID:{936484f7-80c0-41b7-aed4-7c0bee7ee99d}"
$arguments.SetParameterValue("param-Days", $365Days)

#param-ShowServiceSender Check Box
$arguments.SetParameterValue("param-ShowServiceSender", 1)

#param-ErrorsOnly Check Box
$arguments.SetParameterValue("param-ErrorsOnly", 0)

# 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)

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

Thank you. That appeared to take care of the bulk of the errors, however, I'm still seeing this message:

Exception calling "CreateDocument" with "4" argument(s): "Could not load file or assembly 'Softerra.Adaxes.Adsi, Version=3.14.21404.0, Culture=neutral, 
PublicKeyToken=****************' or one of its dependencies. The system cannot find the file specified."
At line:73 char:1
+ $bytes = $reportDocument.CreateDocument($NULL, $arguments, $listItems ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FileNotFoundException

I saw a similar issue in this thread, however, I've checked the permissions on the folder mentioned in that thread the service account already has permissions assigned.

0

Hello,

Are you executing the script on the same computer where Adaxes service runs? If not, make sure that the ADSI provider version matches that of the Adaxes service you connect to in the script. you can check the version in Windows Programs and Features:

image.png

0

Thank you, I appreciate the amount of assistance you've provided.

They did not match; installing the matching version on the remote server seems to have fixed the terminating error.

The script now runs, however, the report it generates is just an empty file.

If I examine the $listitems variable this the error I see:

Completed           : True
Aborted             : False
GenerationException : Softerra.Adaxes.CommandPipeline.Actions.ExecuteActionWrapperException: Exception calling "GetParameterValue" with "1" argument(s): "The number of values doesn't match the number of items defined for parameter 'Object types'." ---> 
                      Softerra.Adaxes.Parameters.InvalidParameterValueException: The number of values doesn't match the number of items defined for parameter 'Object types'.
                         at Softerra.Adaxes.Parameters.AdmParameterCheckList.ValueToString(Object valueArg, ADM_VALUETARGET_ENUM valueTargetArg)
                         at Softerra.Adaxes.Reports.AdmReportArguments.GetParameterValue(String paramNameArg, ADM_VALUETARGET_ENUM valueTargetArg)
                         at Softerra.Adaxes.Reports.ReportScriptContextBase.GetParameterValue(String paramName)
                         at CallSite.Target(Closure , CallSite , Object , String )
                         --- End of inner exception stack trace ---
                         at Softerra.Adaxes.CommandPipeline.Actions.GenerateReportAction.ExecuteAction(IAdmTop targetObject)
                         at Softerra.Adaxes.CommandPipeline.Actions.ActionBase.Execute(IAdmTop targetObjectArg)
                         at Softerra.Adaxes.CommandPipeline.Actions.ActionBase.Execute(ICommand command)
GenerationLog       : {[Error 0x80004005] : Exception calling "GetParameterValue" with "1" argument(s): "The number of values doesn't match the number of items defined for parameter 'Object types'." Stack trace: at <ScriptBlock>, <No file>: line 2, [Error 
                      0x80004005] : Exception calling "GetParameterValue" with "1" argument(s): "Input string was not in a correct format." Stack trace: at <ScriptBlock>, <No file>: line 4, [Error 0x80004005] : You cannot call a method on a null-valued 
                      expression. Stack trace: at <ScriptBlock>, <No file>: line 8, [Error 0x80004005] : You cannot call a method on a null-valued expression. Stack trace: at <ScriptBlock>, <No file>: line 9...}
DataRetrievalLog    : {}

Here are the code for the param-ObjectTypes:

#param-ObjectTypes Checkbox List
$Users = "ADAXESPARAMID:{abe4fd4b-fbee-457a-b0e6-361e7c2a4325}"
$Computers = "ADAXESPARAMID:{3188db7a-6203-47d0-b231-73137eb5e54b}"
$Groups = "ADAXESPARAMID:{ba5d243f-4bd8-4a97-b93c-16073f55c702}"
$Contacts = "ADAXESPARAMID:{821e49b4-40e7-47b0-b564-8a9a809dca8e}"
$OUs = "ADAXESPARAMID:{e61c5598-7f48-4da9-a439-d052d0463884}"
$checkedItemIds = @($Groups)
$arguments.SetParameterValue("param-ObjectTypes", $checkedItemIds)
0

Hello,

If I examine the $listitems variable this the error I see:

What exactly do you mean? How do you perform examination?

Here are the code for the param-ObjectTypes:

Make sure that all the identifiers for all parameters are correct. For information on how to obtain them, see https://adaxes.com/sdk/SampleScripts.ViewingParametersOfCustomCommand.

0

After the script has been run I can check the variable to see the contents - for $listitems I see the error above.

0

Hello,

The issue occurs due to the way parameter values are passed. In certain cases there should be explicit casting. Also, you need to specify a scope and CSV file settings in the script. We updated it accordingly. Find the complete script below.

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

$serviceHost  = "***Adaxes Server FQDN***" # TODO: modify me
$reportDN = "CN=Management history,CN=Logging,CN=Miscellaneous,CN=Reports,CN=Reports Root,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes" # TODO: modify me
$documentType = "ADM_REPORTDOCUMENTTYPE_CSV"
$filePath = "C:\Users\user\Desktop\auditevidence\managementhistory.csv" # 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

# Scope
$scope = $configuration.CreateScope("ADM_REPORTSCOPETYPE_LOCATION")
$baseObject = $scope.CreateBaseObject()
$baseObject.ObjectReference = $null # Everywhere
$scope.BaseObjects = @($baseObject)
$arguments.Scope = $scope

#Parameter Values
#param-ObjectTypes Checkbox List
$Users = "ADAXESPARAMID:{abe4fd4b-fbee-457a-b0e6-361e7c2a4325}"
$Computers = "ADAXESPARAMID:{3188db7a-6203-47d0-b231-73137eb5e54b}"
$Groups = "ADAXESPARAMID:{ba5d243f-4bd8-4a97-b93c-16073f55c702}"
$Contacts = "ADAXESPARAMID:{821e49b4-40e7-47b0-b564-8a9a809dca8e}"
$OUs = "ADAXESPARAMID:{e61c5598-7f48-4da9-a439-d052d0463884}"
$checkedItemIds = [System.String[]]@($Users)
$arguments.SetParameterValue("param-ObjectTypes", $checkedItemIds)

#param-Initiator Checkbox List
$UserInit = "ADAXESPARAMID:{69d21a6a-6a24-4f9c-9dd3-52060fd229af}"
$SchedTaskInit = "ADAXESPARAMID:{7d623323-069a-423a-963e-a2312b516626}"
$checkedInitItemIds = [System.String[]]@($UserInit,$SchedTaskInit)
$arguments.SetParameterValue("param-Initiator", $checkedInitItemIds)

#param-Days Drop-down List
$24hours = "ADAXESVALUEID:{ee3d87a6-765a-4817-a516-bc8b5145b8fe}"
$7days = "ADAXESVALUEID:{857bcfbc-7ffd-49dd-ba20-070eb018f046}"
$15days = "ADAXESVALUEID:{3aa38677-9515-4641-b0b3-fbf9da09fd80}"
$30days = "ADAXESVALUEID:{d570e783-3a7a-4307-b590-8a30fc599332}"
$60days = "ADAXESVALUEID:{a8c6eff6-9cfd-4841-ac2b-6433b13134b5}"
$90days = "ADAXESVALUEID:{4dc0e46e-8230-41d0-b8b3-979b32657353}"
$180days = "ADAXESVALUEID:{78357603-26d5-4c7b-9a70-a45bfe58a1b4}"
$270days = "ADAXESVALUEID:{ca85e53c-3b86-4cee-b2af-279816921b11}"
$365Days = "ADAXESVALUEID:{936484f7-80c0-41b7-aed4-7c0bee7ee99d}"
$arguments.SetParameterValue("param-Days", $24hours)

#param-ShowServiceSender Check Box
$arguments.SetParameterValue("param-ShowServiceSender", 1)

#param-ErrorsOnly Check Box
$arguments.SetParameterValue("param-ErrorsOnly", 0)

# Generate the report.
$listItems = $report.Generate($arguments)
$listItems
## 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.LineBreak = "ADM_LINEBREAK_CRLF"
$reportDocument.ColumnSeparator = ","
$reportDocument.MultiValueSeparator = ";"

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

This appears to have worked. Thank you for all of the support.

Related questions

0 votes
1 answer

Good morning, I'm trying to process a search and export using the Adaxes console to create a list of users using specific criteria. I've been able to process this ... and the job is cancelled Please advise on how I might proceed in addressing this issue.

asked Jan 13, 2022 by jtop (680 points)
0 votes
1 answer

I'm trying to generate a custom report based off the return values of a PowerShell script. I've tried looking over the tutorial docs and SDK, but I can't seem to piece it all ... Expression = { $_.Properties[1].Value } } } catch { Throw $_.Exception } } }

asked Sep 6, 2021 by joshua.lapchuk (60 points)
0 votes
1 answer

As the title says is it still a requirement?

asked Feb 23, 2023 by techg (320 points)
0 votes
1 answer

Aiming to go passwordless, this is a must-have

asked Aug 30, 2023 by JM (20 points)
0 votes
1 answer

We are in the process of migrating some objects from one domain to another. The process involves deleting attributes from the old object. Currently I'm saving certain attributes ... file. Is there a way to initiate that export from a custom powershell action?

asked Jul 23, 2014 by dtb147 (290 points)
3,351 questions
3,052 answers
7,791 comments
545,103 users