【发布时间】:2018-12-22 06:56:20
【问题描述】:
我遇到过使用Get-ADUser -Properties *时未枚举特定属性的情况。例如,以下代码没有列出 msDS-UserPasswordExpiryTimeComputed 属性,即使它存在,我可以将其指定为 -Properties 参数,让它返回,并可以处理它的值。
# Does not return msDS-UserPasswordExpiryTimeComputed
Get-ADUser username -Properties *
# This works to get the msDS-UserPasswordExpiryTimeComputed attribute returned
Get-ADUser username -Properties msDS-UserPasswordExpiryTimeComputed
# If I really want all properties and this one
# I have to specify it alongside *
Get-ADUser username -Properties *, msDS-UserPasswordExpiryTimeComputed
这不仅仅是属性被从显示中省略的情况,我需要明确声明 msDS-UserPasswordExpiryTimeComputed 属性,否则它在生成的对象上根本不可用。
我已经知道在大多数情况下过滤 Properties * 并不是一个好主意,但我很好奇为什么 所有 AD DS 属性没有被枚举,而这正是我要问的要执行的 cmdlet。
这个问题是关于 Get-ADUser 的问题,但与 Get-ADObject cmdlet 的大多数其他行为一样,我认为这种行为扩展到大多数(如果不是全部)它们。
【问题讨论】:
-
很好地枚举了使用
-Properties *时不会返回的其他属性,谢谢 -
也只是想知道,如果你做了
Get-ADObject username -Properties *有什么不同吗? -
是的,当使用
Get-ADUser时,我使用Get-ADObject而不是113 返回了53 个属性(两者都指定-Properties *。所以默认情况下我得到的信息更少。另外,Get-ADObject username没有不适合我(Cannot find an object with identity出错),所以我过滤了我的SamAccountName作为测试。 -
@BendertheGreatest - 虽然我没有支持源,但我很确定 msDS-UserPasswordExpiryTimeComputed being a Constructed Attribute 默认情况下不会显示。根据我的经验,这些仅在您单独查询它们时才会显示。 The attributes which you get from the cmdlet for a particular object type are the set of attributes that govern the creation and update of those objects。请检查它是否有帮助。
标签: powershell active-directory