DeliriumTremens
Contributor
Contributor

Microsoft Teams and DirectFlex

Jump to solution

I am struggling to get DirectFlex to fire off a PowerShell script whenever users launch Microsoft Teams.

I have enabled DirectFlex for the Teams config file, and set the executables to:

  • %LocalAppData%\Microsoft\Teams\Current\Teams.exe
  • %LocalAppData%\Microsoft\Teams\Update.exe

I have a Pre-Import Task

  • powershell.exe -ExecutionPolicy Bypass -File "\\path\to\script.ps1"
  • Run task: Before profile archive import
  • I DO NOT have 'Run Once' selected

I also added a bit to Import/Export to see if that would execute when the application is launched.

I can see the config being loaded to the DirectFlex cache:

  • 2020-07-23 10:44:40.409 [INFO ] Config file '\\uem\config\general\Microsoft Office 2016\Teams.INI' added to DirectFlex cache

The DirectFlex rule runs once -- the first time Teams is launched. Subsequent launches do not run the import or UEM tasks.

I'm running out of ideas as I've tried about every combination of settings I can think of to get DirectFlex to run every time Teams is launched.  Any advice on where to look would be greatly appreciated.

1 Solution

Accepted Solutions
DEMdev
VMware Employee
VMware Employee

Hi DeliriumTremens,

DirectFlex depends on being notified of process launches and exits so it knows when to perform an import (when the first DirectFlex-enabled executable starts) or an export (when the last instance exits.)

I took a quick look at Teams.exe, and it turns out that it spawns a few child instances. That's no problem in and of itself, as the DirectFlex bookkeeping mechanism can deal with that, but it turns out that Teams is using Windows job objects to control some aspects of those child processes. One of the options in a job object is to automatically kill child processes if the parent process exits. If a process is killed in that fashion (rather than exiting "properly"), DEM is not notified of that, which means that our bookkeeping thinks (some of) those child processes are still running, which in turn means that we do not perform a DirectFlex export, which in turn means that the next launch of Teams.exe is not treated as a "first launch", and no DirectFlex import is performed...

View solution in original post

7 Replies
DEMdev
VMware Employee
VMware Employee

Hi DeliriumTremens,

Do all instances of that Update.exe and Teams.exe stop running when you exit Microsoft Teams? Do you see any DirectFlex export actions in the log between the first and second launch of Teams?

0 Kudos
DeliriumTremens
Contributor
Contributor

I have tried quitting from the taskbar, and ending the task in Task Manager.  It does not appear that any export happens, even after Teams has been fully closed.

0 Kudos
DEMdev
VMware Employee
VMware Employee

Hi DeliriumTremens,

DirectFlex depends on being notified of process launches and exits so it knows when to perform an import (when the first DirectFlex-enabled executable starts) or an export (when the last instance exits.)

I took a quick look at Teams.exe, and it turns out that it spawns a few child instances. That's no problem in and of itself, as the DirectFlex bookkeeping mechanism can deal with that, but it turns out that Teams is using Windows job objects to control some aspects of those child processes. One of the options in a job object is to automatically kill child processes if the parent process exits. If a process is killed in that fashion (rather than exiting "properly"), DEM is not notified of that, which means that our bookkeeping thinks (some of) those child processes are still running, which in turn means that we do not perform a DirectFlex export, which in turn means that the next launch of Teams.exe is not treated as a "first launch", and no DirectFlex import is performed...

View solution in original post

DeliriumTremens
Contributor
Contributor

DEMdev

Thanks for the extra details -- so it seems that there may be no way to control this behavior, since no matter which method I use to exit Teams, I experience the same result.

0 Kudos
DEMdev
VMware Employee
VMware Employee

Hi DeliriumTremens,

I wish I had better news, but I'm afraid not, sorry...

DeliriumTremens
Contributor
Contributor

Since the ONLY thing I need to do with this rule is run a small powershell script when Teams is launched, I have opted to ONLY hook DirectFlex to Update.exe -- it looks like this is enough to get the script to fire off whenever someone launches Teams.  I appreciate all of the insight on this!

DEMdev
VMware Employee
VMware Employee

Hi DeliriumTremens,

Since the ONLY thing I need to do with this rule is run a small powershell script when Teams is launched, I have opted to ONLY hook DirectFlex to Update.exe -- it looks like this is enough to get the script to fire off whenever someone launches Teams.  I appreciate all of the insight on this!

Nice one!

0 Kudos