使用包含条件和通配符的数组时出现问题 [英] Issue using an array containing criteria with wildcards

查看:87
本文介绍了使用包含条件和通配符的数组时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试运行powershell代码将文件拆分为2.

I've been trying to run a powershell code to split a file in 2.

我有几个常规数组,效果很好. 第三个数组包含每个条件的通配符,这根本不起作用.

I've got a couple of regular arrays, that works just fine. The 3rd array contains wildcards for each of the criteria, and that doesn't work at all.

我已经尝试-in -notin,-like -notlike,-contains -notcontains,-match -notmatch,但我没有得到想要的结果.

I've tried -in -notin, -like -notlike, -contains -notcontains, -match -notmatch, i'm not getting the results I want.

    $NonAutoStructure = @("Not_Found", "UK Training Centre", "IRISH Training Centre", "Head Office", "UK Newmedica")
$AutoJournalDescriptions = @("STORE TRANFrom *",  "*SALES BANKED*")#, "*/* CREDIT" , "BANKING DIFF*BQ*" , "*/* MASTERCARD/VISA")  
$InactiveStores = @("4410", "0996", "1015", "5996")


$NonAutoJournalCompanies = {$_.Description -notcontains $AutoJournalDescriptions} 
$AutoJournalCompanies = {$_.Description -contains $AutoJournalDescriptions}
#$NonAutoJournalCompanies = {$_.structure -in $NonAutoStructure -or $_.Company -in $InactiveStores -and  $_.Amount -ne "0.00"}
#$AutoJournalCompanies = {$_.structure -notin $NonAutoStructure-and $_.Company -notin $InactiveStores -and  $_.Amount -ne "0.00"}

$UNREC_S0 | Where-Object $NonAutoJournalCompanies | Export-Csv \\774512-LRBSPT01\*****$\uardata\rt1\BankRec\Test\step1\TestNonAutoJournal.txt -notype
$UNREC_S0 | Where-Object $AutoJournalCompanies | Export-Csv \\774512-LRBSPT01\*****$\uardata\rt1\BankRec\Test\step1\TestAutoJournal.txt -notype
$UNREC_S0 | Where-Object $ZeroValuelines | Export-Csv \\774512-LRBSPT01\*****$\uardata\rt1\BankRec\Test\step1\TestZeroLines.txt -notype

我遇到问题的数组是$ AutoJournalDescriptions.如果数组包含单个条件,则只能使它工作.否则,似乎将它们全部忽略. 在这里,它仅包含一对,但是#之后的条件也应包括在内. 我试图在#(Non)AutojournalCompanies文件中包括和排除这些标准,以便所有数据都被预先保留,但分开后可以定向到不同的处理流.

The Array I have issues with is the $AutoJournalDescriptions. I can only get it working if the array contains a single criteria. Otherwise, it seems to ignore them all. Here it only contains a couple, but the criterias after the # should be included too. I'm trying to include and exclude these criterias as part of #(Non)AutojournalCompanies files so that all data is preseverd, but separated and can then be directed towards different process streams.

也许我只是在尝试使用一个不打算那样工作的功能...? 我整天都在寻找解决方案,但无济于事. 我可以在文件生产条件中单独键入所有这些条件,但这会使读取变得繁重且难以维护.我希望在需要更改时丰富/修改数组.

Perhaps i'm simply trying to use a function that isn't meant to work that way...? I've been searching for a solution all day to no avail. I could type all those criterias individually in the file production criteria, but that makes it heavy to read and cumbersome to maintain. I would prefer to enrich/modify the array when changes are required.

我希望一切都说得通. 我对Powershell很陌生.

I hope that all makes sense. I'm pretty new to powershell.

非常感谢,

Antoine

推荐答案

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆