On Tue, Aug 4, 2015 at 12:04 PM, Jim Robertson
<[email protected]> wrote:
> I'm not sure I would approach the problem this way for a whole list of users. 
>  I have run across too many instances of people with either identical names, 
> or variations that are very close.  It would be really easy to have a false 
> positive.  For example, the names Jon, and John could easily be confused 
> unless you can use a unique attribute in both lists to control the 
> comparison.    We also have several instances with users that have the same 
> first name and last name, and a pair with the same first name, middle initial 
> and last name. Which makes using names for a match unreliable.

True that. But sometimes you have to work with what you have ...


>
> Also, by matching only on the given name, you have the potential to match 
> several users.  If I run: [ Get-ADUser -Filter "GivenName -eq ""michelle"""]  
> in my environment I return 18 different users.

Me, too. That's why I match on first and last name. And I am matching
700 out of 950.

> In our environment we populate the employeeID attribute, which gives us a 
> unique attribute that we can use to make sure the comparison is on the 
> correct AD object. Another option might be matching on email address.

And that is what I am trying to populate - the EmployeeID from a CSV
file, matching on the name (first and last name). I suppose I can ask
for email addresses instead. presuming that they have the email
address to give me to match to ...


> If you have whole list of users that you need to compare, I suggest you 
> rethink your approach.
>
> Jim
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] 
> On Behalf Of Michael Leone
> Sent: Tuesday, August 4, 2015 10:26 AM
> To: [email protected]
> Subject: Re: [powershell] Confused about -Like comparison
>
> On Tue, Aug 4, 2015 at 11:20 AM, Jim Robertson <[email protected]> 
> wrote:
>> Like is normally used for a partial string match and needs wildcards to 
>> create an expression that does the match:
>> $Right = "Azarael"
>> $Wrong = "Az*rel"
>> $Right -like $Wrong.
>> True
>>
>
> OK. But I'm not sure how that helps me. What I have is a file of names, and I 
> am supposed to match them in AD. I can't just arbitrarily put a wildcard in 
> the middle of a name, and then try to find that wildcarded name in AD.
>
>> A regex is often used to do the pattern match.
>
> If I was any good at regexs, I would use one. :-)
>
>>
>> Hope that ehlps
>>
>> Jim
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of Michael Leone
>> Sent: Tuesday, August 4, 2015 10:11 AM
>> To: [email protected]
>> Subject: [powershell] Confused about -Like comparison
>>
>> OK, I will admit to being dense today. I have a user in AD, and we have 
>> apparently spelled his first name wrong. Easily fixed manually.
>> But I decided to use this as a test case, to see if I could find him using a 
>> Powershell search. And I kept failing. Then I noticed this:
>>
>>> $Right  = "Azarael"
>>> $Wrong = "Azrael"
>>> $Right -like $wrong
>> False
>>
>> No wonder my filtering was failing, I was trying for "givenName -like 
>> $Right", figuring I would catch him, and then replace the incorrect spelling.
>>
>> Get-QADuser -SizeLimit 0 -Enabled | Where-Object {($_.givenName -like
>> "Azarael")}
>>
>>
>> But why is it wrong? From looking at it, shouldn't the comparison be "True"? 
>> There's only a 1 letter difference between the 2, isn't that enough to 
>> qualify as "-like"?
>>
>> What comparison should I be using, so that looking for "Azarael" finds 
>> "Azrael"?
>>
>>
>> ================================================
>> Did you know you can also post and find answers on PowerShell in the forums?
>> http://www.myitforum.com/forums/default.asp?catApp=1
>>
>>
>> ================================================
>> Did you know you can also post and find answers on PowerShell in the forums?
>> http://www.myitforum.com/forums/default.asp?catApp=1
>
>
> ================================================
> Did you know you can also post and find answers on PowerShell in the forums?
> http://www.myitforum.com/forums/default.asp?catApp=1
>
>
> ================================================
> Did you know you can also post and find answers on PowerShell in the forums?
> http://www.myitforum.com/forums/default.asp?catApp=1


================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

Reply via email to