Powershell Powerhsell-ad提取并过滤结果

Powershell Powerhsell-ad提取并过滤结果,powershell,active-directory,export-to-csv,Powershell,Active Directory,Export To Csv,我的朋友们, 我正在寻找和广告提取,但我没有得到我想要的在提取文件中的结果 我正在运行此powershell命令,如果我删除“选择字符串”开关,我将得到我想要的: import-module activedirectory get-aduser -filter * -properties *| Select-Object -Property CN,co,ExtensionAttribute10,extensionAttribute11,extensionAttribute12,Name,Sam

我的朋友们, 我正在寻找和广告提取,但我没有得到我想要的在提取文件中的结果

我正在运行此powershell命令,如果我删除“选择字符串”开关,我将得到我想要的:

import-module activedirectory
get-aduser  -filter * -properties *| Select-Object -Property CN,co,ExtensionAttribute10,extensionAttribute11,extensionAttribute12,Name,SamAccountName,Description,EmailAddress,LastLogonDate,accountexpirationdate,<#Manager#>distinguishedname,Title,Department,whenCreated,Enabled,Organization  |Sort-Object -Property Name | Select-String -Pattern "regular","remote","shopfloor","admin" |Export-Csv -Delimiter ";" -path "u:\theOutFile2.txt"
我的CSV是这样的:

IgnoreCase;"LineNumber";"Line";"Filename";"Path";"Pattern";"Context";"Matches"
我所有的行都是这样写的

True;"1";"@{CN=accountValue; co=; ExtensionAttribute10=; extensionAttribute11=; extensionAttribute12=; Name=accountValue; SamAccountName=accountValue; Description=; 
因此,此脚本的主要目标是检索位于多个OU中的用户帐户,其字符串为“regular”、“remote”、“shopfool”、“admin”


我希望它是清楚的。

在导出Csv之前尝试插入管道:

...|Where-Object {$_.CN -like "*regular*"-or $_.CN -like "*remote*" -or $_.CN -like "*shopfloor*"}| ...

是的,我的朋友,很好用,谢谢你的时间,价格便宜。祝您有个美好的一天
...|Where-Object {$_.CN -like "*regular*"-or $_.CN -like "*remote*" -or $_.CN -like "*shopfloor*"}| ...