jseerden/IntuneBackupAndRestore

Invoke-IntuneRestoreDeviceHealthScript

condoreddie opened this issue · 4 comments

Hi,

Is it possible to have the addition of restoring the device health scripts?
I can see the backup:
Invoke-IntineBackupDeviceHealthScript.ps1

Check out PR #61 for extended backup and restore functionality of device health scripts.

Check out PR #61 for extended backup and restore functionality of device health scripts.

Thank you, I have now updated the content to include these scripts. However, I get an error stating detectionscript must not be null or empty. I have checked the backup files and folders and they are not empty, they contain the correct content.

Invoke-IntuneRestoreDeviceHealthScript : 400 Bad Request
{"error":{"code":"UnknownError","message":"DetectionScriptContent must not be null or empty","innerError":{"date":"2023
-08-31T09:33:23","request-id":"116e46f8-17be-4bb1-aaf3-766608c89659","client-request-id":"116e46f8-17be-4bb1-aaf3-76660
8c89659"}}}
At line:1 char:1
+ Invoke-IntuneRestoreDeviceHealthScript -Path "D:\Dump\HFLDev_IntuneBa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-IntuneRestoreDeviceHealthScript

The modifications to the backup script (Invoke-IntuneBackupDeviceHealthScript.ps1) are critical, as the original script has a bug that produces incomplete .json dumps of the individual device health script objects.

You have to make sure that you use the modified script to create the backup files, not the original one. You can verify this if you open the exported .json files with a text editor. The key "detectionScriptContent" must contain a base64-encoded value that matches your script when decoded (e.g. via CyberChef).

The exported scripts in the "Script Content" subdirectory are only there for convenience, only the contents of the .json files are relevant during restore.

The modifications to the backup script (Invoke-IntuneBackupDeviceHealthScript.ps1) are critical, as the original script has a bug that produces incomplete .json dumps of the individual device health script objects.

You have to make sure that you use the modified script to create the backup files, not the original one. You can verify this if you open the exported .json files with a text editor. The key "detectionScriptContent" must contain a base64-encoded value that matches your script when decoded (e.g. via CyberChef).

The exported scripts in the "Script Content" subdirectory are only there for convenience, only the contents of the .json files are relevant during restore.

Thank you very much, all is working now