Kaseya Community

'net use' mapped drives

  • Can anyone tell me how to grab the contents of the 'net use' command and throw it to a log file for reporting on.

    The reason is... we've been asked to audit many workstations but they also need to know which mapped networkdrives each pc has.

    The audit doesn't show these details unfortunately.

    Thanks in advance Smile


    Legacy Forum Name: 'net use' mapped drives,
    Legacy Posted By Username: ituk1
  • You can try to run a script that executes

    net use > netuse.txt

    Then bring back the txt file. Or send the contents of the txt file in an email. Or write the contents to the script log so you can report on it.


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: vplaza
  • Can you tell me how to write the contents to the script log?

    Thanks




    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: ituk1
  • One way is to:


    1. Execute the shell command to write the "net use" command to a txt file. Such as "net use > netuse.txt".
    2. Do a "Get Variable and select the type of value to get from the Agent" to be "File Content". You then give it the file name, such as "netuse.txt", and then specify a variable name to receive it, such as "NetUseResults".
    3. Then do a "Write Script Log Entry" and use "#NetUseResults#". This will write the contents of that variable, which had the contents of the txt file, which had the results of the "net use" command.

    I know others are better at explaining scripts than I am, but that is one way to get this.


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: vplaza
  • Thanks.

    We are new to Kaseya so scripting is slowly falling into place. You make perfect sense thanks.

    We're struggling with real good reference points for Kaseya scripting and find the forums the best place. Do you know of any good 'easy to follow'documentation for the product?

    Regards

    Duncan


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: ituk1
  • Duncan,

    The Help documentation and the forums are what we've used. As for scripting, the Help documentation is NOT quite as helpful, which is where the forums come in. I think that once you get your arms around a few scripts that you create or modify from others, you will be okay.

    It's not too terribly difficult.

    Good luck!

    Vince


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: vplaza
  • I've actually put a feature request in for this.

    On any of the execute commands (execute file, execute file in directory path, execute shell command) is it possible to add 1) a checkbox that says "capture output to variable" and 2) a textbox to define the variable name?

    I don't know if there is a better way, but for me to capture a commands output I have to:
    delete temp file (in case it didn't delete on a previous attempt)
    execute command, piping output to a temp file
    read temp file to variable
    delete temp file

    it would be far easier to do
    execute command, capture output to

    Is there an easier way, or have I come up with a good one? Smile


    Legacy Forum Name: Script Requests,
    Legacy Posted By Username: Anthony Michaud
  • We have found this script andVBS file to be very effective:

    Script Name: List Mapped Drives
    Script Description: This script copies listmappeddrive.vbs to the client's C:\temp folder and executes it, which generates a text file with the list of mapped drives. It then copies this list into the client's Script Log on the KServer. From there, run a report on the script to get the results.

    IF User Is Logged In
    Parameter 1 :
    THEN
    Delete File - (Continue on Fail)
    Parameter 1 : c:\temp\drives.txt
    OS Type : 0
    Delete File - (Continue on Fail)
    Parameter 1 : c:\temp\listmappeddrives.vbs
    OS Type : 0
    Write File
    Parameter 1 : c:\temp\listmappeddrives.vbs
    Parameter 2 : VSASharedFiles\listmappeddrives.vbs
    OS Type : 0
    Execute Shell Command
    Parameter 1 : wscript.exe "c:\temp\listmappeddrives.vbs"
    Parameter 2 : 0
    OS Type : 0
    Get Variable
    Parameter 1 : 1
    Parameter 2 : c:\temp\drives.txt
    Parameter 3 : drivelist
    OS Type : 0
    Write Script Log Entry
    Parameter 1 : #drivelist#
    OS Type : 0
    Delete File - (Continue on Fail)
    Parameter 1 : c:\temp\drives.txt
    OS Type : 0
    Delete File - (Continue on Fail)
    Parameter 1 : c:\temp\listmappeddrives.vbs
    OS Type : 0
    ELSE
    Write Script Log Entry
    Parameter 1 : User not logged in.
    OS Type : 0
    '**********************************************************************************
    '**********************************************************************************
    '**********************************************************************************
    '
    ' ListMappedDrives.vbs
    '
    ' A vbscript to write a list of mapped drives to a text file which can be
    ' reported to Kaseya. The file name is c:\temp\drives.txt.
    '
    ' Created by Rob Pennoyer on Decemeber 19, 2005.
    '
    ' No customization required, unless your target machine doesn't have a c:\ drive.
    '
    '**********************************************************************************
    '**********************************************************************************
    '**********************************************************************************


    Option Explicit
    Dim objNetwork, objDrive
    Dim intDrive, fs, logfile
    Set objNetwork = CreateObject("Wscript.Network")
    Set objDrive = objNetwork.EnumNetworkDrives()
    Set fs = CreateObject("Scripting.FileSystemObject")

    set logfile = fs.CreateTextFile("c:\temp\drives.txt", True)
    For intDrive = 0 to objDrive.Count -1 Step 2
    logfile.WriteLine(objDrive.Item(intDrive) & " ---> " & objDrive.Item(intDrive+1) & "
    ")
    Next
    logfile.Close

    set objNetwork = Nothing
    set objDrive= Nothing
    set fs = Nothing


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