Link to home
Create AccountLog in
Avatar of kind4me
kind4meFlag for United States of America

asked on

Need logon script to find all mapped drives

Short story:  I need a script (and best way to run it GPO LOGON etc) to log all mapped drives and report it back to a network share.  

Long Story:

I am working for a client that had 10 servers (if putting a sticker that says "do not touch server" on a dell P4 makes it a server) running random shares.  I am removing 8 of these "servers" and installed a real server.  Since there is no logic behind what and where the shares are to begin with and most users have shares mapped staticly I need to know what people are connecting to.  A few years ago I created a script that run at logon and reported the mapped drives to a log file that was sent to a network share.  I have forgotten most of my scripting in that time and do not have the time to relearn it.  

Please help
Avatar of drequinox
drequinox

the following script will give you the list of all mapped drives

strComputer = "."
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colDrives = objWMI.ExecQuery("select * from Win32_MappedLogicalDisk")
WScript.Echo "Mapped Drives:"
for each objDrive in colDrives
    WScript.Echo " Device ID: " & objDrive.DeviceID
    WScript.Echo " Volume Name: " & objDrive.VolumeName
    WScript.Echo " Session ID: " & objDrive.SessionID
    WScript.Echo " Size: " & objDrive.Size
    WScript.Echo
next
oh and for log file you can see the following link ,, sorry I didnt mention that in my first post
found it from expers exchange !!!
https://www.experts-exchange.com/questions/23001616/Adding-log-file-to-script-VBscript.html
Avatar of kind4me

ASKER

Do you recomend running this as a logon script?  If so should I call it from the existing bat?
Avatar of kind4me

ASKER

Sorry I wasn't clear, I need to know what server and share each user is connecting to.  

As for the log, I am not sure how to incorporate that into the other script.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of kind4me
kind4me
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer