On Tue, Aug 4, 2015 at 11:13 AM, Ryan <[email protected]> wrote: > Wouldn't you need wildcards?
Still fails. >$Wrong = "*Azrael" > $Right Azarael > $Wrong *Azrael > $Right -Like $Wrong False > > On Tue, Aug 4, 2015 at 10:10 AM, Michael Leone <[email protected]> wrote: >> >> 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
