Latest Event Updates
I was recently tasked with automating a disk cleanup and defrag for the XP workstations in our environment. Simple enough of a task using the built-in disk cleanup and defrag. But I thought I’d share some details of how I automated them…
Grasping how to peforming an unattended cleanup can be tricky. The first thing to understand is that selecting the various caches (Internet files, temporary files, trash, etc etc) is controlled through a “sageset”. You can think of a sageset as the configuration number which inidicates what diskclean should remove. So one could have a sageset which cleans up only trash, another sageset which cleans up trash and internet files, another sageset which cleans up all items except memory dump files, etc etc.
This sageset are DWORD values in HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\ in each subkey. For example, I want to cleanup only Internet Cache Files and assign sageset 99 to it. Within subkey “Internet Cache Files” I create the DWORD value name StateFlags0099 and give it the value 2. Then to cleanup this item, I simply run cleanmgr.exe /sagerun:99 – That’s it! To add more items to the sageset, all one needs do is add that StateFlags0000 (where the zeos are the sageset number created).
Make sense? For more information, see Q315246
Not too much doin’ here. I simply trigger defrag.exe c: -f
A neat thing about defrag is that you can first have it analyze the disk to see its fragmentation stats. Since I log SCCM installs/operations for workstations into a custom log file, I thought it would good to capture this analysis in the log file. Below is the vbscript code that I used to facilitate this…
Dim oFSO, oShell, oLogFile Const cForAppending = 8 Set oFSO = CreateObject("Scripting.FileSystemObject") Set oShell = CreateObject("WScript.Shell") Set oLogFile = oFSO.OpenTextFile ("C:\CustomLog.txt", cForAppending, True) Set oExecRun = oShell.Exec ("C:\Windows\system32\defrag.exe c: -a") ' Reads through the output of the analysis until it comes to Analysis Report... ' Then it writes the next line read into the log file Do While Not oExecRun.StdOut.AtEndOfStream If oExecRun.StdOut.ReadLine = "Analysis Report " Then 'extra spaces after report are critical! oLogFile.WriteLine " => Defrag Analysis Report:" & oExecRun.StdOut.ReadLine End If Loop oLogFile.Close
Need a good way to virtualize your test machines for testing SCCM deployments? Use the FREE VMWare Server!
Here is my quick guideline for getting started.
- Get yourself some beefy hardware. I’m using an HP Workstation xw6600T (Intel Xeon 2.33 GHz, 12 GB memory, and 320 GB SCSI disk).
- Get an eSATA external hard drive configured for RAID 0 and that has eSATA and/or FireWire connections (such as http://www.wdc.com/en/products/products.asp?driveid=410). Use this to run the bulk of your VMs on.
- Install your OS. I’m using Windows Server 2008 Standard x64.
Note: you’ll need to install an x64 OS if you have more than 3 GB of memory.
<< Update 4/15/11 – Do not use VMWare Server 2 – Win7 VMs will BSOD frequently. Instead, consider using SCVMM >>
- Download VMWare Server 2.
- Install VMWare Server. During the install, it is very important to change the default ports to 80 (for HTTP) and 443 (for HTTPS). This will save you from a headache in the long run.
- Download and install the VMWare vCenter Converter for converting your physical test machines to virtual machines.
Upon completion you will have a ready to use virtual environment; all you need do is convert your physical machines, launch the Server web interface, and add the new VM. Additional information on VMWare Server, for both install and operation, can be found on the VMWare website in the VMWare Server User’s Guide. The other cool thing is that you can remotely access the console for another computer on your network by going to http://systemname/ui
I have long wanted to begin blogging my IT experiences with SMS 2003 and SCCM 2007. With the frequent busyness of work, I kept putting it off….all the while I have had many things that I’ve wanted to share so that I can remember for the future.