Loyall
asked on
Powershell find users with similar family names
Hi,
I have a script that searches for users that have the exact Firstname I provide and Surnames that are alomst identical
So, when I provide the script the firstname "Sara" and surname "Smith", I want it to find al users that have names like:
Sara Smith
Sara Smithonian
Sara Smith Klein etc.
I'm using this line:
$names = $(try {Get-Aduser -filter * -Properties Surname | Where {$_.Givenname -like "$Givenname" -and $_.Surname -like "*$Lastname*"}} catch {$null})
I kind of works. It just finds only users that have the exact First and Surname I provide the script.
So, in the example above, it only finds all the "Sara Smiths" in AD, but not the Sara's with similar familynames.
How can I get this done ?
Thanks in advance.
I have a script that searches for users that have the exact Firstname I provide and Surnames that are alomst identical
So, when I provide the script the firstname "Sara" and surname "Smith", I want it to find al users that have names like:
Sara Smith
Sara Smithonian
Sara Smith Klein etc.
I'm using this line:
$names = $(try {Get-Aduser -filter * -Properties Surname | Where {$_.Givenname -like "$Givenname" -and $_.Surname -like "*$Lastname*"}} catch {$null})
I kind of works. It just finds only users that have the exact First and Surname I provide the script.
So, in the example above, it only finds all the "Sara Smiths" in AD, but not the Sara's with similar familynames.
How can I get this done ?
Thanks in advance.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My question has been answered
ASKER