1

I want to search my Active Directory for all users that DO NOT match the following criteria:

First letter of login name matches first letter of first name. Remainder of login name matches last name.

So, user John Smith with logon jsmith would be a match. How can I query AD to find users who do not match this criteria?

2
  • do you have powershell available and the AD web service running? Not completely necessary but does make things easier.
    – tony roth
    Jan 5, 2012 at 16:49
  • Powershell - yes. I'm not sure about the AD web service. I need to talk to the admin. Even with powershell, what would the query look like?
    – DCNYAM
    Jan 5, 2012 at 16:59

1 Answer 1

2

Here is a little PowerShell script that uses the Quest AD cmdlets, available here. It constructs the desired logon and then compares it to the current logon, writing out the invalid logon names to the console window. You could have it output to a file or whatever.

$users = Get-QADUSer -SizeLimit 0

foreach ($user in $users)
{

$firstinitial = $user.FirstName.Substring(0,1)
$lastname = $user.LastName.ToString()
$compareterm = $firstinitial + $lastname
if ($compareterm -ne $user.LogonName)
    {
    Write-Host $compareterm "has an invalid logon name."
    }
}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .