[英]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.