如何在没有“..."的情况下从 Powershell 显示成员中的所有项目 [英] How to display all items in a member from Powershell without "..."

查看:52
本文介绍了如何在没有“..."的情况下从 Powershell 显示成员中的所有项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行以下命令:

Get-ADUser <username> -properties MemberOf | select MemberOf | Format-List *

产生类似的结果

MemberOf : {CN=XXX,OU=xxx,OU=xxx,DC=xxx,DC=com, CN=XXX,OU=xxx,OU=xxx,DC=xxx,DC=com,CN=XXX,OU=xxx,OU=xxx,DC=xxx,DC=com,...}

我不想看到..."我实际上想看到所有项目.

I do not want to see "..." I actually want to see all the items.

推荐答案

使用Select-Object-ExpandProperty开关:

Get-ADUser <username> -Properties MemberOf | select -ExpandProperty MemberOf

当您使用 Select-Object 过滤某些属性时,它会返回一个 PSCustomObject,其中包含所选对象的指定属性(或 PSCustomObject 数组,如果选择了多个对象).使用 -ExpandProperty,它只能与单个属性一起使用,对于每个选定的对象,它返回包含在指定属性中的对象.

When you use Select-Object to filter for certain properties, it returns a PSCustomObject containing the specified properties of the object selected (or an array of PSCustomObjects, if multiple objects are selected). With -ExpandProperty, which may be used with only a single property, for each object selected it returns the object contained in the specified property.

所以,使用 |select MemberOf,返回的是一个PSCustomObject,它的唯一属性是Get-ADUser返回的ADUser对象的MemberOf属性,以列表格式显示(在与列出对象的多个属性时显示结果的样式相同).

So, with | select MemberOf, what's being returned is a PSCustomObject whose sole property is the MemberOf property of the ADUser object returned by Get-ADUser, displayed in list format (in the same style as it would display the results if you were listing multiple properties of the object).

使用<代码>|select -ExpandProperty MemberOf,返回的是 ADPropertyCollection 对象,该对象包含在 MemberOf 属性(代表成员 DN 的字符串集合)中,这就是显示在列表格式.

With | select -ExpandProperty MemberOf, what's being returned is the ADPropertyCollection object which is contained in the MemberOf property (a collection of strings representing the DNs of the members), and that's the object that's displayed in list format.

顺便说一句,我删除了|Format-List * 因为在这种情况下它是多余的.

BTW, I removed the | Format-List * because it's superfluous in this case.

这篇关于如何在没有“..."的情况下从 Powershell 显示成员中的所有项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆