almenscorner / IntuneCD

Tool to backup, update and document configurations in Intune
MIT License
290 stars 38 forks source link

[BUG] Backup fails when Proactive Remediation has "/" character in Title #66

Closed tylerreilly-watercare closed 1 year ago

tylerreilly-watercare commented 1 year ago

There appears to be an issue with backing up Proactive Remediations (and possibly other items) when a "/" character exists in the title as this is passed through to the file path for JSON/YAML backup (which is interpreted as a folder).

Backing up Proactive Remediation: Custom Device Inventory - App/Device Inventory Traceback (most recent call last): File "/home/vsts/.local/bin/IntuneCD-startbackup", line 8, in sys.exit(start()) File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/run_backup.py", line 241, in start run_backup(args.path, args.output, exclude, token) File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/run_backup.py", line 193, in run_backup config_count += savebackup(path, output, exclude, token) File "/home/vsts/.local/lib/python3.8/site-packages/IntuneCD/backup_proactiveRemediation.py", line 72, in savebackup f = open( FileNotFoundError: [Errno 2] No such file or directory: '/home/vsts/work/1/s/Proactive Remediations//Script Data/Custom Device Inventory - App/Device Inventory_DetectionScript.ps1'

[error]Bash exited with code '1'.

almenscorner commented 1 year ago

I was able to replicate when adding a ´/´ to the name of my proactive remediation configuration. The reason is that it is trying to use the display name of the configuration when saving the scripts. When doing so it does not run clean_filename to remove it from the name.

I have changed it to instead use the filename of the configuration when saving the script to correctly remove the ´/´ from the filename of the script. The changed will be merged soon.