none
Help with get-aduser -filter command RRS feed

  • Question

  • Hi! I'm having problems with getting user info from displayname

    function searchuzv {
    $uzvinfo=$InputBoxuzv.text;
    $uzvcheck = Get-ADUser -filter "DisplayName -like '*$uzvinfo*'"

    If i run Get-ADUser -filter "DisplayName -like '*$uzvinfo*'" line separately, everything is ok, and working, but when I run function, I m getting error "Get-ADUser : The search filter cannot be recognized"

    My objective is get user info when only part of displayname is provided.

    I suppose there is problem with syntax, but I can't find anything about this.

    Any suggestions?

    Bert regards,

    Ronald

    Monday, April 13, 2015 11:38 AM

Answers

  • Hi Ronald,

    Try this.

    function searchuzv 
    {
    
    $uzvinfo=$InputBoxuzv.text
    
    $uzvDisp = "*"+$uzvinfo+"*"
    
    $uzvcheck = Get-ADUser -filter "DisplayName -like $uzvDisp"
    
    
    }


    Regards,

    Satyajit

    Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    • Marked as answer by RonaldsS Monday, April 13, 2015 12:45 PM
    Monday, April 13, 2015 12:21 PM

All replies

  • Hi Ronald,

    Try this.

    function searchuzv 
    {
    
    $uzvinfo=$InputBoxuzv.text
    
    $uzvDisp = "*"+$uzvinfo+"*"
    
    $uzvcheck = Get-ADUser -filter "DisplayName -like $uzvDisp"
    
    
    }


    Regards,

    Satyajit

    Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    • Marked as answer by RonaldsS Monday, April 13, 2015 12:45 PM
    Monday, April 13, 2015 12:21 PM
  • Perfect, just added '$uzvDisp' and then worked, like I wanted.

    Ronald

    Monday, April 13, 2015 12:47 PM