Getting all Active Directory groups that contain a certain description using powershell

时间:2016-04-04 18:49:28

标签: powershell

I am trying to find all groups in Active Directory that contain the word "Dedicated" in the description...

Currently I have the following code:

Get-ADgroup -filter {GroupCategory -eq "Security" -and Description -like "*Dedicated*"} | Select-object Name, description

I keep getting the following error:

This operation returned because the timeout period expired

Can anyone help me with my query to return a list of all these groups with their descriptions?

1 个答案:

答案 0 :(得分:1)

如果目录中有许多对象,则对非索引属性(如description)的子字符串搜索可能会非常慢。

您可以执行的操作是检索具有说明的所有组,并使用Where-Object对客户端进行过滤。

请注意,Get-ADGroup默认情况下不会返回description值,您需要使用-Properties参数指定该值:

Get-ADgroup -filter {GroupCategory -eq "Security" -and Description -like "*"} -Properties Description |Where-Object {$_.Description -like "*dedicated*"} |Select-Object Name,Description
相关问题