Kaseya Community

Monitor Network Drives and auto-reconnect

  • I know how to run a script to reconnect a network drive for my clients if it does fail, but what I am looking for is a way to continuously monitor a machine's network drives and if for some reason a drive disconnects or doesn't reconnect on a bootup Kaseya would know and automatically run the script to reconnect that particular network drive.



    Anyone have any ideas on a way to monitor or do this?


    Legacy Forum Name: Monitor Network Drives and auto-reconnect,
    Legacy Posted By Username: tom@tbkconsulting.biz
  • How often do you want to check? You could deploy a Kaseya script, scheduled to run every 1 minutes or so, that does the following:

    - tests existence of a file on the mapped drive you are interested in. If required, create a file called "Exist.txt" in the root of the share and test for that. You could also have the Kaseya script test for existence of a directory or something too.
    - if the file exists, you can assume that the drive is mapped. exit.
    - if the test fails, run the following shell commands, as the user:
    net use s: /del
    net use s: \\\\server\\share


    Personally, I don't like the overhead of running a script every minute, but the idea should work.



    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: BulletproofSean
  • The best way i have found to do this kind of thing is to setup a WMI Event Consumer.

    Its basically a combination of the ExecNotificationQuery within WMI and an Event Filter (say, checking the existence of a mapped drive)...from here, you can log something to the Event Log for recording and also kick off a repair script for your mapped drive.


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: jkurth
  • The best way i have found to do this kind of thing is to setup a WMI Event Consumer.

    Its basically a combination of the ExecNotificationQuery within WMI and an Event Filter (say, checking the existence of a mapped drive)...from here, you can log something to the Event Log for recording and also kick off a repair script for your mapped drive.


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: jkurth
  • So you're suggesting configuring something on the remote machine to log to the event log, then have kaseya watch the event log for a specific message, and then act on it?



    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: BulletproofSean
  • Well, both, you can repair the mapped drive issue directly from the WMI Event Filter so that you arent dependent on kaseya to fire down a separate script. The only reason you would want to post something to the logs is if you wanted to create a track history that you could then report on.

    This is the best and quickest solution as it will process the fix the instance that it polls for that shared drive and doesnt see it.

    There are a few gotchas when working with WMI Consumers but they are very easy to manage and circumvent. The greatest thing about them is that they become part of the OS and arent dependent on a 3rd party service or internet connection...


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: jkurth
  • Is it feasable to deploy via a kaseya script or package or would you just set it up via remote control?

    If you really think about it, how often do network drives just disconnect themselves? I've never really seen it. Either the user has done it inadvertently, the server is down, or the share got removed. In all of those cases, you have other problems.

    In a domain environment where you can enforce drive connections via policy and/or logon script, I don't see much need for this. _Maybe_ in a peer to peer environment where there is no central management, but a WMI consumer constantly monitoring its state also seems like overkill.

    It begs the question...what's the real issue? What's actually happening that requires this drive connection to be monitored so closely?


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: BulletproofSean
  • Yes thats exactly how you would ideally deliver it, through a kaseya script. I would create a script that accepted several variables (off the top of my head: the drive letter, frequency for polling the WMI service, server/unc path name to share, user/password credentials to establish the connection...im sure there are more)




    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: jkurth
  • The WMI Script is something more along the lines of what I was looking for ... the overhead of running a Kaseya script every minute or so would slow an already older(SLOW) machine down to the point the user would complain even more. And yes it does beg the question as to what is really happening ... it's a user error, inadvertently or even on purpose removing the networked drive and then complains that other programs do not work or portions of programs do not work, etc ... it's sabotage ... and I want to be able to avoid it cleanly.

    I don't know the WMI scripting very well, could one of you fine people give me a hand here and post a sample script for me???



    Thanks!


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: tom@tbkconsulting.biz
  • Another fix might be to bill him everytime you have to fix it.


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: BulletproofSean
  • here is a good place to start:

    http://tinyurl.com/ydc4ld

    there is an example script that ms offers in here where they use the WMI class VolumeChangeEvent...you can modify this to call to the MappedLogicalDisk class like so:

    "Select * from Win32_MappedLogicalDisk"

    then set a variable to the mapped drive you want to monitor in the do loop and create a if statement. If the drive doesnt exist...run your map drive process, otherwise, do nothing.

    Hope this gets you in the right starting spot. Its better to figure this kind of stuff out on your own as you will learn more. If you want me to post the complete script I can do that also.


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: jkurth