Windows 8.1 / Windows Server 2012 R2 - RDS Shadowing is back!
While shadowing is a great built-in solution for remote support, having to use the Server Manager to shadow the user is less than convenient. Using the command line opens up programmatic solutions, but the server name and session ID of the user on that server must be known.
Can we add a Shadow button directly to the Online users form instead?
It seems like we have all the needed pieces to make a working solution, so it's time to put them all together. Start by adding a new Shadow (control) button below the grid.
To keep the clicked method simple, just call a form method named clickedShadowControl() and do the heavy lifting there.
The first task is to call the QUERY command to fetch the session ID for the user on the server (remote desktop). We'll construct the parameter string, create a System.Diagnostics.ProcessStartInfo object, making sure to capture the standard output of the process, and then start the process to execute the command. If it doesn't terminate after 5 seconds, terminate it to be safe and abort.
The next task is to read the output from the QUERY command and locate the user's session ID. The first line is the header, which allows us to locate the ID column position, and then the ID itself can be fetched from the user's data on the second line.
The last task is to call the MSTSC process with the server and now available session ID as parameters.
Finally, clicking the button launches the shadowing session in a Remote Desktop Connection window.
This is a proof of concept build that illustrates the possibilities for integrating shadowing directly into the Online users form within Dynamics AX. Exercises such as error handling and security are left to the reader.