简体   繁体   English

让AD用户在AD中的描述字段中具有特定关键字

[英]Getting AD users having a specific keyword within description field in AD

I want to get all of those users starting with a specific keywords in AD User Description field using PowerShell. 我希望使用PowerShell将所有这些用户从AD用户描述字段中的特定关键字开始。 Keyword: Could not execute powershell 关键字:无法执行powershell

Import-Module ActiveDirectory

Get-ADUser -Filter * -SearchBase 'OU=contoso, DC=contoso, DC=local' - Properties Description | select -expand name,distinguishedname,description  | Export-Csv -path C:\description.csv -NoTypeInformation

Last Update : 最后更新 :

 Get-ADUser -Properties Description -Filter 'Description -like "*Could not  execute powershell*"' -SearchBase 'OU=contoso, DC=contoso, DC=local' | 
select name,distinguishedname,description  | 
Export-Csv -path C:\description2.csv -NoTypeInformation

This is an easy task using the -filter option that you can use with get-aduser . 使用-filter选项可以轻松完成这项任务,您可以将其与get-aduser

For more info how to filter: https://technet.microsoft.com/en-us/library/ee617241.aspx?f=255&MSPPError=-2147217396 有关如何过滤的更多信息: https//technet.microsoft.com/en-us/library/ee617241.aspx?f = 255&MSPPError = -2147217396

Under the filter bit 在过滤器位下

 Get-ADUser -Properties Description -Filter {Description -like $Description} -SearchBase 'OU=contoso, DC=contoso, DC=local' | select Name, DistinguishedName, Description | Export-Csv -path C:\description2.csv -NoTypeInformation

您只需过滤描述:

Get-ADUser -Properties Description -Filter 'Description -like "*Could not execute powershell*"' -SearchBase 'OU=contoso, DC=contoso, DC=local' 

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM