locked
how to use powershell for fuzzy serch? RRS feed

  • Question

  • i have a computer list need to serch how many name like this in the ad server

    so i create a csv file 'test' and create header call 'name' and placed all the data under it .

    like this :

    name

    5109160506
    5109160512
    5109160513
    5109160534
    5109200047
    5109200054

    5109200454

    Etc

    how can i use fuzzy serch in powershell for serch how many computer name  include these number?

    Thanks in advance

    Wednesday, August 16, 2017 2:29 AM

Answers

  • Get-ADComputer -Filter "Name -like '*$($_.name)*'"


    \_(ツ)_/

    • Marked as answer by DT 2017 Monday, September 11, 2017 3:12 AM
    Wednesday, August 16, 2017 4:13 AM

All replies

  • What?  What is a "fuzzy" search? 

    You can search for each name but there is really no good way to search for a list.

    Start by searching for each item in your list  build a list of iitems found.


    \_(ツ)_/

    Wednesday, August 16, 2017 2:47 AM
  • sorry  I didn't explain clear.   i just want serch name contains these number in all ad computer.

    i know it is not good way to serch for each one whitout powershell.

    so i wirte :   Import-Csv test.csv | %{Get-ADComputer $_.name -Properti
    es *} | Select-object name  | Export-Csv computer.csv -NoTypeInformation
    -Encoding UTF8

    and i know some place need change or add, but i don't know how.

    so can you get some advice.

    Wednesday, August 16, 2017 3:06 AM
  • And yes. You are doing this:

    Import-Csv test.csv | 
    	ForEach-Object{
    		Get-ADComputer $_.name 
    	} | 
    	Select-object name | 
            Export-Csv computer.csv -NoTypeInformation -Encoding UTF8

    What is the issue or error?


    \_(ツ)_/

    Wednesday, August 16, 2017 3:39 AM
  • computer name for example like 'ZJ5109160506' or '5109160506A'

    the above command serch need perfect match right,  it didin't serch out anything and i need each containing these in them computer name

    so how can do ?  please get me some thought



    • Edited by DT 2017 Wednesday, August 16, 2017 3:57 AM
    Wednesday, August 16, 2017 3:56 AM
  • Get-ADComputer -Filter "Name -like '*$($_.name)*'"


    \_(ツ)_/

    • Marked as answer by DT 2017 Monday, September 11, 2017 3:12 AM
    Wednesday, August 16, 2017 4:13 AM
  • thank you for your help.  problem be fixed.

    i think i need learn more about this thing.

    Wednesday, August 16, 2017 5:02 AM
  • Hi,

    Was your issue resolved?

    And if the replies as above are helpful, we would appreciate you to mark them as answers, and if you resolve it using your own solution, please share your experience and solution here. It will be greatly helpful to others who have the same question.

    Appreciate for your feedback.

    Best Regards,
    Albert Ling

    Please remember to mark the replies as an answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, August 25, 2017 11:54 AM