简体   繁体   English

我需要从Active Directory中提取一些数据。 我想要一个AD用户列表,其姓氏字段的姓氏后面有“ PA”

[英]I need a pull some data from Active Directory. I want a list of all the users in AD whose last name field has “PA” after their last name

Use PowerShell to pull all users from AD that has "PA" in the last name field. 使用PowerShell从姓氏字段中具有“ PA”的AD中拉出所有用户。

Get-ADuser -Filter * -Properties * | Where-Object {$_.SurName -Like "*PA*" -And $_.DisplayName -Like "*PA*"} | Select Name, SamAccountName | FT

Get-ADuser -Filter * -Properties * | Where-Object {$_.SurName -Like "*PA*" -And $_.DisplayName -Like "*PA*"} | Select Name, SamAccountName | FT

It is pulling the names of all the user sin AD whose last name has the value of "PA" for example: "Palmer" or "Joppa". 它正在提取姓氏值为“ PA”的所有用户sin AD的名称,例如:“ Palmer”或“ Joppa”。 That is not what ia m looking for. 那不是我想要的。 This is what i want. 这就是我要的。 Say a user first name a John and last name is Cooper. 假设用户的姓氏为John,姓氏为Cooper。 But then when the account was created in AD, the last name is listed as "Cooper PA". 但是,当在AD中创建帐户时,姓氏将列为“ Cooper PA”。 So the "PA" is after the last name with a space between and last name and the "PA". 因此,“ PA”位于姓氏后面,并且姓氏和“ PA”之间有一个空格。

Get-ADuser -Filter 'surname -like "* pa"'

EDIT: You should frame a question clearly, and give a coding attempt. 编辑:您应该清楚地提出问题,并尝试进行编码。 But this is interesting: 但这很有趣:

get-aduser -filter * | group-object { "$($_.givenname) $($_.surname)" }

Count Name                      Group
----- ----                      -----
2     Joseph Smith              {CN=jsmith,OU=People,DC=stackoverflow,DC=com, CN=jsmith2...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我需要一个更具体的 Powershell 命令来隔离域中用户的 Active Directory 名称、用户名和上次登录日期 - I need a more specific Powershell command to isolate Active Directory names, usernames, and last login date from users on a domain 我想使用 AccountExpires 获取 Active Directory 用户的列表,但该属性对所有用户返回空 - I want to get a list of Active Directory users with the AccountExpires but the property returns empty on all users 将广告用户添加到组(名字,姓氏) - Add ad users to a group (First Name, Last Name) 从Active Directory说明中拉出名称 - Pull out name from Active Directory description 我想从 Active Directory 中的组中删除用户 - I want to delete users from a group in Active Directory 需要列表中的每个名称来查询活动目录 - Need every name in the list to query active directory 使用Powershell列出活动目录用户显示名称,OU和上次密码更改日期 - list active directory User Display Name, OU and last password change date using powershell 只打印列表中的最后一个服务器,我希望所有服务器 - Only prints the last server in the list, I want all servers Powershell Active Directory从我的广告组中获取所有用户 - Powershell Active Directory get all users from my AD groups 通过Powershell使用导入的.csv从Active Directory中提取名字和姓氏 - Extract First and Last Name from Active Directory using imported .csv through Powershell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM