0

I folks, I'm looking for and ad extract but I'm not getting the restult I want in the extracted file.

I'm running this powershell command, if I remove the "select-string" switch I get what I want:

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"

As soon as i use the Select-String -Pattern my csv is getting wierd.

Instead of having info like

CN;"co";"distinguishedname";"ExtensionAttribute10";"extensionAttribute11";"extensionAttribute12";"Name";"SamAccountName";"Description";"EmailAddress";"LastLogonDate";"Manager";"Title";"Department";"whenCreated";"Enabled";"Organization"

My CSV is like this:

IgnoreCase;"LineNumber";"Line";"Filename";"Path";"Pattern";"Context";"Matches"

and all my line are write like

True;"1";"@{CN=accountValue; co=; ExtensionAttribute10=; extensionAttribute11=; extensionAttribute12=; Name=accountValue; SamAccountName=accountValue; Description=; 

So the main goal of this script is to retrive users accounts that are in Multiple OU with string "regular","remote","shopfloor","admin"

I hope it's clear.

4

1 回答 1

1

尝试在您的管道之前插入export-Csv

...|Where-Object {$_.CN -like "*regular*"-or $_.CN -like "*remote*" -or $_.CN -like "*shopfloor*"}| ...
于 2013-06-18T09:44:06.087 回答