How we can we force the PS script on Intune to rerun

Ashish Kumar Arya 41 Reputation points
2021-04-14T16:18:34.123+00:00

Hi Team,

Please help here ---

I am pushing a PS script to Intune machines on my tenant to change the Ethernet network adapter's network category from Public to private. This is to turn off the VPN automatically when the machine is on an Ethernet network.

For some reason, the script is getting failed for scenarios when the machines are not on LAN and connected to Wifi and when the machines gets to LAN, so the VPN does not turned off automatically.

Is there a way to resolve this issue?

Microsoft Security | Intune | Other
{count} votes

Accepted answer
  1. Cici Wu-MSFT 1,191 Reputation points
    2021-04-15T03:00:22.613+00:00

    Please understand that the Intune management extension agent checks with Intune once every hour and after every reboot for any new scripts or changes. After you assign the policy to the Azure AD groups, the PowerShell script runs, and the run results are reported. Once the script executes, it doesn't execute again unless there's a change in the script or policy. If the script fails, the Intune management extension agent retries the script three times for the next three consecutive Intune management extension agent check-ins.

    If you want to force run the script, you can restart the IntuneManagementExtension service in task manager and and the script will rerun again on this device. Also, a restart on the device or restart service triggers the script. Here is a good sample:
    https://oliverkieselbach.com/2018/02/12/part-2-deep-dive-microsoft-intune-management-extension-powershell-scripts/

    If you want scripts to run multiple times for a user, you'll need to deploy a method of removing the key, reassigning the script or scheduling it as a task.
    Reference: https://learn.microsoft.com/en-us/mem/intune/apps/intune-management-extension

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    4 people found this answer helpful.

3 additional answers

Sort by: Most helpful
  1. Paul Austin 31 Reputation points
    2021-08-19T05:02:07.157+00:00

    Intune could be improved dramatically with one simple change.

    If you go into Microsoft Company Portal and click the Sync button in settings it would go off, check in and run any updates that need to be run.

    The current cycle of wait a random amount of time to see if the changes you made to a script, setting or new app to be installed isn't very productive for Administrators doing new things.

    6 people found this answer helpful.

  2. Pavel yannara Mirochnitchenko 13,341 Reputation points MVP
    2021-04-14T18:38:44.157+00:00

    It is enough to re-add the script file into the script policy and it will re-execute it (for all devices).


  3. U2 Pas 0 Reputation points
    2023-10-05T16:26:09.23+00:00

    to rerun, either have to cleanup in registry so intune does not remember it already did run.
    Here is a good start for more details
    https://www.deploymentresearch.com/force-application-reinstall-in-microsoft-intune-win32-apps/

    Maybe even better is to use remediation scripts and set them to run once or schedule, and in single devices can also rerun manually


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.