Applying RDS Management Tools
This section will show you how to combine these tools to get the information that you need when it's not supplied directly by the tools themselves.
Differentiating RemoteApp Sessions from Full Desktop Sessions
One good example of applying the RDS management tools is when you have to determine whether you can shadow a session. As explained earlier in this tutorial, shadowing Remote- App sessions isn't supported and can lead to some very odd behavior. Therefore, it's good to avoid shadowing a RemoteApp session. Unfortunately, this is easier said than done, because the Remote Desktop Services Manager doesn't spell out the difference. You can find the RemoteApp sessions if you know that RemoteApp sessions use Rdpshell.exe and full desktops use Explorer.exe as the shell. You also have to know where to find this information.
Here's how to find it: From the Remote Desktop Services Manager, the User tab and Session tab reveal no differences between desktop and RemoteApp sessions. Go to the Processes tab. As you might remember, desktop sessions use Explorer.exe as a shell and Userinit.exe to start Windows Explorer; RemoteApp sessions use Rpdshell.exe and Rdpinit.exe, respectively. Therefore, if user Magy Ryan calls you to ask for help with his application, you can check the Processes tab to determine if Magy is running a desktop session that you can shadow.
Auditing Application Usage
Many administrators want to know if their company is compliant with their application licensing requirements. Unfortunately, this isn't easy to determine at the best of times, and it gets harder when an RD Session Host deployment is involved. First, application licensing for an RD Session Host server can be tricky. You need to read the application's fine print (the application vendor determines the licensing requirements, not Microsoft), and if you must be able to demonstrate compliance for legal reasons, you might need to clarify the details with the application's vendor. (Not all license agreements are written with virtualization in mind.) Second, Windows Performance Monitor doesn't offer a way to keep track of how many instances of a process are open on a server, other than adding a process counter and manually counting how many processes have the same name.
You could count application instances from the Remote Desktop Services Manager by counting processes on each RD Session Host server and adding up the results of each count, but why would you? The query process or qprocess command provides a way to do the same thing programmatically. With a little help from some other scripting objects, the query process command can be the basis of a rudimentary application metering tool.
NOTE The Get-Process Windows PowerShell cmdlet isn't session-aware, so it will return only processes in the current session.
This series of scripts will do the following.
- Find all RD Session Host servers in an OU.
- Query all servers to get a list of the processes running on each one.
- Ignore all processes that aren't the application that the script is designed to count.
- Email you if more people are using the application than you have licenses.
- Keep a log file of this data for trending.
Use this tool not only to keep track of your licensing, but also to let you know if an application's usage is decreasing. If you're considering retiring an application, recording how many instances are running over time can give you the data you need to know about how many people are still using it.
NOTE The code snippets in the following sections are not full working scripts. For the sake of space, the script lines that define variables have been removed. The full working scripts are located on the companion media.
In this tutorial:
- Managing Remote Desktop Session
- Introducing RD Session Host Management Tools
- Command-Line Tools
- Connecting Remotely to Servers for Administrative Purposes
- Managing RD Session Host Servers from Windows 7
- Organizing Servers and VMs in the Remote Desktop Services Manager
- Monitoring and Terminating Processes
- Terminating Applications
- Monitoring and Ending User Sessions
- Closing Orphaned Sessions
- Disconnecting Sessions
- Providing Help with Remote Control
- Enabling Remote Control via Group Policy
- Enabling Remote Control via RD Session Host Configuration
- Shadowing a User Session
- Troubleshooting Session Shadowing
- Preparing for Server Maintenance
- Sending Messages to Users
- Shutting Down and Restarting RD Session Host Servers
- Applying RDS Management Tools
- Get the Server Names
- List Processes on the RD Session Host Servers
- Auditing User Logons
- Closing Unresponsive Applications