Moving

•November 3, 2009 • Leave a Comment

Just to let everyone know, I am moving my blog off to my own server. The new address will be blog.christophermichaelwebb.com. I had resisted for quite a while as wordpress has some powerful clout on the search engines, but I feel it’s for the best as I like to have full control over my sites. Hope to see you all there.

Burnt Out?

•November 2, 2009 • Leave a Comment

You know, I think my main reason for going into IT was that it is constantly changing and there is so much to learn that it seems constantly new. I started in consulting and loved it. Everyday somewhere new, a new task with new technologies. After a while, I grew curious of what it would be like to work in a dedicated environment. This period coincided with a time of downsizing at the consulting firm I was with. I took the opportunity to hop on at a data center with Lockheed Martin. At first, I thought it would be exciting, learning about clustering and the different issues that are involved with large enterprise environments. Honestly, though, it’s pretty boring. At our office, we have no senior systems administrators, so there isn’t really anyone to observe or learn from. I’m not saying that the guys I work with aren’t smart, not by any means. We just all lack that experience and the other benefits that come with it. The environment we are in is pretty stale, it has been running for a couple years now and is 90% stable and with everything being redundant, there never seems to be an emergency. Really, this is what most companies want and something that I would love to set up, but i feel no connection to the environment as I had no part in the installation or configuration of any of it.

One thing that has made my time with Lockheed wonderful is the scripting. I got to really dive in and learn scripting and WMI and how AD works because there are constantly large, mundane tasks that need done across the network. I started doing a lot of scripting. I think that my big debate right now is “Where do I want to go with my career?” I like the consulting work and administration when there is opportunity for change, but really, i feel like my true passion for IT comes with the idea of creation. I loved setting up networks from scratch, from the routers, to switches, to deciding which servers, desktops, and OS’s to use. There was a lot of control there, but I don’t think the control is the main thing that made me love it. I have been studying up on Visual Basic and .NET 3.5 lately, to try to get into application development. I would like to move to C++, but already have a fairly solid knowledge of VB to start there. My thought is creating versus maintaining, obviously creating is more exciting(at least to me). I guess I’m not sure what I want, I just feel a bit burnt out and can’t seem to focus today. There hasn’t been anything too exciting for me to post lately, either, so I thought I would just throw my thoughts up as an update.

How to Set Folders View in Explorer Bar Permanently

•October 27, 2009 • Leave a Comment

I have always hated that i need to go to View>Explorer Bar>Folders every time I need to get the folder view on the left, or even right-click>Explore. I want it there all the time. This little trick I learned from a colleague really helped me out.

First open My Computer
GoTo View>Explorer Bar>Folders
Here’s the trick to make it stick:
Now, goto Tools>Folder Options>File Types
Find the entry that is a folder icon with (none) next to it.
Click it, goto Advanced.
Click Explore
Then click Set Default

Voila! Now, every time you open an explorer window, the folder view will be on the left.

Killing Processes on Server 2000 from VBScript

•October 8, 2009 • Leave a Comment

Alright, so we have a report server that has a massive SQL database and is running Server 2000 SP4. I honestly don’t know too much about it, because we have a DBA who does pretty much 90% of the maintenance/admin work on this server and the reports have nothing to do with the programs I work with. Anyway, the reports that are run export the SQL data to Excel spreadsheets. Once the report is run, the Excel process is left running. This server is already extremely old and bogged down as is, so having over a hundred instances of Excel running on it wasn’t helping. I wrote a script to check for all processes named “excel” and see how long they have been running, then kill the ones that were running for what seem to be too long of time. I had some issues, because Server 2000 does not have all of the capabilies as 2003, obviously. This script requires that you download pskill, part of the PSTools suite from SysInternals(now Microsoft). Now, while the script requires PSKill, it is able to run on server 2000/2003/2008(and 2000/xp/vista/7), so hopefully it is still useful to someone else out there. The script is below and I tried to make sure it was well-commented to help you out. Feel free to leave any suggestions/questions below. Enjoy.


''''This script requires pskill, part of the PSTools suite from SysInternals(now Microsoft). This script is assuming pskill is in your path for cmd line(generally, c:\windows(winnt on 2000/nt)\system32\)

Option Explicit
Dim strComputer, objWMIService, colProcessList, objProcess, PDate, Days, Hrs, Min, Sec, objSWbemLocator, WshShell
strComputer = "."
Set WshShell = CreateObject("wscript.shell")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'Excel.exe'") ' Replace Excel with whatever the process is you're looking for.
Do
If colProcessList.Count = 0 Then ' This kills the script if the process we are looking for is not running.(also ties with last commented line for looping)
Exit Do
Else
For Each objProcess in colProcessList
If objProcess.CreationDate "" Then
PDate = Left(objProcess.CreationDate,14) ' pulls the date process started in format: yyyymmddhhmmss
Days = DateDiff("d",DateSerial(Left(PDate,4),Mid(PDate,5,2),Mid(PDate,7,2)),Date) ' find how many days process has been running
Hrs = Hour(Now) - Mid(PDate,9,2) ' find how many hours process was running, if started same day
Min = Minute(Now) - Mid(PDate,11,2) ' same but for minutes
Sec = Second(Now) - Mid(Pdate,13,2) ' same but for seconds
If Hrs > 6 Then ' This is where you specify how long the process has to have been running in order for it to be killed, so you don't kill active jobs. Change it from "Hrs" to "Min" or "Sec" for minutes or seconds. Change 6 to whatever number of units.(currently set to kill processes over 6 hours old)
WshShell.Run "pskill -t " & objProcess.ProcessId, 0, False
Else
If Days > 0 Then ' This is a failsafe to the previous "If". Since it only detects how many hours process was running, if started same day. This guarantees that it kills anything over a day old.
WshShell.Run "pskill -t " & objProcess.ProcessId, 0, False
End If
End If
End If
Next
WScript.Sleep 1000 ' wait before trying again
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'Excel.exe'") ' Recheck for processes ' This makes the script keep looking until there aren't any active processes. i.e. a report is being run now, we will wait until it is done to kill the process and the script.
End If
Loop

Login Script for Everyone

•September 21, 2009 • Leave a Comment

We have a new program in with a new domain. On our other networks, there are seperate logon scripts for pretty much every security group and they all call other scripts. With this network, i wanted to keep things simple, so this script connects to AD and checks their group membership before running the apropriate commands for each group. This particular network does not have any shares yet, and isn’t very complex, but here is the base of it. Let me know if you want to know how to add anything more to it.

Option Explicit
Const ADS_PROPERTY_APPEND = 3 'sets the variable to Append
Const ADS_UF_NORMAL_ACCOUNT = 512
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
CONST HKEY_LOCAL_MACHINE = &H80000002
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Dim WshShell : Set WshShell = CreateObject("wscript.shell")
Dim strContainer, strUser, i, objRootDSE, strDisplayName, ObjFSO, objInFile, objContainer, strLine, strName, objOU, objGroup, objUser, objFile, objFile2, varDomainNC, objRoot, strText, FirstLine, arrMemberOf, Group, strFirstName, strLastName, strLine2, objOU2, objNetwork, strGroup, objConnection, objCommand, objRecordSet, objErrorLog, strComputer, colItems, objWMIService, colInstalledPrinters, strComputer2
Set objOU2 = GetObject("LDAP://CN=users,DC=arra,DC=local")
Set objOU = GetObject("LDAP://OU=arra-users,DC=arra,DC=local")
ObjOU.Filter= Array("user")
Set objGroup = objOU2.Getobject("group", "cn=CSRs")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = WScript.CreateObject("Wscript.Network")
Set objRootDSE = GetObject("LDAP://rootDSE")
strComputer2 = "."
Dim CRLF
CRLF = Chr(13) & Chr(10)

'*************(Global Scripting) this section applies to all computers no matter what group users are in.

''default lockheed banner script
Function Ask(strAction)

Dim intButton
intButton = MsgBox(strAction, _
vbQuestion + vbYesNo, _
L_Welcome_MsgBox_Title_Text )
Ask = intButton = vbYes

End Function

MsgBox "This system is the property of this Corporation, and is intended for" & CRLF & _
"the use of authorized users only. All activities of individuals using this computer" & CRLF & _
"with or without authority, or in excess of their authority, may be monitored and recorded" & CRLF & _
"by system personnel. If any such monitoring reveals evidence of criminal activity or is in" & CRLF & _
"violation of foreign or U.S. state or federal law, such evidence may be provided to law" & CRLF & _
"enforcement officials and/or used for further legal action by this Corporation and/or the" & CRLF & _
"organization's Information Protection group. Unauthorized use of this system is prohibited" & CRLF & _
"and may result in revocation of access, disciplinary action and/or legal action. The" & CRLF & _
"company reserves the right to monitor and review user activity, files and electronic messages." & CRLF & _
"REMINDER: Information transmitted to a foreign person on this network may be subject " & CRLF & _
"to applicable Export Control laws. Contact your Export Coordinator for assistance." & CRLF & _
"(This machine is not authorized for classified processing)", _
vbOKOnly, _
"SYSTEM USE MONITORING NOTICE - IPM-003 Banner Statement"

'*************End of global scripting

''pull local computer name for loggin info.
strComputer = objNetwork.ComputerName

''pull logon id
strUser = objNetwork.UserName

''turn logon id into container name for LDAP queries

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = ";(&(objectCategory=User)(samAccountName=" & strUser & "));name;subtree"
Set objRecordSet = objCommand.Execute
On Error Resume Next
strUser = objRecordSet.Fields("name")
On Error GoTo 0
objConnection.Close
Set objRecordSet = Nothing
Set objCommand = Nothing
Set objConnection = Nothing

''set user to have LDAP queries run
Set objUser = GetObject("LDAP://cn=" & strUser & ",ou=arra-users,dc=arra,dc=local")

''\/\/\/\/\/\/Determine Group memberships. PLEASE NOTE: group names must be in UPPER case and the "Left(strGroup, X)"
' X must be the number of characters in the group name.
'\/\/\/\/\/\/\/

arrMemberOf = objUser.GetEx("memberOf")

If Err.Number E_ADS_PROPERTY_NOT_FOUND Then
For Each Group in arrMemberOf
strGroup = UCase(Group)
strGroup = Right(strGroup, Len(strGroup) - 3)
If Left(strGroup, 2) = "IT" Then
'*****IT group scripting

''set Z:IT drive
WshShell.Run "net use z: /delete", 0, False
WshShell.Run "Net use z: \\indarradc04\it", 0, False

''Prepare to set printers
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

''This prevents script from stopping when mapping network printers on the server where they
''are shared from
ON ERROR RESUME NEXT

''Add Printers
objNetwork.AddWindowsPrinterConnection("\\indarradc03\Xerox WorkCentre 5675 PS")

'*****End of IT
Else
If Left(strGroup, 4) = "CSRS" Then
'*****CSR group scripting

'*****End of CSR
Else
If Left(strGroup, 10) = "MANAGEMENT" Then
'*****Management group scripting - NOTE: all managers are members of "Team Leads" group

'*****End of Management
Else
If Left(strGroup, 10) = "TEAM LEADS" Then
'*****Team Lead scripting

''Prepare to set printers
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

''This prevents script from stopping when mapping network printers on the server
''where they are shared from
ON ERROR RESUME NEXT

''Add Printers
objNetwork.AddWindowsPrinterConnection("\\indarradc03\Xerox WorkCentre 5675 PS")

'*****End of Team Lead
End If
End If
End If
End If
Next
Else
'*****Create Error Log if groups could not be determined

Set objErrorLog = objFSO.OpenTextFile("\\indarradc04\errors\signonerrors.txt", ForAppending, True)
objErrorLog.WriteLine strUser & " on " & strComputer & " could not be found in Active Directory on " & Date
Err.Clear
End If

Again, let me know if you need help modifying/adding anything for your own use.

**UPDATE(9/25)**

Changed the
WshShell.Exec(“net use…”)
lines to
WshShell.Run “net use…”, 0, False

This allows us(and does it already) to set any outside commands or scripts(in this case mapping drives, but can call bat files or whatever) to run invisibly(the 0), and “False” says to continue with the rest of the script immediately, True would mean to wait for the outside command to complete before continuing. This site has the details.

Run Method(Windows Script Host)

Bulk Add of Users to Active Directory – vbscript

•September 21, 2009 • 2 Comments

This script is fairly basic. We have a temporary(7-12 month) program coming in and they need their own domain. They won’t have exchange or really need AD for anything except authentication and GPOs. This was made for server 2008, but everything works on 2000/2003. We got a list of 85 names for user accounts in a text file, so this is how i used them for input. anyway, here it is:

Option Explicit
Const ADS_PROPERTY_APPEND = 3 'sets the variable to Append
Const ADS_UF_NORMAL_ACCOUNT = 512
Const ForReading = 1
Dim strcontainer, strUser, i, objRootDSE, strDisplayName, ObjFSO, objInFile, objContainer, strLine, strName, objOU, objGroup, objUser, objFile, objFile2, varDomainNC, objRoot, strText, FirstLine, strFirstName, strLastName, strLine2, objOU2
Set objOU2 = GetObject("LDAP://CN=users,DC=arra,DC=local")
Set objOU = GetObject("LDAP://OU=arra-users,DC=arra,DC=local")
Set objGroup = objOU2.Getobject("group", "cn=CSRs")
strContainer = "ou=Arra-Users"
Set objFSO = CreateObject("Scripting.FileSystemObject")

'***********************************************
'* Connect to a container *
'***********************************************
Set objRootDSE = GetObject("LDAP://rootDSE")
If strContainer = "" Then
Set objContainer = GetObject("LDAP://" & _
objRootDSE.Get("defaultNamingContext"))
Else
Set objContainer = GetObject("LDAP://" & strContainer & "," & _
objRootDSE.Get("defaultNamingContext"))
End If
'***********************************************
'* End connect to a container *
'***********************************************

Set objInFile = objFSO.OpenTextFile("C:\Users\webbc\Desktop\Users.txt", ForReading)
Do until objInFile.AtEndOfStream
strLine2 = objInFile.ReadLine
FirstLine = 0

strText = Replace(strLine2, " ", "§§")
Dim arrText : arrText = Split(strText, "§§")

For Each strLine In arrText
If FirstLine 1 Then
FirstLine = FirstLine + 1
strLine = Replace(strLine, "§§", "")
strFirstName = strLine
Else
strLine = Replace(strLine, "§§", "")
strLastName = strLine
End If
Next

strUser = Left(strFirstName, 1) & strLastName
strDisplayName = strFirstName & " " & strLastName

Set objUser = objContainer.Create("User", "cn =" & strDisplayName)
objUser.Put "displayName", strDisplayName
objUser.Put "description", strLastName & ", " & strFirstName
objUser.Put "sAMAccountName", strUser
objUser.Put "givenName", strFirstName
objUser.Put "sn", strLastName
objUser.Put "userPrincipalName", strUser & "@arra.local"
objUser.Put "Homedrive", "h"
objUser.Put "scriptPath", "login.bat"
objUser.Put "HomeDirectory", "\\indarradc03\Home\" & strUser
objUser.SetInfo

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateFolder("\\indarradc03\Home" & "\" & strUser)

objUser.AccountDisabled = FALSE
objUser.Put "pwdLastSet", 0

'* edit the password to suit

objUser.SetPassword("NewPassword1")
objUser.SetInfo

objGroup.PutEx ADS_PROPERTY_APPEND, "member", Array("cn=" & strDisplayName & ",OU=arra-users,dc=arra,dc=local")
objGroup.SetInfo
Loop

Let me know if you have any questions.

Windows Updates and Proxy Servers

•September 3, 2009 • Leave a Comment

So, in our environment, we have several segregated networks. Each has their own (squid) proxy server and none have previously had issues with automatic updates. All were supposedly set the same way, with the proxy being pushed through group policy. The gpo was set to only push the proxy to normal users and not members of the IT team, mainly because we just don’t like having it. Anyway, there is one network that could not get the microsoft update web page to load. When we looked at the proxy, it looked as though it was redirecting the page to a null site. The reason it was only affecting the one network was: The other networks have the ability to bypass the proxy if the page didn’t load and it wasn’t listed as blocked, whereas this particular network was forced to have all traffice through the proxy. The key to making it work was one simple command:

proxycfg -p :

Anyway, i know this is a simple little post, but hope it helps someone.

UPDATE (9/17):

For Vista/Server 2008 use this command:

netsh winhttp set proxy [myproxy]:[myport]

Project Euler – Problems 1 & 2

•August 27, 2009 • Leave a Comment

So lately I got a little bored and stumbled upon Project Euler. It is basically a site with 250+ complex math/programming problems. It has been quite a bit of fun, even though I am only on the 3rd problem. I thought that i would post my VB(.NET 3.5) code that I used for the first 2 problems. If you don’t want to know the solutions, dont read further. Although, it is helpful to see the algorithm in other languages to make it work in your own code. For me, I think knowing what the final solution is would be best, so i can verify my algorithms worked before submitting. Anyway, below is problem 1


Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, ii, Multiples(0) As Integer
Dim X, Y As Double
X = 0
i = 0

Do Until X = 1000
If X / 3 = CInt(X / 3) Or X / 5 = CInt(X / 5) Then
ReDim Preserve Multiples(i)
Multiples(i) = X
Me.ListBox1.Items.Add(X)
i = i + 1
End If
X = X + 1
Loop

Y = 0
For ii = 0 To UBound(Multiples)
X = Multiples(ii)
Y = Y + X
Next
Me.Label1.Text = CStr(Y)
If Me.Label1.Text = "233168" Then
Me.Button2.Visible = True
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form2.WindowState = FormWindowState.Normal
Form2.Visible = True
Me.Visible = False
End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
End Class

And for Problem 2:


Public Class Form2

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim X, Y, Z, Numbers(1), i, ii, Evens(0), p As Long
Dim EvenString As String
Dim Q As Double
X = 1
Y = 2
Z = 0
i = 2
p = 0
Numbers(0) = X
Numbers(1) = Y
EvenString = ""

Do Until Z >= 4000000
Z = X + Y
X = Y
Y = Z
If Z >= 4000000 Then
Exit Do
End If
ReDim Preserve Numbers(i)
Numbers(i) = Z
i = i + 1
Loop
For ii = 0 To UBound(Numbers)
Me.ListBox1.Items.Add(CStr(Numbers(ii)))
Next
For ii = 0 To UBound(Numbers)
X = Numbers(ii)
Q = X / 2
If Q = CInt(Q) Then
ReDim Preserve Evens(p)
Evens(p) = Numbers(ii)
Me.ListBox2.Items.Add(CStr(Numbers(ii)))
p = p + 1
End If
Next
X = 0
Y = 0
For ii = 0 To UBound(Evens)
X = Evens(ii)
Y = Y + X
Next
Me.Label5.Text = CStr(Y)
If Me.Label5.Text = "4613732" Then
Me.Button2.Visible = True
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form3.WindowState = FormWindowState.Normal
Form3.Visible = True
Me.Visible = False
End Sub

Private Sub Problem1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Problem1ToolStripMenuItem.Click
Form1.WindowState = FormWindowState.Normal
Me.Visible = False
Form1.Visible = True
End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
Form1.Close()
End Sub
End Class

More to come… Enjoy!

VBScript to find a file (virtually) anywhere in the domain.

•August 5, 2009 • 5 Comments

Alright, I haven’t posted in a while, but I also haven’t had any new issues develop that I felt would be helpful or insightful to any of you out there. But today, I did have to write a script to find out if a file had been copied from the directory it was supposed to be in to any other place in the domain. At first, I thought they were crazy, but I turned to my good friend VBScript and got the job done. There are several pieces to this script, each very useful in it’s own right. First, it connects to the domain controller and finds out what domain you are in(handy if you work on several domains and don’t want to fiddle to make it work different places), then it makes a .txt file with every computer account in the domain on a line. The next step is pinging each of the machines listed to see if they are are available. Then, it connects and scans the C drive (via c$) for the file name recursively scans hidden folders and files as well. Then, it finds any shared folders on the system(say a server, where shares are not on C:) and scans them recursively. It reports if the file was found on the system or not and if it was, the exact location on the machine. Anyway, let me know if you have any questions on how to get this working for different scenarios or need to just make certain snippets work.

***Updated 8/7/09 with revisions to make script shorter, more efficient and work better with regular expression/pattern searching***

''Script to find all machines in AD, search C drive of all machines for a pattern in the filename, then search any shared folders for the file and reports
'' whether it was found and whether the machines are reachable by ping.
'' Side Note -- Can not scan shares on Windows 2000 or older, it will simply skip those shares. It will still scan C drive on Windows 2000, not NT

Option Explicit
CONST HKEY_LOCAL_MACHINE = &H80000002
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim strResultsFile, strServerName, strErrorNumber, strErrorDescription
Dim strAge, strLatestFile, strClientName, strDNSDomain
Dim strBase, strFilter, strAttributes, strQuery
Dim objWMIService, objLocator, objResultsFile, objRootDSE, objCommand, objConnection
Dim objRecordSet
Dim strSearchName
Dim objNetwork : Set objNetwork = CreateObject("WScript.Network")
Dim strFileName : strFileName = "computers.txt"
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim WshShell : Set WshShell = CreateObject("wscript.shell")
Dim i
Dim ii
Dim objFile, objCurrentFile, objTempList, objFS, objList, strCurrentFile2, objLogFile1, objLogFile2
Dim strComputer()
Dim strRet

'Here, you can put in the Regulare Expression pattern to use when searching.
Dim objRegEx : Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.IgnoreCase = True
objRegEx.Pattern = ".*pip_dvalles.*"

Dim IsFound
Dim strReply, png, strPing
Dim strList, objShare, strShare
Dim strShares()
Dim strDate, strTime, strHour, strMinute, strSeconds, Now, NowStart, ConnectTime
NowStart = Now
strResultsFile = "computers.txt"
strDate = CStr(Year(Date) * 10000 + Month(Date) * 100 + Day(Date))
strTime = Time
strHour = Hour (strTime)
strMinute = Minute (strTime)
strSeconds = Second (strTime)
Dim strFound, strNotFound
strFound = "C:\Found.txt"
strNotFound = "C:\NotFound.txt"

Set objLogFile1 = objFSO.OpenTextFile(strNotFound, ForAppending, True)
Set objLogFile2 = objFSO.OpenTextFile(strFound, ForAppending, True)

'Check for the presence of the Computer.txt file in the same folder as the script
If Not objFSO.FileExists(strFileName) Then

Set objResultsFile = objFsO.OpenTextFile (strResultsFile, ForWriting, True)
' Start getting a list of all servers from AD
' Determine DNS domain name from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
'Start the ADO connection
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection

'Set the ADO connection query strings
strBase = ""
strFilter = "(objectCategory=computer)"
strAttributes = "distinguishedName,objectCategory,name"

'Create the Query
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst

'Find all computers in the domain
While Not objRecordset.EOF
ON ERROR RESUME NEXT
strServerName = objRecordset.Fields("name")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strServerName & "\root\cimv2")
strErrorNumber = Err.Number
strErrorDescription = Err.Description

objResultsFile.WriteLine strServerName

'NEXT!
objRecordSet.MoveNext

Wend
objResultsFile.Close
WScript.Echo "All computer accounts in " & strDNSDOMAIN & " have been found." & vbCrLf & "Click OK to scan for file: " & objSearchFile
Set objFile = objFSO.OpenTextFile(strFileName, ForReading)
Else
Set objFile = objFSO.OpenTextFile(strFileName, ForReading)
End if

'start parsing through computer.txt
Do Until objFile.AtEndOfStream
isFound = FALSE
Redim Preserve strComputer(i)
strComputer(i) = objFile.ReadLine

'Ping Computers to make sure that they are reachable.
Set png = WshShell.exec("ping -n 1 " & strComputer(i))
Do Until png.Status = 1 : WScript.Sleep 10 : Loop
strPing = png.StdOut.ReadAll

'NOTE: The string being looked for in the Instr is case sensitive.
'Do not change the case of any character which appears on the
'same line as a Case InStr. AS this will result in a failure.
Select Case True
Case InStr(strPing, "Request timed out") > 1
strReply = "Request timed out"
Case InStr(strPing, "could not find host") > 1
strReply = "Host not reachable"
Case InStr(strPing, "Reply from") > 1
strReply = "Ping Successful"
End Select

' Connects to the operating system's file system
ON ERROR RESUME NEXT
Set objFS = GetObject("WinNT://" & strComputer(i) & "/LanmanServer,FileService")
objList = ""

' Loops through each share and checks for file
For Each objShare In objFS
strShare = LCase(objShare.name)
Set objTempList = WshShell.Exec("cmd /c dir /a/s/b \\" & strComputer(i) & "\" & strShare)
Do Until objTempList.StdOut.AtEndOfStream
objCurrentFile = objTempList.StdOut.ReadLine
If objRegEx.Test(objFSO.GetBaseName(objCurrentFile)) Then
strCurrentFile2 = objfSO.GetBaseName(objCurrentFile)
objLogFile2.WriteLine Now & " - The file " & objSearchFile & " was found on " & strComputer(i) & " at " & objCurrentFile
isFound = True
Else
If isFound = False Then
isFound = False
Else
isFound = True
End If
End If
Loop
objList = LCase(objShare.name) & vbCrLf & objList
Next

'Check for file on remote PC
Set objTempList = WshShell.Exec("cmd /c dir /a/s/b \\" & strComputer(i) & "c$")
Do Until objTempList.StdOut.AtEndOfStream
objCurrentFile = objTempList.StdOut.ReadLine
If objRegEx.Test(objFSO.GetBaseName(objCurrentFile)) Then
strCurrentFile2 = objfSO.GetBaseName(objCurrentFile)
objLogFile2.WriteLine Now & " - The file " & objSearchFile & " was found on " & strComputer(i) & " at " & objCurrentFile
isFound = True
Else
If isFound = False Then
isFound = False
Else
isFound = True
End If
End If
Loop

'Write to Not Found Log, if not found.
If isFound = False Then
objLogFile1.WriteLine Now & "No File matching the pattern (" & objRegEx.Pattern & ") was found on " & strComputer(i)
End If
Loop
objLogFile1.Close
objLogFile2.Close
WScript.Echo "Done scanning, LogFiles are located at:" & vbCrLf & strFound & vbCrLf & strNotFound & vbCrLf & "Click OK to finish"

Hope this helps someone out there.

System Administrator Appreciation Day!

•July 23, 2009 • Leave a Comment

July 31, 2009 (Last Friday Of July) is the 10th Annual System Administrator Appreciation Day!

A sysadmin unpacked the server for this website from its box, installed an operating system, patched it for security, made sure the power and air conditioning was working in the server room, monitored it for stability, set up the software, and kept backups in case anything went wrong. All to serve this webpage.

A sysadmin installed the routers, laid the cables, configured the networks, set up the firewalls, and watched and guided the traffic for each hop of the network that runs over copper, fiber optic glass, and even the air itself to bring the Internet to your computer. All to make sure the webpage found its way from the server to your computer.

A sysadmin makes sure your network connection is safe, secure, open, and working. A sysadmin makes sure your computer is working in a healthy way on a healthy network. A sysadmin takes backups to guard against disaster both human and otherwise, holds the gates against security threats and crackers, and keeps the printers going no matter how many copies of the tax code someone from Accounting prints out.

A sysadmin worries about spam, viruses, spyware, but also power outages, fires and floods.

When the email server goes down at 2 AM on a Sunday, your sysadmin is paged, wakes up, and goes to work.

A sysadmin is a professional, who plans, worries, hacks, fixes, pushes, advocates, protects and creates good computer networks, to get you your data, to help you do work — to bring the potential of computing ever closer to reality.

So if you can read this, thank your sysadmin – and know he or she is only one of dozens or possibly hundreds whose work brings you the email from your aunt on the West Coast, the instant message from your son at college, the free phone call from the friend in Australia, and this webpage.

Show your appreciation

Friday, July 31, 2009, is the 10th annual System Administrator Appreciation Day. On this special international day, give your System Administrator something that shows that you truly appreciate their hard work and dedication. (All day Friday, 24 hours, your local timezone).

Let’s face it, System Administrators get no respect 364 days a year. This is the day that all fellow System Administrators across the globe, will be showered with expensive sports cars and large piles of cash in appreciation of their diligent work. But seriously, we are asking for a nice token gift and some public acknowledgement. It’s the least you could do.

Consider all the daunting tasks and long hours (weekends too.) Let’s be honest, sometimes we don’t know our System Administrators as well as they know us. Remember this is one day to recognize your System Administrator for their workplace contributions and to promote professional excellence. Thank them for all the things they do for you and your business.

Spread the word

 
Follow

Get every new post delivered to your Inbox.