Forum Discussion
AndiPsh180
Dec 21, 2021Copper Contributor
How construct a variable that works with export-csv?
Hello, I have a small csv file that I import in Powershell into a variable. Here it is (as I can't seem to upload a file): "RGG","BAS","IMT"
"keepass","webex","firefox"
"acrobat","ciscoan...
AndiPsh180
Jan 05, 2022Copper Contributor
Hi,
One solution would be to create an array of pscustomobjects like so:
$myArr=@()
for($i=0; $i -lt 10; $i++){
$myArr = $myArr + [PSCustomObject]@{AAA = ""; BBB = ""; CCC = "" }
}
Afterwards I can set any cell of the matrix:
$myArr[2].aaa="note"
The only problem is that I have more then three keys, all through to ZZZ.
As I don't want to type them all, I wonder whether I can get this done programmatically?
I tried to build a string variable and put it within the curly brackets of the hashtable. But the compiler does not allow for that as it requires a hard coded equal sign.
Anybody have an idea?
Thank you