Forum Discussion
Ashish_Arya
Aug 13, 2024Brass Contributor
Parameter is incorrect error at ESP phase of Autopilot device preparation policy (Autopilot V2)
Hi Team, I am testing the Windows autopilot device preparation profile (Autopilot V2). Here, I need to rename the device while it is enrolling to the Intune (during ESP). So, I created a script ...
Ankido
Mar 08, 2025Iron Contributor
Ashish_Arya,
Timing and ESP’s Dependency on Continuity
The ESP (Enrollment Status Page) is designed to monitor and ensure that all configuration steps (Device Preparation, Device Setup, and Account Setup) are completed without interruption. When you force a restart using -Restart -Force in the script during the ESP phase, you disrupt the expected flow of ESP. After the restart, it appears that ESP cannot properly resume the process, which may cause the error. Autopilot V2 is sensitive to unexpected restarts, especially if they are not managed by Intune itself.
Intune and Autopilot V2’s Handling of Restarts
In Autopilot V2 (Device Preparation), restarts during ESP are not always fully supported unless they are initiated by Intune based on specific return codes from apps or scripts. Your script uses -Restart -Force, which means the restart happens immediately without giving Intune a chance to "approve" or manage it. This can result in ESP losing track of the process.
Avoid Restart During ESP
Test removing -Restart -Force from the script and allow the name change to occur without an immediate restart. The user can then manually restart the device after ESP is complete, or you can schedule the restart after ESP using another method (e.g., a scheduled task triggered after defaultuser0 logs out). This can help preserve ESP’s flow.
Example of a modified script without restart:
$newname = "YourDeviceName"
Rename-Computer -NewName $newname -ErrorAction 'Stop' -ErrorVariable err
Check Intune Configuration
Ensure that your Device Preparation policy in Intune is correctly configured and that the script is marked as "Required" during the ESP phase. If there are any conflicting policies (e.g., one that also tries to set the device name), it could cause issues.
Feel free to reach out.