Have a question?
Message sent Close

Blog

Intune Training: Managing PowerShell Scripts with Start Transcript

In this blog post, we will discuss the process of managing PowerShell scripts using the Start Transcript feature in Microsoft Intune. Start Transcript allows you to create logs that provide diagnostic data in case a script fails to run successfully. However, if a script fails three times, it will never run again on that machine. We will explore two options to overcome this limitation and ensure that the script runs again when needed.

Option 1: Redeploy the Script

The first option is to delete the script from the Intune console and redeploy it. This approach provides a clean slate and gives the script another chance to run successfully. To delete the script, navigate to the Intune console, locate the script, and remove it. Then, redeploy the script to the target devices.

Although this method guarantees that the script will run again, it may not be the ideal solution in a production environment with multiple scripts. Deleting and redeploying scripts can be time-consuming and may disrupt other processes running on the devices.

Option 2: Force the Script to Run Again

The second option involves manually forcing the script to run again by making changes in the Windows registry. This method allows you to bypass the three-fail limit and ensure that the script gets another chance to execute.

To force the script to run again, follow these steps:

  1. Open the Windows Registry Editor by typing “regedit” in the Run dialog.
  2. Navigate to the following location: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Intune\ManagementExtension\Policies.
  3. Locate the entry that corresponds to the script you want to rerun. The entry will have a unique ID, which can be found in the script’s log file.
  4. Delete the entire folder related to the script from the registry.
  5. Restart the Intune Management Extension service.

By deleting the registry entry, you are essentially removing any evidence of the script running on the machine. When the device communicates with Intune again, it will no longer have a record of the script running, and it will initiate the script execution process.

It is important to note that this method is more suitable for troubleshooting individual machines rather than managing scripts across a large number of devices. Deleting the script from the registry will only affect the specific machine where the change is made.

Conclusion

Managing PowerShell scripts in Intune requires a systematic approach to ensure successful execution. The Start Transcript feature helps in diagnosing script failures by providing valuable diagnostic information. However, if a script fails three times, it will no longer run on that machine. By either redeploying the script or manually deleting the registry entry, you can force the script to run again and overcome this limitation.

Intune Training Demo

Join Our Intune WhatsApp Community

Join Our Intune Telegram Community

Join Our LinkedIn Community