Solved

Need a script that will identify users with first initial last name email address

Posted on 2007-04-04
8
437 Views
Last Modified: 2010-03-17
Does anyone have, or know of a script or something that can search through AD and identify users that
have an email address of first initial last name @domain.com. I have tried csvde but the best I can do with that is export out proxy addresses which takes too much information. We are trying to phase out email addresses that are first initial last name and go with firstname.lastname for everyone. Many still have
the legacy first initial lastname email address.
0
Comment
Question by:mikedotm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18852351
Perhaps something like this...

Dim objRoot:Set objRoot=GetObject("LDAP://RootDSE")
Dim objDomain:Set objDomain=GetObject("LDAP://" & objRoot.Get("defaultNamingContext"))

EnumOUs(objDomain.ADsPath)

Sub EnumOUs(adspath)
  Dim objOUs, OU
  Set objOUs=GetObject(adspath)
  objOUs.Fileter=Array("OrganizationalUnit")
  Call EnumUsers(objOUs.ADsPath)
  For Each OU in objOUs
    Call EnumOUs(OU.ADsPath)
  Next
End Sub

Sub EnumUsers(adspath)
  Dim objUsers, User
  Set objUsers=GetObject(adspath)
  objUsers.Filter=Array("User")
  For Each User in objUsers
    strFI=Left(User.givenName,1)
    strLN=User.sn
    For Each addr in User.proxyAddresses
      If mid(addr,instr(addr,":")+1,instr(addr,"@")-instr(addr,":")-1)=strFI & strLN Then
         wscript.echo User.givenName & " " & User.sn & " has the email address that you're looking for!"
       End If
     Next
   Next
End Sub
0
 

Author Comment

by:mikedotm
ID: 18858138
This looks interesting. How would I run it? Do I need to specify a search base when I run it?
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18860891
Name it as FindUsers.vbs and just double-click on it - it should work based upon your criteria...
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:mikedotm
ID: 18905027
Did you test this? I got a number of errors. Some I was able to fix but because I don't understand VB,
I was not able to continue.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18905188
Can you post the error(s) as well as the line # it occurred on.
I did test it, but I had to copy it by hand onto my home PC, from my work PC, so I sometimes mistype something...
0
 

Author Comment

by:mikedotm
ID: 18918566
This is what I get when I run it.


C:\>cscript findusers.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\findusers.vbs(23, 5) Microsoft VBScript runtime error: Object not a collection

C:\>

Thanks much!!
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18950719
I don't have a way to test this just yet, but I know why you're getting the error...I 'think' (from memory) this should sort it - if not, post back and I can test at work...


Dim objRoot:Set objRoot=GetObject("LDAP://RootDSE")
Dim objDomain:Set objDomain=GetObject("LDAP://" & objRoot.Get("defaultNamingContext"))

EnumOUs(objDomain.ADsPath)

Sub EnumOUs(adspath)
  Dim objOUs, OU
  Set objOUs=GetObject(adspath)
  objOUs.Fileter=Array("OrganizationalUnit")
  Call EnumUsers(objOUs.ADsPath)
  For Each OU in objOUs
    Call EnumOUs(OU.ADsPath)
  Next
End Sub

Sub EnumUsers(adspath)
  Dim objUsers, User
  Set objUsers=GetObject(adspath)
  objUsers.Filter=Array("User")
  For Each User in objUsers
    strFI=Left(User.givenName,1)
    strLN=User.sn
    If IsArray(User.proxyAddresses) Then
      For Each addr in User.proxyAddresses
        If mid(addr,instr(addr,":")+1,instr(addr,"@")-instr(addr,":")-1)=strFI & strLN Then
           wscript.echo User.givenName & " " & User.sn & " has the email address that you're looking for!"
         End If
       Next
     End If
   Next
End Sub
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18966608
Happy to help - thanx for the grade! :^)
0

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Here's a look at newsworthy articles and community happenings during the last month.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question