Archive for September, 2005

Searching Active Directory (VBScript)

Friday, September 30th, 2005

If, like me, you have been left irritated by the search function in Active Directory Users and Computers simply not telling you WHERE a particular user or computer actually is, simply use this bit of code. It allows you to search through AD for users or computers and returns a list of what it finds and the FULL canonical name so you can actually find the damned thing.

You could of course expand this script to perform user modifications such as resetting passwords, without the need to use the AD MMC console.

Click the link to see the script. (more…)

Using ADO & PHP to query a CSV file

Sunday, September 18th, 2005

OK, so I finished my book on VBScript. While interesting and informative it certainly didn’t cover all the aspects of VBSCript that I’d like to know about. Scouring MSDN for clues just isn’t my idea of fun either and quite frankly gets me a little irritated. Why it can’t be like the PHP Website is beyond me.

While the book did touch on ADSI and WMI, it didn’t really give me much in the way of detail about actually doing anything with the information I can gather. So I can tell who’s logged on to a computer if I issue a WMI query specifically to that computer, so what!? (more…)

Screenshot active window

Wednesday, September 14th, 2005

Tip of the day:

Use ALT+PRTSCRN to get a screenshot of only the active window. Meaning you don’t have to cut out the surrounding chaff with your favourite image editing application.

Learning Windows Scripting.. pff

Tuesday, September 13th, 2005

After my last post about VBScript/WSH I thought I would bite the bullet and get myself a couple of books to learn about Windows Scripting to assist with network management, logon scripting etc.

I bought two books, Microsoft Press Windows Scripting Self-Paced Learning Guide and Windows Admin Scripting Little Black Book Second Edition.

The obvious place to start was with the book that will teach me about Windows Scripting so I begin on Saturday afternoon. 164 pages later and I’m on Lab 18a which is the DIY section of the chapters. A great idea to actually use VBSCript to achieve what you want to do. This particular chapter deals with WMI and accessing the WMI namespace to retrieve data that you can use for reporting or whatever really. So the lab runs you through creating a script which ends up looking exactly like this: (more…)

Directory size monitoring with VBScript

Friday, September 9th, 2005

OK, I don’t admit to being anything like an expert with VBScript or Windows Scripting Host but I’m learning. I’ve bought a couple of books on the subject to help me administer the network at work and automate repetitive tasks.

We have a folder on the network attached storage server that is used for archiving aged data. Our tape backup solution uses 100GB tapes. If this archiving folder goes above 100GB, the data has to be archived off on to two or more tapes which is a nightmare to administer. I’m sure you can understand how long it takes to backup 100GB, even over 1Gbps backbone but inserting tapes to do a restore, even from a backup set that spans two tapes is the biggest pain in the backside.

I need something to check the size of this archive folder and didn’t want to invest in some naff program to do it for me. I need to check it maybe once a day so I can just run a scheduled task once a day, no expenditure needed, no other resources etc.
I stumbled across a VBScript yesterday that had all the fundamental bits of code to do what I wanted it to do so I adjusted it slightly to check the folder I wanted it to check and email me if it was over a certain size or it encountered a problem. I guess the script could also be adapted to monitor server shares and availability too since if it can’t connect it will send you an email telling you so. The obvious drawback is the fact that it can’t email you telling you that the email server is down! ;) (more…)

Large BLOB to MSSQL database

Friday, September 9th, 2005

While trying to maintain security restrictions for a new system I’m developing to deliver data to our customers I came up with the following chunks of code to insert data in 256k chunks into a Microsoft SQL Server database.

The problem was the unavoidable fact that the server couldn’t reserve a contiguous space in its memory to handle the query. The query came out to nearly 120MB just for a 25MB file. Even with a recent upgrade of 2GB memory the server still couldn’t handle it and I searched high and low for an answer.

Out of desperation I felt I had to contact some SQL gurus so I popped over to SQLTeam.com and posted up my problem. I received a great response from one of the developers of SQL Server 2005’s storage engine which pretty much said: Split it in to chunks to avoid the problem altogether. (more…)