根据多个属性获取AD-User

时间:2015-06-30 17:13:02

标签: powershell

我想找一下纽约办事处IT部门的每个人。我如何组合这两个代码?我希望通过过滤属性而不是-searchbase来搜索用户。

Code 1:
get-aduser -filter "department -eq 'IT'" #get everyone from IT department 

Code 2: 
get-aduser -LDAPFilter "(PhysicalDeliveryOfficeName=NewYork)" #get everyone   from NewYorkOffice

1 个答案:

答案 0 :(得分:3)

您可以将过滤语句与布尔运算符组合使用:

get-aduser -filter {department -eq 'IT' -AND PhysicalDeliveryOfficeName -eq 'NewYork'} -Properies ('PhysicalDeliveryOfficeName', 'Department')