1

The Net Use command will only show me what drives that only I have mapped when I am logged into the server. What is the easiest way to see all mapped drives for all users and the status of the drives? Thanks.

EDIT

I'm specifically looking for all disconnected drives for all users that are not longer valid so I can disconnect them. I believe the old disconnected mapped drives are causing problems regarding Outlook and inserting attachments to emails.

EDIT AGAIN (WHY NOT?)

My original thought was that someone, somewhere created a tool that displayed this information, and that I was just unable to find it.

NinjaBomb
  • 159
  • 2
  • 5
  • 17
  • To approach the issue differently, could you just set a GPO to log TS users off that are inactive for a shorter amount of time? This would prevent this state from even happening. – BoxerBucks Apr 29 '11 at 17:11

4 Answers4

3

Tentative answer - iterate through the users under HKEY_USERS and extract the contents of the Network key. That won't tell you for all users logged in, that will tell you for all users that ever logged in. If you need it fancier, you could parse usernames from the output of qwinsta, correlate that to the SIDs under HKEY_USERS, and then pull only their Network keys.

I'm sure it would be easiest to do in PowerShell (which might have more built-in methods to do this anyway), but since you're on Win2k3, I'm not going to assume that's installed.

Edit- ok, now with that explanation of the problem, why don't you add a line to the start of your TS login scripts to do a net use * /delete ? Then map everything after that. If anyone needs a mapped drive, add that into their login scripts.

mfinni
  • 36,144
  • 4
  • 53
  • 86
  • PowerShell is not installed. Say i did iterate throught the HKEY_USERS regristry keys and get the contents of the network key and correlate it to the SID's of the users. Would I end up with something that tells me the users, mapped drive letters, mapped drive location and if the drive is connected/disconnected? – NinjaBomb Apr 26 '11 at 21:38
  • From a first glance, it would tell you the users, the letter, the UNC path, and it looks like there's a numeric value for status, so you'd have to know what those values meant. – mfinni Apr 26 '11 at 21:42
  • Let me ask this - What problem are you trying to solve? Think of adding that to your original question, and you can often get some answers that might even involve a different approach than what you're specifically asking about. – mfinni Apr 26 '11 at 21:43
  • Just updated with more info. Besides my specific problem, there isn't an answer I could find online, so that also led me to ask the question. – NinjaBomb Apr 26 '11 at 21:47
  • OK - can you elaborate more on this? "I believe the old disconnected mapped drives are causing problems regarding Outlook and inserting attachments to emails." What are the problems, and why do you believe that this is the cause? – mfinni Apr 26 '11 at 21:48
  • Attachments take a long time (5 - 10 minutes) to attach to emails in Outlook. I have tried everything I could find to fix it, but based on my research the disconnected drives might be the culprit. See http://www.petri.co.il/forums/showthread.php?t=7595 and http://www.office-outlook.com/outlook-forum/index.php/m/632929/ – NinjaBomb Apr 26 '11 at 21:55
  • I edited my answer to address the issue in a slightly different way. Even if you find them, you still need to clean them up. Perhaps you could simply manage the whole process. – mfinni Apr 26 '11 at 23:29
  • 1
    i believe mfinni's solution of deleting all mapped drives at TS logon and then mapping necessary drives afterward to be the best option. – pk. Apr 27 '11 at 15:59
  • Are your users logging out when they're done? Or do they just disconnect? I could see the drives going to disconnected if the users go idle and then resume the session later. – SpacemanSpiff May 02 '11 at 04:01
  • They _should_ be logging out completely at the end of the day. – NinjaBomb May 03 '11 at 15:44
  • @Ninja - that doesn't take real-world usage patterns into account :-) Plenty of people, including admins, just X their Citrix or RDP sessions, without properly logging off. As an admin or engineer, you can't ever count on users always doing things the "proper" way. If they did, most of us would be out of jobs. – mfinni May 03 '11 at 16:19
  • Seeing other answers - they do a good job of telling you what drives the users have. What they don't do is let you actually manage them, which is required to solve your problem. My approach cuts that Gordian knot, and then reties it properly. – mfinni May 03 '11 at 16:22
  • Just to clarify, I thought by accepting your answer it would award you the full bounty when it expired. Dumb me didn't realize I had to click the bounty button. – NinjaBomb May 03 '11 at 20:04
  • Haha - no worries. Also, I do like @Garrett's answer below. Keeping some diag info, gathered by login scripts, is a great little piece of management infrastructure for small-to-medium environments. – mfinni May 03 '11 at 21:01
1

The following wmic commandline will return all mapped drives not in Connected state.

wmic /node:"ServerName" netuse where connectionstate!="Connected" get localname, name, username

The following will return all mapped drives regardless of the connection state:

wmic /node:"Sedlmeyer-PC" netuse get localname, name, username

You can also remove the "get localname, name, username" and replace with list to get full details. If you run the command local to the server you can leave off the /node.

You also add a /format option to change how the info is output. For instance /format:csv will generate it in csv format, /format:htable will output it as a HTML table, and /format:xml as XML. If you add /output:"filename" as the first argument it will save the output to the specified file. If you use /output:clipboard it will place th eoutput in the clipboard.

More info on wmic can be found here.

TimS
  • 2,166
  • 13
  • 8
  • Just tried this, but it only gives me the disconnected drives that only I have (which is none), not all users on the Terminal Server. To verify, I tested your second code example and it returned only my connected drives. Is there another switch to make it run globally? So far, this is the easiest and best method IMO if it could search all users. – NinjaBomb May 03 '11 at 13:24
1

Add something like the following to your logon script

echo %date%,%time%,%computername%,%username% >> \\fileserver\hiddenshare$\drives.csv
net use >> \\fileserver\hiddenshare$\drives.csv

Make sure to give all your users write access to the share, then let it populate.

After a day or two you'll have a great CSV file you can load up in Excel, sort on User, and flip around the data however works best for you.

Garrett
  • 1,638
  • 4
  • 15
  • 25
  • what exactly will be in the csv file once it is populated? I see date, time, computername (which I know), and username. Is the mapped drive info and status in there? – NinjaBomb May 03 '11 at 15:45
  • @Ninja - that's the output of "net use" - the double-arrow redirects output and appends it to the CSV file. – mfinni May 03 '11 at 16:20
  • 1
    Also, this is a great answer. I've done almost exactly this in the past, it also gives you a login log that's easier to read than all of your DC audit logs. – mfinni May 03 '11 at 17:49
-1

Please look at the following link, which provide an ability to manage TS. It might allow getting such an information.

Vick Vega
  • 2,398
  • 16
  • 22
  • I'm sorry, it doesn't appear that any of those links provide the information requested. Can you elaborate? Perhaps I'm overlooking something. – mfinni Apr 26 '11 at 20:33
  • Given the password for the logged in user is known, you can extract the list of logged in users and run as "net use". – Vick Vega Apr 26 '11 at 20:53
  • And how does that get the list of mapped drives in their sessions? – mfinni Apr 26 '11 at 21:41
  • 2
    How is the password for each user known? I don't know them, nor do I want too. – NinjaBomb Apr 26 '11 at 21:42
  • If you do not know the password - it's impossible. – Vick Vega Apr 27 '11 at 01:37
  • Vick - any sane security policy would absolutely preclude password sharing, even to the systems admins. – mfinni Apr 27 '11 at 12:41
  • @mfinni, I'm fully aware of that. And this is generally the case, however there are completely different scenarios when it's exactly the opposite. – Vick Vega Apr 27 '11 at 13:01