PowerShell Active Directory查询
使用PowerShell的新手,所以对于我所展示的任何杂物,我深表歉意。
我正在尝试从Active Directory提取用户名,活动状态,到期日期和标题。
我的PowerShell命令是:
Get-ADUser -Filter * -SearchBase "DC=XXX,DC=XXXX" |
Select-Object Name, GivenName, Surname, SamAccountName, DistinguishedName, enabled, Title, AccountExpirationDate |
Export-Csv -Path c:\users\myname\ADUsersWithExpirationDate.csv
查询成功运行,但即使某些用户帐户在AD中都有或两个值,也从未显示标题或到期日期。同样,状态(启用)并不总是填充:返回的值是真实的,false或null的。所有的null(我已经检查过的)都是活动用户帐户,但似乎在非标准OU(例如Admins)中。
任何洞察力或建议都非常欢迎。
提前致谢。
New to using Powershell, so I apologize for any noobness that I show.
I'm trying to extract user names, active status, Expiration Dates and Titles from Active Directory.
My Powershell command is:
Get-ADUser -Filter * -SearchBase "DC=XXX,DC=XXXX" |
Select-Object Name, GivenName, Surname, SamAccountName, DistinguishedName, enabled, Title, AccountExpirationDate |
Export-Csv -Path c:\users\myname\ADUsersWithExpirationDate.csv
The query runs successfully, but does not ever show a Title or Expiration Date even though some user accounts have either or both values in AD. Also status (Enabled) does not always populate: the returned values are True, False, or null. All of the Nulls (that I've checked) are active user accounts, but appear to be in non-standard OU's (Admins for example).
Any insight or recommendations are very welcome.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,AD CMDLET不会返回所有属性。您需要使用
-properties
参数将accountExpirationDate和标题属性添加到查询中。您的命令应该看起来像:By default the AD cmdlets don't return all the attributes. You need to use the
-Properties
parameter to add the AccountExpirationDate and Title attributes to the query. Your command should look something like: