简体   繁体   中英

AD User Array CSV search and analyze error

i want to search to an exported Active Directory list but i got one problem.

AD Files looks like this and its saved as CSV-File (I added a Header to the file)

CN=ARV-PRO7,OU=etc,OU=etc,DC=etc,DC=etc,DC=etc
CN=BLAPO86z,OU=etc,OU=etc,DC=etc,DC=etc,DC=etc

This is a example (there are 37 more entrys like ARV in the "where" is shoreted it for better view) of the Code im trying to run:

$Datei = Import-Csv "C:\FILESPATH\AD-list.csv"
$Datei | where {$_.CN -notmatch "ARV" -and $_.CN -notmatch "BBN"} | Out-GridView -Title "Site Info"

This shows me all the items with no ARV in it, thats what i want. BUT it ignores also the items which looks like this:

CN=PR122ARVO7,OU=etc,OU=etc,DC=etc,DC=etc,DC=etc

Because ARV is in the name the item is not shown. I need a way to check if the first 3 letter ARV than its okay and he can ignore it but i also need him to show me names with ARV in it to check the name rules. ( Department-PCNAME ) and not (BLABLA-PC-DEPARTMENT-NAME)

I Hope its clear what iam asking and what my problem is ^^

If I understand correctly, you would like to ignore items starting with ARV. This should work (simplified, only where section is important here):

@{CN='ARV-PRO7'},
@{CN='BLAPO86z'},
@{CN='PR122ARVO7'} | where { !$_.CN.StartsWith('ARV') }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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