powershell - 使用 powershell 按“城市”和“成员”组过滤的广告用户
问题描述
我们开始升级我们的 Citrix 平台,我正在尝试使用 AD 来获取当前在特定站点以及使用我们的 Citrix 环境的用户列表。我目前有以下内容来过滤网站并删除任何离开者等:
Get-ADUser -Filter 'City -Like "Portsmouth" -and Description -notlike "LEAVER*" -and Description -notlike "This user was*"' | select-object name, userprincipalname | format-table
这很好用,但是我现在只需要按我们的 Citrix 'Member of' 组中的人进行过滤。我相信我可以自己使用以下内容:
Get-ADGroupMember 'Citrix_USR'
但是,我正在努力寻找一种方法将其添加到我之前的搜索中并使其正常工作。任何帮助或指出我正确的方向都会很棒。
PS这是我第一次发帖,请多多关照,哈哈。
解决方案
Where-Object
您可以使用cmdlet 对MemberOf属性执行筛选。
确保使用Get-ADUser
cmdlet指定请求的属性-Properties MemberOf
或-Properties *
像这样:
#first you get distinguished name
$dn = Get-ADGroup 'Citrix_USR' | Select -ExpandProperty DistinguishedName
#now you perform filtering
Get-ADUser -Filter 'City -Like "Portsmouth" -and Description -notlike "LEAVER*" -and Description -notlike "This user was*"' -Properties MemberOf | Where-Object {$_.MemberOf.Contains($dn)} | Select-Object name, userprincipalname | Format-Table
推荐阅读
- forms - 将 Flex URLRequest 和 navigateToURL 表单模拟重新编码为 Royale JS
- python - 将 TFLite (TensorFlow) 转换为 MLModel (Apple)
- jquery - 在 wordpress 中切换类
- vtk - 在 VTK 中获取特定轮廓
- c# - 为什么客户端(C# 的 HoloLens)无法从服务器(python 的 PC)接收消息?(客户端可以将图像发送到服务器。)
- amazon-web-services - 是否可以使用 aws mediaconvert 从 mkv 视频文件中提取 subrip 字幕
- python - f-strings 多行打印顺序错误
- c# - 让线程在开始下一组任务之前等待所有任务完成
- flutter - 使用 bloc 处理来自 Post 方法的回调响应
- java - 添加Jpa maven依赖项后无法运行spring boot应用程序