Smash forehead on keyboard to continue…
Posts tagged vbScript
Part 1: Blocking Bad Hosts – Finding Them, Easily
Dec 21st
Download Script: get-bad-hosts.zip
While troubleshooting some issues on an OWA Front-End server, I went over to the security log to see if the authentication attempts were getting past this box. The problem I found was the log was so full of failed logon attempts it was difficult to filter out what I was looking for. In a twelve hour period, there were thousands of 529 events in the security log. Now, I know this is nothing new, but I found a few patterns. I manually exported the log to a CSV, parsed out all the source ip addresses and opened it up in Excel. What I found was that 98.7% of failed logon attempts were made by just four different ip addresses. (I recommend using MaxMind’s GeoIP Address Locator for help in determining where the source addresses are located.) More >
Logon Script: Move Local PST Files To Network Share
Oct 14th
Download Script: move-pst-to-network.zip
So, my buddy (and former co-worker) called me yesterday for some help with a script he put together. His script checked the local profile in Outlook for any PST files that were stored locally. If it found any, it would them move them to the users home space. We tried and tried to get the script to work properly but it never seemed to work 100%. Being that he is a good friend and this would be useful at work, I decided to take the work he had put in and get the thing working. More >
vbScript – List All Members Of Sensitive Groups: Schema, Enterprise and Domain Admins
Mar 13th
Update 2009.04.16: At the request of a commenter, I added a couple lines to the script that will dump the output to a text file in the root of the C: drive. I also corrected a couple errors in the script.
I was tasked to get a dump of all the users in our Schema Admins, Enterprise Admins and Domain Admins for our Forest. I started thinking about it and realized a couple things. Two of the three groups reside at the forest root while the Domain Admins group exists for every domain in the forest. This meant I would need to enumerate every domain and depending on the domain, enumerate either all three groups or just one. More >
VBScript: Delete Files Older Than One Hour
Oct 3rd
So, I am constantly looking for ways of automating tasks. Too many admins do not take advantage of scripting and scheduled tasks/cron. Just this last week, I was implementing a new print server. Besides just building up the new server, I wanted to actually offer the users something new and useful.
I’ve been wanting to setup a network pdf printer for quite some time. I have played around with setting up a network PDF printer using cups. However, we seem to be so MS centric these days that I decided to use PDFCreator’s print server. It was really a piece of cake. Just install the server portion, setup the service, create a share and watch the PDF’s spool.
I quickly found that the folder where PDF’s were written to, was quickly filling with PDF’s as users were not removing them. So, the solution was to write a little vbscript to purge any files older than an hour. There were two things I wanted:
- I have a file named “!FILES ARE PURGED AFTER ONE HOUR!”. I did not want this file removed. It serves as a warning for uses.
- I did not want to purge the folder every hour. I wanted to remove any files that were one hour old or greater. That way, if a user creates a PDF at 2:59pm, the 3:00pm run won’t delete it. It will be deleted on or after 3:59pm.
Here is the script I came up with:
strFolder = "C:\Folder\" Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(strFolder) Set objFSO = CreateObject("Scripting.FileSystemObject") For Each strFileName in objFolder.Items If len(objFSO.GetExtensionName(strFileName)) > 0 Then Set objFile = objFSO.GetFile(strFolder & strFileName.Name) If DateDiff("N",objFile.DateLastModified,Now()) > 59 Then objFSO.DeleteFile(strFolder & strFileName.Name),True End If End If Next
The great thing about this is that you get a free network PDF printer that can be left alone. Your boss thinks you are a genius and there is no sweat on your brow.
Cheers!