Answer the question
In order to leave comments, you need to log in
How to summarize variable values in a table in Powershell?
Good day everyone!
As a result of parsing a bunch of files, there are several variables that contain lines with data that all need to be summarized in one table, you can in csv.
$A
abc
zxc
$B
qwe
asd
$C
123
456
A B C
abc qwe 123
zxc asd 456
$tabName = “SampleTable”
#Create Table object
$table = New-Object system.Data.DataTable “$tabName”
#Define Columns
$col1 = New-Object system.Data.DataColumn A,([string])
$col2 = New-Object system.Data.DataColumn B,([string])
$col3 = New-Object system.Data.DataColumn С,([string])
#Add the Columns
$table.columns.add($col1)
$table.columns.add($col2)
$table.columns.add($col3)
#Create a row
$row = $table.NewRow()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question