Hi everyone. in my organization we have over and estimated 2000 users or more. We just found out that some accounts have been created with same first name and last name for example :

First name : Joy

Last Name: Joy

I need to find a script that can help me to find the accounts that were created with the same first and last name is this possible or whats the best way to go by fixing this issue thank you in advance.

7 Spice ups

What have you tried so far?

See if you find something here:

https://community.spiceworks.com/scripts?source=navbar-footer

Or powershell…

I can’t think of a smart filter but this might work

Import-Module ActiveDirectory
Get-ADUser -Filter * |
where {$_.givenname -eq $_.surname} |
select name, samaccountname |
export-csv "c:\list.csv" -NoTypeInformation
5 Spice ups

That worked thanks I have been working on a script for this for last 5 hours

Don’t forget to award a best answer if your problem has been resolved!

so this worked for me before but I dont know what I am doing wrong now but I keep getting this error

export-csv : Could not find a part of the path ‘C:\list.csv’.
At line:5 char:1

  • export-csv “c:\list.csv\username” -NoTypeInformation
  • CategoryInfo : OpenError: (:slight_smile: [Export-Csv], DirectoryNotFoundException
  • FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ExportCsvCommand

The path does not seem right:

export-csv "c:\list.csv\username" -NoTypeInformation

it should be possibly like so?

It’s C:\folder\file.csv

export-csv "c:\username.csv" -NoTypeInformation

Also it would help if you post the code you run (sanitized)

If you post code, please use the ‘Insert Code’ button. Please and thank you!