2012-09-20 55 views

回答

3

試試這個:

$myVar = '*test*' 
Get-ADUser -Filter {name -like $mvVar} -Properties name | Select-Object Name 

很確定Name是默認的屬性。

+1

是的。名稱作爲默認值進入。 – Mike

+0

'*'給了我。 –

-1
###Dynamic Approach to Lookup a User### 

    #Get Input to Define Variables 
    $NameLast = Read-Host 'User Last Name' 
    $NameFirst = Read-Host 'User First Name' 
    $NameLookup = "*$NameFirst* *$NameLast*" 

    #Get-ADuser Lookup Based on Defined Variables 
    Get-ADuser -Filter {name -like $NameLookup} -Properties * | Select-Object name, samaccountname, emailaddress | Sort-Object samaccountname