VBScript - PowerPoint PPT Presentation

About This Presentation
Title:

VBScript

Description:

VBScript. Plain Text. Use text editor (e.g. Notepad) WMI. Windows Management Instrumentation (WMI) is a scalable system management ... – PowerPoint PPT presentation

Number of Views:401
Avg rating:3.0/5.0
Slides: 27
Provided by: Bri96
Category:
Tags: vbscript

less

Transcript and Presenter's Notes

Title: VBScript


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.

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
  • "impersonationLevelimpersonate!\\"
  • 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 ltgt ""
  • strusername inputbox("Enter user name",
    "username")
  • if isempty(strusername) then
  • wscript.quit
  • end if
  • loop
  • do until strpassword ltgt ""
  • 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.filesystemobj
    ect")
  • 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.connectse
    rver(strcomputer, "root\cimv2", "nm.xyz\"
    strusername, strpassword)
  • set colswbemobjectset objswbemservices.execquer
    y("Select from Win32_NetworkAdapterConfiguratio
    n Where IPEnabled TRUE")

11
IP Address
  • for each ipconfig in colswbemobjectset
  • if not isnull(ipconfig.ipaddress) then
  • for ilbound(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
(No Transcript)
15
(No Transcript)
16
(No Transcript)
17
(No Transcript)
18
(No Transcript)
19
(No Transcript)
20
(No Transcript)
21
Errors
22
(No Transcript)
23
(No Transcript)
24
(No Transcript)
25
(No Transcript)
26
Resource Sites
  • Microsoft TechNet Script Center
  • W3schools
  • DevGuru
Write a Comment
User Comments (0)
About PowerShow.com