如何选择 [Active Directory] ​​对象的扩展属性? [英] How do I select the extended properties of an [Active Directory] object?

查看:73
本文介绍了如何选择 [Active Directory] ​​对象的扩展属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望提取我们所有 Active Directory 帐户的报告,包括每个帐户的某些属性/属性,并将其通过管道传输到 .csv 文件中,以便我可以添加格式和过滤器(等等)管理.

我有他们想要包含的属性列表(DisplayName、SamAccountName、Enabled、Created、AccountExpirationDate、LastLogonDate、PasswordLastSet、EmailAddress),其中大部分是 Get-ADUser cmdlet 的扩展属性.我首先尝试像默认属性一样抓取它们,如下所示:

Get-ADUser -Filter * -SearchBase "dc=somedomain,dc=tld" `|选择 DisplayName、SamAccountName、Enabled、Created、AccountExpirationDate、LastLogonDate、PasswordLastSet、EmailAddress `|导出-csv c:\DominAccountsPasswordInfoDump.csv -NoTypeInformation

...但这不起作用,因为扩展属性 "只有在 cmdlet 的 -Properties 参数中指定时才会被检索",所以我得到了一个带有一堆空白列的 .csv.>

现在我的问题是我不知道如何在我的 select 语句中指定 -Properties 参数,(我似乎在每个方面都收到以下错误消息我试试)

<块引用>

Select-Object : 找不到与参数名称Parameters"匹配的参数.

考虑到其中的 select-object 部分,我开始怀疑是否需要定义我读入的每个用户对象(将它分配给 $user 变量,或者其他东西),此时我想我应该在进一步处理之前寻求帮助.由于搜索 Google 和 StackExchange 没有帮助,我在这里问.

如何选择 AD 用户的扩展属性?(理想情况下,使用上面的单行脚本/PowerShell 命令.)

解决方案

您可以在 Get-ADUser cmdlet 中执行此操作.

示例:'

$Properties =@('显示名称','SamAccountName','启用','创建','账户到期日','上次登录日期','PasswordLastSet',' 电子邮件地址')Get-ADUser -Filter * -SearchBase "dc=somedomain,dc=tld" -Properties $Properties |选择 $Properties |导出-csv c:\DominAccountsPasswordInfoDump.csv -NoTypeInformation

然后选择将排除您不想导出的默认属性.

I'm looking to pull a report of all our Active Directory accounts, include certain attributes/properties on each, and pipe it into a .csv file, so I can add formatting and filters (and so on like to) for management.

I've got a list of attributes that they want included (DisplayName, SamAccountName, Enabled, Created, AccountExpirationDate, LastLogonDate, PasswordLastSet, EmailAddress), most of which are extended properties of the Get-ADUser cmdlet. I first tried to grab them like the default attributes, as below:

Get-ADUser -Filter * -SearchBase "dc=somedomain,dc=tld" `
| select DisplayName, SamAccountName, Enabled, Created, AccountExpirationDate, LastLogonDate, PasswordLastSet, EmailAddress `
| export-csv c:\DominAccountsPasswordInfoDump.csv -NoTypeInformation

...but that didn't work, as extended properties "are only retrieved if they are specified in the -Properties parameter of the cmdlet", so I got a .csv with a bunch of blank columns.

Now my problem is that I don't know how to specify the -Properties parameter within my select statement, (I seem to get the below error message every way I try)

Select-Object : A parameter cannot be found that matches parameter name 'Parameters'.

And on thinking about the select-object part of that, I'm starting to wonder if I need to define each user object I read in (assign it a to $user variable, or something), at which point I figured I should probably ask for help before mucking around any further. Since searching Google and StackExchange didn't help, I'm asking here.

How do I select the extended properties of an AD user? (Ideally, using the one-line script/PowerShell command I've got above.)

解决方案

You do that in the Get-ADUser cmdlet.

Example:'

$Properties =
 @( 
 'DisplayName',
 'SamAccountName',
 'Enabled',
 'Created',
 'AccountExpirationDate',
 'LastLogonDate',
 'PasswordLastSet',
' EmailAddress'
 )

Get-ADUser -Filter * -SearchBase "dc=somedomain,dc=tld" -Properties $Properties | 
 select $Properties |
 export-csv c:\DominAccountsPasswordInfoDump.csv -NoTypeInformation

The select will then exclude the default properties you don't want to export.

这篇关于如何选择 [Active Directory] ​​对象的扩展属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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