, , .
, , :
$Filtered = $Table|Select-String -Pattern $ExcludeStrings -NotMatch -SimpleMatch
$FilteredArray = @()
$Filtered.Line | foreach {$split = $_ -split ';';
$tidied = $split -replace '@|{|}|^ ';
$obj = New-Object System.Object
$tidied|foreach {$obj|Add-Member -MemberType NoteProperty -Name ($_.split('=')[0]) -Value ($_.split('=')[1])
}
$FilteredArray += $obj
}
, Import-CSV, , .
, MatchInfo, :
@{Column1=Value1; Column2=Value2; Column3=Value3;}
CSV , .
, ($FilteredArray).
Then I passed Linethe matchinfo array property from Select-Stringto the foreach loop, and for each line I split it into half-time, then I delete the @ {} characters and any leading spaces.
Then I create a new one System.Object, then translating the result into another foreach loop, creating new NoteProperty objects in obj, calling them from the current line in finished form to the = character, and the value is the remaining text after the = character.
As a result, I get:
PS C:\Users\Graham> $obj
Column1 : Value1
Column2 : Value2
Column3 : Value3
And the filtered array looks like this:
PS C:\Users\Graham> $FilteredArray[0..3]|Format-table
Column1 Column2 Column2
------- ------- -------
Value1 Value2 Value3
Value1 Value2 Value3
Value1 Value2 Value3
source
share