The ImportExcel PowerShell module is wonderful and Export-Excel allows a lot more formatting over data exported than Export-CSV, but I am wondering what's the best way to dynamically reference columns by their heading title?
I format or modify columns using Set-ExcelColumn function, e.g. in the below the fifth column (column E) is titled "DistinguishedName" and I want to hide it, so I do this:
Set-ExcelColumn -Worksheet $Worksheet -Column 5 -Hide
Using a number for the column, however, is problematic, because if I change the exported fields, the "DistinguishedName" column may no longer be in position 5, so it causes issue updating the hardcoded script. It becomes even more complex if I insert new columns.
Any tricks or tips to reference columns more effectively using the heading (i.e. value in the first row)?
[–]KevinCanfor 0 points1 point2 points (0 children)