简体   繁体   English

在Powershell中使用dsquery时如何排序和显示组?

[英]How can I sort and display groups when using dsquery in powershell?

I am using this line of code in powershell and it works but it displays too much. 我在powershell中使用这一行代码,它可以工作,但显示太多。 I am trying to find and display where the group that contains "Avecto" in the name. 我正在尝试查找并显示名称中包含“ Avecto”的组的位置。

dsquery user -samid MyUSerName| dsget user -memberof | dsget group -samid

Is there anyway to add that on this script statement? 无论如何,要在此脚本语句上添加它吗?

Use the where keyword in PS (shorthanded here as ? ) 在PS中使用where关键字(此处缩写为?

dsquery user -samid MyUSerName| dsget user -memberof | dsget group -samid | ? {$_ -match 'avecto'}

So it would read where each item in the pipeline matches the string 'Avecto' 因此它将读取管道中每个项目与字符串“ Avecto”匹配的位置

You could store the data into a variable and manipulate further, as just a simple Object array will be returned if more than one result, otherwise in a single result it will just be a string 您可以将数据存储到变量中并进行进一步操作,因为如果有多个结果,则仅返回一个简单的Object数组;否则,在单个结果中,它将只是一个字符串

Hope that helps 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用PowerShell将Active Directory用户排序为互斥组? - How can I sort Active Directory users into mutually exclusive groups using PowerShell? 尝试使用 dsquery 使用 Powershell 禁用不活动的 AD 计算机 - Trying to disable inactive AD Computers using Powershell using dsquery 检查DSQuery在PowerShell中是否成功? - check if DSQuery was successful in PowerShell? Powershell / dsquery将一组用户数组中的用户列表拉成一个具有唯一用户的数组 - Powershell / dsquery Pull list of users in an array of groups make an array with the unique users 如何在 PowerShell 中按列排序? - How can I sort by column in PowerShell? 如何使用 PowerShell 复制 AzureAD 用户组以匹配帐户? - How can I copy AzureAD user groups with PowerShell for matching accounts? 我如何为 powershell 的每个联系人提取邮件联系人组? - How can I pull Mail Contact groups for each contact with powershell? 如何在 powershell 中按时间戳对文本数据进行排序 - How can I sort text data by timestamp in powershell 如何在Powershell中显示其他属性? - How can I display an additional property in Powershell? 如何在PowerShell中按groups数组的值对正则表达式匹配项进行排序 - How to sort a regex match in PowerShell by a value of the groups array
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM