此操作返回,因为超时期限已过期错误

时间:2015-09-08 09:40:59

标签: powershell active-directory

我使用PowerShell从AD中提取部门列表:

$departments = Get-ADUser -Filter * -Property Department |
               Where-Object { $_.Department } |
               Select -Expand Department -Unique

使用该列表,我验证了我的用户输入:

do {
    $Dept = Read-Host "Enter the desired department"
} until ($departments -contains $Dept)
$strFilter = "(&(objectCategory=User)(Department=*$Dept*))"
$colResults = Get-ADUser -LDAPFilter $strFilter |
              Select-Object -Expand DistinguishedName

但是我收到以下错误消息:

Get-ADUser : This operation returned because the timeout period expired 
At line:5 char:15 + $colResults = Get-ADUser -LDAPFilter $strFilter | 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
+ CategoryInfo : NotSpecified: (:) [Get-ADUser], ADException 
+ FullyQualifiedErrorId : This operation returned because the timeout period
  expired,Microsoft.ActiveDirectory.Management.Commands.GetADUser

我必须更改哪些参数才能克服此超时错误?

1 个答案:

答案 0 :(得分:2)

不要使用(Department=*$Dept*) - 您已经知道$Dept存在完全匹配 - (Department=$Dept)已足够

另一方面,

*$Dept*会提示DSA检查范围内的每个对象,而不仅仅是$Dept的完全匹配,还有Department }属性值以$Dept

开头,结尾或包含<uses-permission android:name="android.permission.INTERNET" />