Tuesday, January 18, 2011

Export Computer objects from Active Directory with OldCmp

Export Computer objects from Active Directory with OldCmp

I needed to reconcile Active Directory computer objects last login time with a complete list of my company's inventory and found this process to be pretty useful. Please visit http://www.joeware.net/freetools/tools/oldcmp/index.htm to download OldCmp, this utility will export computer objects from AD. I'm paranoid so I used a AD account with no rights to delete or modify objects but just enough rights to read AD, which is just about any account.

  1. Download OldCmp.zip from http://www.joeware.net/freetools/tools/oldcmp/index.htm
  2. Extract the OldCmp.exe file within the zip and place in a directory you can easily navigate to from within the cmd line interface.
  3. Review the OldCmp.exe usage switches on this page: http://www.joeware.net/freetools/tools/oldcmp/usage.htm or with the OldCmp /? command
  4. For the report I needed, I ran the following command:
    C:\Documents and Settings\testr>oldcmp -report -b ou=hosting,dc=subdomain,dc=domain,dc=edu -file oldcmp_export.csv -format CSV
  5. This generated a file called oldcmp_export.csv of all the systems in my domain within the "hosting OU with their last system login time if available.
Note: This tool is VERY POWERFUL and could be VERY DANGEROUS! If you are not sure what you are doing, please find or ask someone who does!

Next, I needed to import this file into Excel and clean up the formatting and run a comparison with MS Access. I did the following:

  1. Rename the csv file you just exported to have a .txt extension (this is done so that Excel will be prompted for delimiters when it tries to open/import its data).
  2. Launch Excel and open the csv file (now renamed as a txt file), select the delimiter as semicolon and then correct formatting and clean up anything that looks strange. I can't tell you how to do this as your naming conventions may collide with the delimiters set. Use your own judgement and save-as a new excel file, you will reference this file from MS Access.
  3. Launch MS Access, create a new DB.
  4. See http://office.microsoft.com/en-us/access-help/compare-two-tables-and-find-only-matching-data-HA010205130.aspx for a how to on how to create the comparison in MS Access 2007.

No comments: