Category - VBScript
Contents Under Construction


Contents:
bar1
How To Enumerate Local Admin Members

bar1



Δ Scan IIS Log For - 500 Type Errors
Written by Eddie Jackson on Day, 11/xx/2009 xx:xx:00 PM [filed under VBScript]
bar1

For my Reference...

Here are our specs:


bar1
Here are our specs:
Scan IIS log for 500 type errors
Echo to screen the 500 type errors
bar1



'L A N G U A G E
'VBScript
'
'S C R I P T N A M E
'Scan_iis.vbs
'
'P U R P O S E
To scan iis log for -500 errors and outputs results to screen.
'
'U S A G E
Launch file
'
'A U T H O R
'Eddie S. Jackson
'
'D A T E C R E A T E D
'11/19/09


Dim strFilename, obj, objTS, strLine

strFilename = "IIS.log"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTS = objFSO.OpenTextFile(strFilename)
Do Until objTS.AtEndOfStream
strLine = objTS.ReadLine
If InStr(1,strLine," - 500") <> 0 Then
WScript.Echo strLine
End If
Loop
objTS.Close


bar1
Δ

bar1




Δ How To Use Send Keys
Written by Eddie Jackson on Day, 11/07/2009 xx:xx:00 PM [filed under VBScript]
bar1

For my reference:

WshShell.Sendkeys keys

or

WshShell.SendKeys("10")

BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER} or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC}
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}
SHIFT +
CTRL ^
ALT %

bar1
Δ

bar1



Δ 
How To Enumerate Local Admin Members
Written by Eddie Jackson on 07/27/2009 00:00:00 PM [filed under VBScript & Reporting]
bar1
 

So my manager comes to me asking for a report with the local admin members for all workstations on our network, which is thousands of computers. We are realizing the security risks of having so many unknown members of the local admin group. So now we gather the information and begin removing members that do not need to be a part of the local admin group.

bar1
Here are our specs:


Query the local admin group
Output results to log file, to be imported into Excel spreadsheet
Log if workstation is offline
Must be coded and report compiled in 1 day
bar1

For those of you who need to run such a report that enumerates all members of the local admin group, enterprise wide, this is what you're looking for. I am going to modify the code to make it a comma delimited file, but for right now it outputs to a text file, seperated by carriage return or character ^13 if you would like to replace it with commas manually. The comma seperated file will serve you better when importing into an excel spreadsheet.

bar1

Script:

' ******************************************************************
‘ Script Language: VBScript
‘ Script Name: localadminmembers.vbs
‘ Purpose: QUERIES LOCAL ADMIN GROUP FOR MEMBERS
‘ Creation Date: 07/27/09
‘ Last Modified:
‘ Author: EDDIE JACKSON
‘ E-Mail: EDDIE.JACKSON@halifax.org
'*******************************************************************

On Error Resume Next
Const ForWriting = 2
' Variable for admin group name, modify this
' variable if the administrators account has
' been renamed.
strAdminGroup = "Administrators"
' Format date/time stamp for output file
strTimeDate = Year(Date) & "-" & Month(Date) & _
"-" & Day(Date) & "~~" & Hour(Time) & "-" & _
Minute(Time)
' Output file name and path
strLogFile = "C:\adminaccounts-" & strTimeDate & _
".txt"

'Create Log File
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile (strLogFile, _
ForWriting, True)

' Connect to domain and collect computer accounts
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
set objRootDSE = GetObject("LDAP://RootDSE")
objCommand.CommandText = _
"SELECT Name, Location FROM 'LDAP://" & _
objRootDSE.Get("defaultNamingContext") & "'" _
& "WHERE objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

' Output domain computer accounts, connect to each
' computer, and enumerate admin account members
Do Until objRecordSet.EOF
strComputer = objRecordSet.Fields("Name").Value
objFile.WriteLine "System: " & strComputer
Set objGroup = GetObject("WinNT://" & strComputer & _
"/" & strAdminGroup)
If Err <> 0 Then
objFile.Writeline("*** System Unreachable ***")
Err.Clear
Else
For Each member In objGroup.Members
objFile.WriteLine member.Name
Next
End If
objRecordSet.MoveNext
objfile.writeline()

Loop



bar1
Δ

bar1
































 


..About

..I'm a Computer  
..Systems Engineer


..L
iving and loving life

........................................


..Author
....




..Categories

....< AD
....< Exchange 
....< SQL
....< Windows
....< VBScript
....< Shell
....
<
Javascript
....< HTA
....< PowerShell
....< Reporting
....< Healthcare
....< Networking
....< General



..
Archives


....< November 2009
....<
October 2009
....<
September 2009

....
<
August 2009
....< July 2009