Announcement

Collapse
No announcement yet.

How to make batch script to write in shared network directory ?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to make batch script to write in shared network directory ?

    Hi All,

    I just wondering and would like to know if batch script can write the result of this powershell script into shared network drive ? [so that i can gather the result of the script in one single location]

    Code:
    md %computername%
    cd %computername%
    
    ver > Evidence_Basic.txt
    
    wmic computersystem get Domain, Name >> Evidence_Basic.txt
    
    wmic service where state="Running" get DisplayName, Caption > Evidence_Running.txt
    
    netstat -an | findstr /I "listen udp" | find /V "127.0.0.1" > Evidence_netstat.txt
    
    wmic startup list brief > Evidence_Start.txt
    
    ipconfig | findstr /C:"IP Address" >> Evidence_basic.txt
    
    reg query "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\rdp-tcp" | findstr /I "minencryptionlevel" > Evidence_reg_query_mine.txt
    
    wmic service where name="EventLog" get Name, SystemName, StartMode, Status > Evidence_service_event.txt
    
    net time /querysntp >> Evidence_basic.txt

    any kind of help would be greatly appreciated.

    Thanks.

  • #2
    Re: How to make batch script to write in shared network directory ?

    Code:
    @ECHO OFF
    net use Z: \\server\sharename /user:username password
    xcopy /e /v /y *.* Z:\
    net use Z: /delete
    That will map your network share, copy your %computername% directories to the network share, and then delete the drive mapping.

    Comment


    • #3
      Re: How to make batch script to write in shared network directory ?

      Originally posted by georgeeye View Post
      Code:
      @ECHO OFF
      net use Z: \\server\sharename /user:username password
      xcopy /e /v /y *.* Z:\
      net use Z: /delete
      That will map your network share, copy your %computername% directories to the network share, and then delete the drive mapping.
      and also delete the batch script itself along with the result file ?
      my goal is to leave the servers with no footprints or trace.

      Comment


      • #4
        Re: How to make batch script to write in shared network directory ?

        xcopy does not delete
        net use Z: /delete does not actually delete the file, just the pointer to the mapped network drive (IE: Mycomputer will no longer show Z

        Could you be more specific on what you are trying to do?

        What do you mean by no footprint / trace?

        If you are running this from the server itself you could just modify the script to:

        Code:
         
        net use Z: \\server\sharename /user:username password
        z:\
        md %computername%
        ver > z:\%computername%\Evidence_Basic.txt
        How many machiens are you running this on and how far back do you want to keep the logs?

        If they are overwritten everyday you are fine, otherwise I would rename the results filename to be more of:
        DD_Evidence_Basic.txt (Where DD = Day or 19_Evidence_Basic.txt)
        MM_DD_Evide... for a year copy (MM = Month, DD = Day)
        MM_DD_YYYY_Evide... for a forever log

        You could also run this remotely by various methods so the script is not on the computer it ran on.

        Google: Powershell remotely

        Hobie
        Last edited by Hobie; 19th June 2011, 20:12.

        Comment

        Working...
        X