我希望能够搜索特定电话号码/分机号的Active Directory用户的所有属性。
可以通过以下方式获取所有属性:
get-aduser joesmith -Properties *
但我希望过滤出特定的结果,比如扩展号码为1234的(可能在多个地方,例如extensionAttribute1、OfficePhone、HomePhone、Mobile等)。
我尝试了以下方法:
get-aduser joesmith -Properties * | where-object {$_ -like "*1234*" }
但是where-object想要$_.value,而我不知道确切的值。
我应该如何搜索多个属性的值?我希望看到以下结果:
mobile 1234
officephone 12345
othermobile 61234
get-aduser joesmith -prop *|gm -MemberType Property|select -ExpandProperty name|%{if($test.$_ -match "@philips"){[pscustomobject]@{Name=$_;Value=$test.$_}}}
这也许会给您带来更容易处理的结果。 - TheMadTechnician