Diskspace checks and trend analysis

Posted on February 22nd, 2009 in Server 2003, Server 2008, Storage by alt-92

Simple Diskspace monitoring tools for home use.
Tools: VBscript & MS Access database

The script:

01
02
On Error Resume Next
03
Const HARD_DISK = 3
04
Const adOpenStatic = 3
05
Const adLockOptimistic = 3
06
 
07
strNamespace = "root\cimv2"
08
strDomain = "domain"
09
 
10
strDate = FormatDateTime(Now(), 2)
11
strTime = FormatDateTime(Now(), 4)
12
Set objNetwork = CreateObject("Wscript.Network")
13
' =====================================================================
14
arrComputers = Array("Server1","Server2","Server3")
15
 
16
For Each strComputer In arrComputers
17
Set objWMIService = GetObject("winmgmts:" & strComputer & "root\CIMV2")
18
Set colDisks = objWMIService.ExecQuery _
19
("SELECT * FROM Win32_LogicalDisk Where DriveType = " & HARD_DISK & "",,48)
20
 
21
Set objConnection = CreateObject("ADODB.Connection")
22
Set objRecordSet = CreateObject("ADODB.Recordset")
23
 
24
objConnection.Open _
25
"Provider = Microsoft.Jet.OLEDB.4.0; " & _
26
"Data Source = c:\scripts\diskspace_database.mdb"
27
 
28
objRecordSet.Open "SELECT * FROM tbldiskspace" , _
29
objConnection, adOpenStatic, adLockOptimistic
30
For Each objDisk in colDisks
31
objRecordSet.AddNew
32
 
33
objRecordSet("server") = strComputer
34
objRecordSet("domain") = strDomain
35
objRecordSet("disk") = objDisk.VolumeName
36
objRecordSet("drive") = objDisk.DeviceID
37
objRecordSet("totalspace") = round(objDisk.Size /1024/1024,2)
38
objRecordSet("freespace") = round(objDisk.FreeSpace /1024/1024,2)
39
objRecordSet("percentage") = (objDisk.Freespace /objDisk.Size)*100
40
objRecordSet("date") = strDate
41
objRecordSet("time") = strTime
42
 
43
objRecordSet.Update
44
 
45
Next
46
Next
47
 
48
objRecordSet.Close
49
objConnection.Close
50
' =====================================================================
51

Access DB has a simple table layout, and a couple of queries and comboboxes.
Table:
table

Form:
form1

Using the queries and by generating a PivotTable view, it’s easy to spot growth trends on disks.
Graph showing available free space:
graph

Opening .CHM files from network drives – the GPO way

Posted on December 11th, 2008 in Security, Server 2003, Vista by alt-92

Trying to read non-local HTML Help files since Security Bulletin MS05-026 has always been a very frustrating process.
First, there is the common ‘Oh oh, you’re opening a potentially dangerous file’ popup:

Well, yes. I want to, it’s already stored on my network. I put it there. In fact, I already unblocked the content when I downloaded the file.

But still I get a blank page in the Helpfile:

So let’s go check the KB Article page to see what we can do.

Ah. While there is a helpful section explaining the registry keys needed to Make Things Work again regeditting manually is not everyones favourite pastime:


Windows Registry Editor Version 5.00


[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\HHRestrictions]
"MaxAllowedZone"=dword:00000001
"UrlAllowList"="\\\\alt-92.net"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HTMLHelp\1.x\ItssRestrictions]
"MaxAllowedZone"=dword:00000001
"UrlAllowList"="\\\\alt-92.net"

No, the double \\ are no mistake. You need to escape backslashes.

Now repeat for every computer. Wash, rinse, repeat.

Time to get busy.
Using GPOs seems a likely solution. In fact, the KB article references GPO’s but in a very nasty way.
So why not use Vista’s new GPO Preferences?

To start off, create a new GPO (appropriately named GP_HTMLHelpFix ).
Dig down into the Computer Configuration tree, until you reach Preferences> Windows Settings > Registry.

Create new entries for the values needed:

You can use the UrlAllowList setting to enter DFS roots or local intranet domain.

After linking the Computer GPO to the proper OU and doing a gpupdate, you should see the results in the Registry Editor:

The above approach works in most cases. Except.. it’s still not working.

As it turns out, I not only need to configure the registry keys, but also need to properly configure Internet Options to include the namespace in the local Intranet Zone.
Apparently, there is a problem in IE7 listed in MSKB article 941001.

If you configure a policy setting to a value other than the default value, a local site may appear as “Local Intranet” even though you expect it to appear as “Internet,” or vice versa.

The default settings which should work but don’t:

So let’s tick off Autodetect, tick “Include all Network paths (UNCs)” since a drivemapping is also UNC..

Click Advanced, and enter the domain as a file://-based UNC path..

Re-tick autodetect, with the settings enabled and ‘Ok’ your way though.

Import these settings in the appropriate GPO object to control IE settings if you have them.

Bonus: Use a WMI filter to exclude or include the operating systems you wish to apply these settings to. The Filter shown ensures the GPO only applies to XP desktops and Vista RTM or SP1 desktop machines, and not to any 2000 Pro or 2003 Server machines that inadvertently stray out of their OU.

By the way:

It worked!

Smart-resizing Remote Desktop connections?

Posted on November 21st, 2008 in Server 2003, Server 2008, Vista by alt-92

Guess you can learn something new every day.

http://blogs.msdn.com/ts/archive/2008/08/07/smart-sizing-the-ts-client.aspx

Since the Windows XP timeframe, the TS Client has had the ability to run in “smart-sized” mode (users of Remote Assistance will be familiar with this mode). Smart-sized mode means that the entire remote desktop is always visible in the client window, with no scrollbars being necessary. In effect, for the same size client window, smart-sizing shows you more graphic data, while a non-smart-sized client window has to use scrollbars and shows much less.

Which means by adding

smart sizing:i:1

to a .rdp file (which is a textfile after all) you can get resizing Remote desktop windows too :)

Link Layer Topology Discovery driver on Windows 2003

Posted on August 16th, 2008 in Server 2003, Vista by alt-92

Vista (and Server 2008) introduced the Network Map feature ( as discussed here ).

This feature shows you a Diagram with all LLTD-capable hosts in your home network and you can start it from the Network and Sharing Center Control Panel applet by clicking View Full Map:

Your Network Map would look something like this:

Now, only Vista has this on by default, and the only other Windows version for which LLTD is available is XP.

Shuttle is a WIndows XP MCE2005 machine and has the LLTD Responder installed as provided from MSKB article 922120 (Validation is required to get the download).

My network however also features some 2003 Servers, how do we get these to show?
Installing the driver on Windows 2003 Server does not work, since the updater checks your Windows buildnumber. The update_SP2QFE.inf and update_SP2GDR.inf files contain this entry:

[Version]
Signature = "$Windows NT$"
LanguageType = %LangTypeValue%
NtBuildToUpdate = 2600
NtMajorVersionToUpdate = 5
NtMinorVersionToUpdate = 1
MaxNtBuildToUpdate = 2600
MaxNtMajorVersionToUpdate = 5
MaxNtMinorVersionToUpdate = 1
MinNtServicePackVersion = 512
MaxNtServicePackVersion = 512
ThisServicePackVersion = 512
CatalogFile = %SP_SHORT_TITLE%.cat

Editing the MaxNtMinorVersionToUpdate to 2 (NT 5.2 meaning 2003 Server) might seem like an option, but this invalidates the signature with which all Microsoft updates are signed to prevent tampering.

Turns out there is a very simple way to install the LLTD responder.
First, extract the hotfix to a directory:

.\WindowsXP-KB922120-v5-x86-ENU.exe /X:D:\temp\kb922120

Move the files into your preferred location. In my case, I’m using a DFS network share for AD software deployments.
Create a batchfile, vbscript or whatever you like, and let it perform the following actions:

copy "\\yourserver\appinstall\lltd_2k3\SP2QFE\rspndr.sys" %windir%\system32\drivers
copy "\\yourserver\appinstall\lltd_2k3\SP2QFE\rspndr.exe" %windir%\system32
copy "\\yourserver\appinstall\lltd_2k3\SP2QFE\ip\rspndr.inf" %windir%\inf
start %windir%\system32\rspndr.exe -i
exit

This obviously copies the files in their corresponding target locations and then starts the Responder Service.
Deploy the files in the way that suits you best,

Now, check your Network Map again and you will see your Windows 2003 Server:

And since the Responder can be started and stopped as a regular Service, you can influence the behaviour from whatever mechanism you prefer (MOM Tasks, startup/logon scripts, SMS, System Center) .

Note:
If you’re using VMware products, and both Host and Guest OS have the Responder installed, you’ll notice that VMware Bridging is represented as a Network Hub connection.

DFS Modlink utility

Posted on June 14th, 2008 in Server 2003, Server 2008, Storage, Vista by alt-92

If you add a new target ( DFSCMD /ADD \\dfsroot\link \\server\share ) the default behaviour is to enable the DFS link state.
Based on code found on MSDN for DFS_INFO_101 Structure (Windows) , this command line utility enables or disables the DFS target link state.