Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best effort fix errors while exporting objects #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

certxlm
Copy link
Contributor

@certxlm certxlm commented Nov 9, 2023

Export-Clixml sometimes fails to exports all (gc)ADobjects, due to invalid encoded characters in some attributes.

Error observed usually during such events:

Error while exporting objects retrieved via LDAP '�', hexadecimal value 0xFFFF, is an invalid character

We end up with a truncated XML files, here is an example of such files:

<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
  <Obj RefId="0">
    <TN RefId="0">
[...]
 <Obj N="msExchAssistantsMaintenanceSchedule" RefId="13601">
        <TNRef RefId="1" />
        <LST>
          <S> <----- end of file

This does not seem to impact ingestion into splunk (maybe because extraction is done via regex?).

It is "kind of easily" reproductible by replacing a random attribute of such object with the following value:
$adobjects[0].random_attribute="should-not-be-$([char]0xffff)-exportable"

Nonetheless, it would be nice to exclude un-exportable objects and retry afterwards. The following PR uses the following static function to detect such objects:
[System.Management.Automation.PSSerializer]::Serialize

Note that it is a best-effort fix only, and has limitation (PSSerializer does not allow to set the encoding as in current code (UTF8), and has a default depth of 1 instead of 2 for export-clixml

Fix potential issue when exporting adobjects
same fix but for global catalog objects
Adding logging for objects we cannot serialize
Forgot to clean old code for gcobjects export
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant