Generate a report of Exchange mailbox sizes broken out by department and location

I found a script a few months ago that generated a CSV report of mailbox size, which included the Mailbox Name (usually the user’s name), size in Kbytes, number of items, which server it’s on, etc. This was very helpful, but I wanted to see which department within the company used the most space on the mail server, and the department wasn’t one of the pieces of data included in the report. It took a while but I figured out how to do LDAP lookups in vbscript and was able to add that info, so the report now has the user’s department, office location, and quota limit in it as well as the other fields. This makes it very easy to do a PivotChart in Excel to generate a pie chart of the size by department. The script is attached – change the extension to .vbs to run it. You’ll need to plug in your Exchange server and domain controller where the placeholders currently are.

EmailSizeByDepartment.vbs

Windows XP guests hang on shutdown in VMware Workstation on Linux

I had this problem with FC11, where I couldn’t properly shut down or suspend the Windows XP VM I run (mostly for Outlook). When I’d shutdown inside the guest, it would mostly do what you’d expect, but then the screen would go blue, then black, and then the only way I could get the thing to exit was to kill the pid of vmware-vmx (or a ‘killall vmware-vmx’). I solved it somehow by removing some RPM, but when I went to FC12 the other day it came back, and I couldn’t remember how I’d fixed it initially. I Googled for nearly a full day before I found the original blog post that told me which RPMs to remove – for some reason I thought it was fprintd, but it was something else completely. Here’s the original post, and when I just read it I was going to comment on it to say thanks for posting it, but apparently I did that already. Anyway, I removed pcsc-lite again and everything appears to be good now.

Upgraded to Fedora Core 12

I upgraded my work laptop from FC11 to FC12 yesterday using the “preupgrade” tool. It was pretty simple, though it took a lot longer than I expected. There was some funkiness with my screen going crazy after the upgrade – my external monitor and the laptop’s LCD both did this crazy wavy-line thing. I tried changing the refresh rate, running system-config-display, nothing worked. I found a post that suggested passing “nomodeset” to the kernel boot options – that solved it. Yay!

The other problem I had was reinstalling VMware Workstation – I couldn’t. I got this error: /tmp/vmware-root/modules/vmnet-only/vnetUserListener.c:240: error: ‘TASK_INTERRUPTIBLE’ … etc. I ended up having to edit the vmplayer source files directly (!!!) to get them to compile – instructions found here

So far FC12 seems exactly like FC11. But that’s fine – I only upgraded because I didn’t want to be on a dead-end version once FC13 is released.

Code to flatten a list in Java, with and without recursion

Recently had someone ask me to solve this problem: assume you have a list of objects, some of which may be lists of arbitrary depths. Write a function to return the list “flattened,” so sublists are all in the “main” list. I solved it recursively pretty easily, but it took some thought to do it without recursion. My solutions are below.

package com.evanhoffman.listflattener;

import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;

public class ListFlattener {

        private static Logger logger = Logger.getLogger(ListFlattener.class);

        public static List flattenList(List inList) {
                List newList = new LinkedList();

                for (Object i : inList) {
                        // If it's not a list, just add it to the return list.
                        if (!(i instanceof List)) {
                                newList.add(i);
                        } else {
                                // It's a list, so add each item to the return list.
                                newList.addAll(flattenList((List)i));
                        }
                }

                return newList;
        }

        public static List flattenListNoRecursion(List inList) {
                List tempList = null;

                // Clone the input list to newList
                List newList = new LinkedList();
                newList.addAll(inList);

                ListIterator iterator = newList.listIterator();


                int currentPosition = 0;

                while (iterator.hasNext()) {
                        Object i = iterator.next();
                        if (!(i instanceof List)) {
                                // If it's not a list, advance the position.  Don't advance position if this IS a list.
                                currentPosition++;
                        } else {
                                // If the current item is a list, save it to a temp var.
                                tempList = (List) i;

                                // Delete the list from the list
                                iterator.remove();

                                // Add each item from the temp list to the master list at the same position the sublist was removed.
                                for (Object obj : tempList) {
                                        iterator.add(obj);
                                }

                                // reset the iterator to re-walk the list that was just inserted (within the master) to check for more lists.
                                iterator = newList.listIterator(currentPosition);
                        }
                }
                return newList;
        }

        public static void printList(List list) {
                int i = 0;
                for (Object item : list) {
                        logger.debug("List item #"+i +": "+item);
                        i++;
                }
        }

        public static void main(String[] args) {

                BasicConfigurator.configure();

                // List of strings
                LinkedList stringList = new LinkedList();
                for (Integer i = 0; i < 10; i++) {
                        stringList.add("String #" +i.toString());
                }

                // List of integers
                LinkedList intList = new LinkedList();
                for (Integer i = 10; i < 20; i++) {
                        intList.add(i);
                }

                // Nested Lists
                LinkedList nestedList1 = new LinkedList();
                LinkedList nestedList2 = new LinkedList();
                LinkedList nestedList3 = new LinkedList();

                nestedList3.add("Nested String 1");
                nestedList3.add("Nested String 2");
                nestedList2.add(nestedList3);
                nestedList1.add(nestedList2);

                LinkedList bigList = new LinkedList();

                bigList.add("First item");
                bigList.add(stringList);
                bigList.add("Third Item");
                bigList.add(intList);
                bigList.add("Fifth Item");
                bigList.add(nestedList1);
                bigList.add("Seventh Item");

//              List flattenedList = flattenList(bigList);
                List flattenedListRecursion = flattenList(bigList);
                List flattenedList = flattenListNoRecursion(bigList);

                logger.debug("Original list:                 "+bigList.toString());
//              printList(bigList);
                logger.debug("Flattened list (w/ recursion): "+flattenedListRecursion.toString());
                logger.debug("Flattened list (no recursion): "+flattenedList.toString());
//              printList(flattenedList);

        }
}

Moving an Exchange 2003 server to another location with minimal risk and disruption?

So our Exchange server is located in our office building. This made sense at the time because that’s where the users are. Over time though, this has proved problematic for a few reasons. Primarily, our office is certainly not a datacenter and doesn’t offer the amenities of one – clean, reliable power, and redundant cooling. In an average year we lose power probably 10-15 times, often for an hour or more. The rest of our production environment is hosted in a top-tier datacenter, so after a while I started to wonder why our Exchange server wasn’t there, and making plans to move it there. Oh, and did I mention I’m not an Exchange admin in any sense of the term? I just inherited the Exchange server about 2 months ago.

Continue reading Moving an Exchange 2003 server to another location with minimal risk and disruption?

Top Long Island teacher salaries

Average teacher salaries for Long Island school districts. Courtesy of NYS DOE, via Newsday – data are from 2005:

1	Fire Island	$96,228
2	East Williston	$93,001
3	Island Park	$88,992
4	Quogue	$88,975
5	Great Neck	$87,444
6	Roslyn	$87,277
7	Mineola	$85,978
8	Lawrence	$85,400
9	East Rockaway	$84,130
10	Bridgehampton	$83,568
11	West Hempstead	$83,546
12	Jericho	$83,150
13	Carle Place	$83,088
14	Locust Valley	$82,553
15	Port Washington	$82,520
 Continue reading Top Long Island teacher salaries