Get-ADUser输入的用户名不正确 [英] Get-ADUser for not exact username

查看:178
本文介绍了Get-ADUser输入的用户名不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的脚本列出了一些用户详细信息,只有在我输入了确切的用户名的情况下,该脚本才起作用。如果输入部分用户名,是否可以使用一种方法来获得结果?
我的意思是,例如,如果我输入 elibukin或 eli.buk而不是 eli.bukin女巫,那是正确的用户名。

The script below lists some user details, it works only in case I've entered the EXACT user name. Is there a method I could use to get results if I type a partial username? I mean if for example I enter "elibukin" or "eli.buk" instaed of "eli.bukin" witch is the correct username.

do {
    Write-Host "Who r we looking for ?        (type EXIT when u done)"
    $User = Read-Host
    Get-ADUser $User -Properties * |
        fl empl*,title, sam*, disp*, mail*, manager*, depa*, giv*, l, last*,
           logon*, when*
} until ($user -eq "exit")


推荐答案

我会使用-具有不明确名称解析(ANR)的LDAPFilter。

I would use -LDAPFilter with ambiguous name resolution (ANR).

Get-ADUser -LDAPFilter "(anr=smith)"

请参见 https://support.microsoft.com/en-us/kb/243299 了解有关ANR的更多信息。

See https://support.microsoft.com/en-us/kb/243299 for more information about ANR.

这篇关于Get-ADUser输入的用户名不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆