简体   繁体   English

从 OU 获取启用的用户

[英]get enabled user from OU

How would I add filter on this to query only enable users?我将如何在此添加过滤器以仅查询启用用户?

(Get-ADUser -Filter * -SearchBase “ou=Users,dc=qq,dc=com”).count

Just tell it to look at the Enabled property in the -Filter parameter:只需告诉它查看-Filter参数中的Enabled属性即可:

(Get-ADUser -Filter "Enabled -eq $true" -SearchBase "ou=Users,dc=qq,dc=com").Count

Note that there is no Enabled attribute in AD itself.请注意,AD 本身没有Enabled属性。 But PowerShell exposes an Enabled property that maps to the value in AD (the userAccountControl attribute).但是 PowerShell 公开了一个Enabled属性,该属性映射到 AD 中的值( userAccountControl属性)。 The actual LDAP query this gets translated to looks something like this:被翻译成的实际 LDAP 查询看起来像这样:

(Get-ADUser -LDAPFilter "(!userAccountControl:1.2.840.113556.1.4.803:=2)" -SearchBase "ou=Users,dc=qq,dc=com").Count

So PowerShell simplifies it a bit for you.所以 PowerShell 为您简化了一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM