如何获得对象类型/标识? [英] How to get object type/identifier?
问题描述
在PowerShell中,当我与Active Directory工作具体而言,通常我会编译包含人组的列表的对象通常与 $ X =得到,广告组的筛选器{名状* } |选择对象名称
这给了我一个头或对象类型名称的列表:
In PowerShell, when I work with Active Directory specifically, often I'll compile an object containing a list of groups of people usually with $x = get-adgroup -filter {name -like "*"} | select-object name
which gives me a list with a header or object type name:
name
----------
name1
name2
name3
我如何可以访问该对象的名称头甚至把它变成别的东西吗?
能不能同样做我访问的第一个条目的字符串,如 $的方式X [0]。名称
?
另外,有没有访问与任意条目相关的字符串比较通用的方法是什么?
How can I access the name header of the object or even change it to something else?
Can it be done similarly to the way I would access the string of the first entry like $x[0].name
?
Further, is there a more generic way to access the string associated with an arbitrary entry?
我被问了很多在PowerShell中编程相关的广告,所以任何资源可以提供给帮助我将不胜AP preciated。
I'm being asked to a lot of "programming" in PowerShell related to AD so any resources you can provide to help me would be greatly appreciated.
推荐答案
的两件事情,我想你问的是一个纲领性的方式来确定对象的特定属性的名称。
The two things that I think you are asking for is a programmatic way to determine the name of a given property in an object.
(get-aduser $user | select name).psobject.properties
MemberType : NoteProperty
IsSettable : True
IsGettable : True
Value : Matt
TypeNameOfValue : System.String
Name : name
IsInstance : True
在名称
属性 .psobject.properties
包含了大部分的这些信息,我想你可能会寻找。
The Name
property of .psobject.properties
contains most of this information and I think you might be looking for.
正想回答什么Arco444刚才说的关于使用选择对象
Was going to answer the second part with what Arco444 just said about using select-object
这篇关于如何获得对象类型/标识?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!