[英]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.