almenscorner/IntuneCD

[BUG] UnicodeEncodeError: 'charmap' codec can't encode character '\ufeff' in position 0: character maps to <undefined>

Closed this issue · 3 comments

ztrhgf commented

Describe the bug
When running:
IntuneCD-startbackup --mode=1 --output=json --path="$PWD\prod-backup" --localauth="$PWD\auth.json"

Backup fails with error:

Backing up Proactive Remediation: BIOS_UEFI_Boot_Path
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python311\Scripts\IntuneCD-startbackup.exe\__main__.py", line 7, in <module>
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python311\Lib\site-packages\IntuneCD\run_backup.py", line 370, in start
    run_backup(args.path, args.output, exclude, token)
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python311\Lib\site-packages\IntuneCD\run_backup.py", line 275, in run_backup
    results.append(savebackup(path, output, exclude, token))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python311\Lib\site-packages\IntuneCD\backup_proactiveRemediation.py", line 78, in savebackup
    f.write(decoded)
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python311\Lib\encodings\cp1250.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\ufeff' in position 0: character maps to <undefined>

To Reproduce
Upload "UTF8 with BOM" encoded remediation or detection script to Intune and run backup action.

Expected behavior
Backup "UTF8 with BOM" encoded scripts successfully.

Screenshots
If applicable, add screenshots to help explain your problem.

Run type (please complete the following information):

  • Mode: 1
  • Client: local machine
  • Version latest

Additional context
Add any other context about the problem here.

ztrhgf commented

Same goes for builtin PowerShell Intune script "Modern Workplace - Autopatch Client Setup v1.1" that is being created automatically when Autopatch feature is used.

ztrhgf commented

It helped thanks!