I’ve been using CSV files with FIM File-based MA’s now and then and till now I never had any issues. This week I received a new CSV and I had issues getting the configuration of the MA right. To be more precise, whenever I ran a Full Import I got an error stating stopped-file-embedded-nulls. I asked the guys why they put those nulls in the CSV… They had no clue :). They did some PowerShell magic and used the import-csv and export-csv commandlets to generate the CSV.
The error in the Synchronization Manager:
In the event log:
In words: The management agent “MA NAME” failed on run profile “Run Profile Name” because null characters were embedded in the input file. User Action Verify the input file and the code page configuration for the management agent.
After some googling and reading about embedded nulls I opened the CSV using some binary file viewer:
At the begin of the file you can see FF FE which is definitely not supposed to be there. If we simply open the file with notepad, copy paste the contents into a new file, the FF FE values are gone in the resulting file and the import runs just fine. That’s a good workaround for once, but it’s not acceptable to do on a regular base. And it’s sure as hell isn’t a nice answer as to why these symbols are being added by PowerShell!
Some more googling led me to: PowerShell Byte Array And Hex Functions which says: The “0xFF,0xFE” bytes at the beginning of a Unicode text file are byte order marks to indicate the use of little-endian UTF-16. Now that ringed a bell!
My MA had “Western European” as Code page (default): This can be found on the Configure Attributes tab of the File MA configuration.
By clicking change we can choose “Unicode”, which I think is the equivalent of “little-endian UTF-16”.
Either way, running a full import now succeeds just fine!
[Update] As the comment system seems to have acted up both Brian Desmond and Carol Wapshere mailed me and pointed me to the fact that you can just append the “-encoding ASCII” to the export-csv commandlet to avoid the above issue in the first place. Thanks for the tip both of you!
A screenshot of the help section of the export-csv commandlet: