Avatar of kind4me
kind4me
Flag 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
Active Directory

Avatar of undefined
Last Comment
kind4me

8/22/2022 - Mon
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
drequinox

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
kind4me

ASKER
Do you recomend running this as a logon script?  If so should I call it from the existing bat?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
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
kind4me

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.