-
Notifications
You must be signed in to change notification settings - Fork 4
/
Remote Processes Dump.vbs
48 lines (34 loc) · 1.57 KB
/
Remote Processes Dump.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
' Author: Alistair McMillan
' Start Date: 31 October 2012
' -----------------------------------------------
Option Explicit
Dim strComputer, strFilename, objFileSystem, objFile, objSWbemLocator, _
objSWbemServices, colItems, objItem, strMachineName
strComputer = InputBox("Enter full computer name (i.e. SWSA29565) or IP address. Leave blank to run against your own PC.")
If IsEmpty(strComputer) Then
WScript.quit()
ElseIf strComputer = "" Then
strComputer = "."
End If
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = GetObject( "winmgmts://" & strComputer & "/root/cimv2" )
objSWbemServices.Security_.ImpersonationLevel = 3
' Basic info
Set colItems = objSWbemServices.ExecQuery("select * from Win32_ComputerSystem")
For Each objItem in colItems
strMachineName = objItem.Name
Next
strFilename = strMachineName + ".csv"
Set objFile = objFileSystem.OpenTextFile(strFilename, 8, True)
' RAM
objFile.WriteLine("MACHINE, PROCESS ID, PROCESS NAME, WORKING SET (MB), PAGE FILE USAGE (MB), COMMAND")
Set colItems = objSWbemServices.ExecQuery("select * from Win32_Process")
For Each objItem in colItems
objFile.WriteLine(strMachineName & ", " & objItem.ProcessId & ", " & objItem.Name& ", " & Round(objItem.WorkingSetSize/1024/1024, 2) & ", " & Round(objItem.PageFileUsage/1024/1024, 2) & ", " & objItem.CommandLine )
Next
objFile.Close
set objFile = NOTHING
set objFileSystem = NOTHING
Wscript.Echo "DONE. Created " & strFilename
Wscript.Quit