Archive for the ‘Scripting / Batch File / Automation’ Category

Update AD EmployeeNumber Attribute From CSV File

Wednesday, June 4th, 2014

2014-06-04 Initial Post

The other month I needed to update the EmployeeNumber attribute of all Active Directory user accounts based on a CSV file generated from Oracle HRMS. You may modify this script to update a different attribute, such as EmployeeID.

#Script updated 2014-03-31, created 2014-03-06, by
#PURPOSE: Takes a CSV input file that contains "E-mailAddress,EmployeeNumber" on each line (DO NOT include header in CSV file).
# Searches AD for user account that has the e-mail address as its primary address.
# If found, update that respective AD account with the corresponding EmployeeNumber.
#There is some limited error checking and a status file is generated after script completion.
#I was not able to get the Import-Csv command to work correctly so I used Get-Content to grab data from the input file.
#Tested against Windows Server 2008 R2 SP1 AD.
$strFilePathInput = "X:\TempPowerShell\setAD-EmployeeNumberINPUT.csv"
$strFilePathOutput = "X:\TempPowerShell\setAD-EmployeeNumberOUTPUT.csv"
Get-Content $strFilePathInput | ForEach-Object{
$strUserInfoLineFromFile = $_
$strUserEmailAddress = $strUserInfoLineFromFile.Split(",")[0]
$strUserEmployeeNumber = $strUserInfoLineFromFile.Split(",")[1]
If($objADuser = Get-ADUser -Filter {mail -eq $strUserEmailAddress }) #The mail attribute is the primary/reply e-mail address.
Set-ADUser $objADuser -EmployeeNumber $strUserEmployeeNumber
If($?) #If True, which means previous command (set EmployeeNumber) was successful. Invalid e-mail address or insufficient AD permissions will make this False.
"OK - Updated," + $strUserInfoLineFromFile | Out-File -Append $strFilePathOutput
"ERROR - Could not update," + $strUserInfoLineFromFile | Out-File -Append $strFilePathOutput
"E-mail address has no primary match," + $strUserInfoLineFromFile | Out-File -Append $strFilePathOutput

VMware vSphere Hypervisor (ESXi 4.1) Test Lab Configuration Notes

Wednesday, June 20th, 2012

2012-06-20 Updated

2010-12-22 Initial Post

I've never had a chance to work with any version of VMware at work. My last company was so far behind in its IT strategy that even in late 2009 it had absolutely no virtualization strategy at all. I did manage to set up one Hyper-V server for them so that one department could use it for software testing. Where I work now, they do use VMware, but they don't use them on any of the messaging servers that I support. So once again, I have no chance to work with VMware. (more…)

Redirect Web Site Folder (WordPress)

Wednesday, April 11th, 2012

2012-04-11 Initial Post

When I first set up this blog, the WordPress Permalink Settings was set to use Day and name (e.g., Later on, I changed it to Custom Structure (e.g., /%postname%) without thinking about how to redirect from the old format to the new format.

I had posted a comment on and put a link to my post at So after changing the permalink settings, the link to my post no longer worked. So how do I redirect it? That link isn’t to an HTML file, but to a directory/folder, so I wasn’t sure how to do this.

I finally got around to messing with this last night and it took me a while to find a solution because my searches kept pointing to examples of using .htaccess and RewriteRule, which isn’t what I wanted. After more searching, I found the solution here:

This is what I ended up doing (I don’t know if there’s a simpler way, but this worked for me, so that’s all I need):

  •  Go into BlueHost cPanel --> File Manager.
  • Under public_html, create this folder structure: 2010/02/04/telnet.
  • Under telnet, create a file named .htaccess.
  • Edit the .htaccess file and put in this one line: Redirect /2010/02/04/telnet /telnet

OCS – List All AD Enabled User Accounts That Are Also OCS Enabled

Monday, February 6th, 2012

2012-02-06 Initial Post
Windows Server 2003 SP2
Office Communications Server 2007 (non-R2)

csvde -f getOCSUsersListCSVDE-Output.csv -r "(&(objectCategory=user)(msRTCSIP-UserEnabled=TRUE)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))" -s dc001 -l "displayName" -j .

See for explanation of userAccountControl and using bitwise filters with LDAP.

New-MailboxExportRequest – How To Export Multiple Well-Known Folder Names

Monday, December 5th, 2011

2011-12-05 Initial Post

A few weeks ago I was trying to get a command together to export only the Calendar and Contacts folders from all mailboxes on an Exchange Server 2010 SP1 mailbox database. (more…)