In my design, I encounter a problem, that is:
in database, Form table A, I defined a variable name "MyParams", its value is "1,2,3", or "2,3,5" or "5,6,9", that is, the variable will change based on the business logic.
In powershell, below script will deal with some text splitted by ~, it will check if the columns which extract from variable "MyParams" in database is blank, if any columns with blank value, it will exclude this record.
Get-Content "${myFile}.tmp" | Where-Object { $_.Split("~")[1] -ne "" -and $_.Split("~")[2] -ne "" -and $_.Split("~")[3] -ne "" }|Out-File $myFile -Encoding ASCII
here , the numbers (1,2,3) in $.Split("~")[1] $.Split("~")[2] $_.Split("~")[3] come from variable "MyParams" which is configed in database.
my problem is, the MyParams's value is often change, How can I originize my above code to adjust this ?
I think maybe I need to use foreach-object inner Where-object , corrct? anyone can help me? thx.