获取所有具有按字段管理的空白的 AD 组
我正在尝试获取所有用名称管理的空白和广告组描述的广告组。我目前在使用过滤器显示不显示结果的问题,但不确定为什么。任何帮助都将受到赞赏。
Get-ADGroup -filter * | Where-Object {$_.ManagedBy -eq ""} | Select-Object manager,description | Export-Csv -Path C:\Users\User\Desktop\AllNullManagedBy.csv -NoTypeInformation
当前脚本没有显示任何应该向几个用户显示的用户
I'm trying to get all AD groups that have a blank Managed By Name and the description of the AD group. I'm currently having issues with displaying no results using my filter, but am not sure why. Any help is appreciated.
Get-ADGroup -filter * | Where-Object {$_.ManagedBy -eq ""} | Select-Object manager,description | Export-Csv -Path C:\Users\User\Desktop\AllNullManagedBy.csv -NoTypeInformation
The current script is not showing any users which it should be showing several users
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是
Get-ADGroup
默认情况下不会返回具有ManagedBy
属性的对象,您需要请求它(-Properties ManagedBy
):不过这个操作效率相当低,可以使用 LDAP 过滤功能:
作为旁注,
Where-Object { $_.ManagedBy -eq "" }
可能不会返回任何结果,您将查询ManagedBy
属性已设置并且其值等于空字符串的 AD 组,而不是过滤<强>没有该属性设置或其值为$null
或空字符串({-not $_.ManagedBy }
):The problem is that
Get-ADGroup
does not return an object with theManagedBy
attribute by default, you need to ask for it (-Properties ManagedBy
):However, this operation is quite inefficient, you can use LDAP filtering capabilities for this:
As a side note,
Where-Object { $_.ManagedBy -eq "" }
is likely to not return any results, you would be querying for AD Groups where theirManagedBy
attribute is set and it's value is equal to an emptry string instead of filtering for groups that don't have the attribute set or it's value is$null
or empty string ({-not $_.ManagedBy }
):