从samaccountname获取displayname

时间:2015-04-29 08:44:39

标签: powershell active-directory

我正在寻找一种方法从displayname获取用户的samaccountame

$username = Read-host 'Username'
$user = Get-ADUser -Filter {samaccountname -like $($name.DisplayName)$username}

我想将displayname放入名为$user

的变量中

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

$username = Read-host 'Username'
$user = Get-ADUser -Filter "samaccountname -eq '$username'" |select name