Presentation is loading. Please wait.

Presentation is loading. Please wait.

VBScript Tim Sirgo www.personal.kent.edu/~tsirgo/nmproject.ppt.

Similar presentations


Presentation on theme: "VBScript Tim Sirgo www.personal.kent.edu/~tsirgo/nmproject.ppt."— Presentation transcript:

1 VBScript Tim Sirgo www.personal.kent.edu/~tsirgo/nmproject.ppt

2 Comparison VB.Net GUI Visual Studio VBScript Plain Text Use text editor (e.g. Notepad)

3 WMI Windows Management Instrumentation (WMI) is a scalable system management infrastructure that uses a single, consistent, standards-based, extensible, object- oriented interface.system management

4 WMI Provides a way to interact with system management information

5 WMI 1. Connect to WMI object 2. Run a query against it Query is structured similar to SQL “Select * from …”

6 SWBEM Instead of WMI “moniker string” "{impersonationLevel=impersonate}!\\" Use domain credentials objswbemlocator.connectserver(strcomputer, "root\cimv2", "nm.xyz\" & strusername, strpassword)

7 Code In following slides www.personal.kent.edu/~tsirgo

8 Credentials do until strusername <> "" strusername = inputbox("Enter user name", "username") if isempty(strusername) then wscript.quit end if loop do until strpassword <> "" strpassword = inputbox("Enter password - WARNING: THE PASSWORD WILL NOT BE HIDDEN", "password") if isempty(strpassword) then wscript.quit end if loop

9 Output Files set objfso = createobject("scripting.filesystemobject") set IPoutfile = objfso.createtextfile("IPAddresses.txt", True) set NICoutfile = objfso.createtextfile("NIC.txt", True) NICoutfile.writeline("Computer Name, Adapter Type ID, AutoSense, Description, DeviceID, Index, MAC, Manufacturer, Speed, MAX Speed, Connection Status") IPoutfile.writeline("Computer Name, IPAddress")

10 SWbem set objswbemlocator = createobject("wbemscripting.swbemlocator") set objswbemservices = objswbemlocator.connectserver(strcomputer, "root\cimv2", "nm.xyz\" & strusername, strpassword) set colswbemobjectset = objswbemservices.execquery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = TRUE")

11 IP Address for each ipconfig in colswbemobjectset if not isnull(ipconfig.ipaddress) then for i=lbound(ipconfig.ipaddress) to ubound(ipconfig.ipaddress) IPoutfile.writeline(strcomputer & ", " & ipconfig.ipaddress(i)) next end if next

12 NIC set colswbemobjectset = objswbemservices.execquery("Select * from Win32_NetworkAdapter") for each objitem in colswbemobjectset select case objitem.adaptertypeid case 0 stradaptertype = "Ethernet 802.3" case 1 stradaptertype = "Token Ring 802.5" case 2 stradaptertype = "FDDI - Fiber" case 3 stradaptertype = "Wide Area Network" case 4 stradaptertype = "LocalTalk" case 5 stradaptertype = "Ethernet using DIX header" case 6 stradaptertype = "ARCNet" case 7 stradaptertype = "ARCNET 878.2“ case 8 stradaptertype = "ATM" end select

13 NIC (cont.) (for each objitem in colswbemobjectset) NICoutfile.writeline(strcomputer & ", " & stradaptertype & ", " & objitem.autosense & ", " & objitem.description & ", " & objitem.deviceID & ", " & objitem.index & ", " & objitem.macaddress & ", " & objitem.manufacturer & ", " & objitem.speed & ", " & objitem.maxspeed & ", " & objitem.netconnectionstatus) next loop

14

15

16

17

18

19

20

21 Errors

22

23

24

25

26 Resource Sites Microsoft TechNet Script Center W3schools DevGuru


Download ppt "VBScript Tim Sirgo www.personal.kent.edu/~tsirgo/nmproject.ppt."

Similar presentations


Ads by Google