Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

4 Answers 4

up vote 3 down vote accepted
+25

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.

share|improve this answer
    
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
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
show 9 more comments

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.

share|improve this answer
    
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 3 '11 at 13:24
add comment

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.

share|improve this answer
    
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 3 '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 3 '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 3 '11 at 17:49
add comment

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

share|improve this answer
    
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 1:37
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.