powershell - 获取有关组描述的 Active Directory 组及其成员的列表
问题描述
我想根据组描述(文本)获取 Active Directory 组及其成员(用户)的列表。如果输出文件采用以下格式,那就太好了:
第 1 组 用户 1 用户 2 用户 3 第 2 组 用户 2 用户 3 第 3 组 用户 1 ......
到目前为止,我得到了包含描述中文本的组列表。我无法获得这些团体的成员。
Get-Adgroup -Filter * - Properties Name, Description | Select Name, Description | Where-Object {$_.Description -eq "description-text"}
我确实得到了组(名称)和描述列表,其中仅包含具有所需描述的组。我试图继续, | Get-AdGroupMember -Identity
但没有成功。
解决方案
尽可能靠近管道的左端进行过滤会更有效,即用于描述。尝试这样的事情:
# Gets all groups with the specific description
$Groups = Get-ADGroup -Filter "Description -like 'description-text'"
# Iterate through the list of groups
foreach ($Group in $Groups) {
$Group.Name # Outputs the group name
$Users = $Group | Get-ADGroupMember # Gets the list of users in that group
$Users.Name # Outputs all the users' names
}
推荐阅读
- r - 使用 gtsummary 包的宽格式多项逻辑回归结果表
- javascript - HTML 显示在实时服务器上,但未在我的烧瓶应用程序上呈现。只有索引显示在烧瓶上
- r - 在 R Shiny 的表中插入 ggplot barplot
- c# - 如何更改 WorkflowApplication 的线程(优先级)
- php - 如果产品在购物车中,则更改“添加到购物车”按钮文本,并在 WooCommerce 中满足条件时重定向到购物车页面
- firebase - 如何从 Cloud Functions 中的实例模板创建 VM 实例?
- python - 关于 Python 中的 pytz 模块和 time 模块
- python - 完整的数据无法从密码保护工作簿复制到 python 中的另一个工作簿
- javascript - 在 Javascript 中重复 ACF 字段
- android - 如何在 CardView 上方设置按钮?(在 XML 上工作,但现在在应用程序启动时)