Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Write List data to csv powershell

I am getting data like below

Path              : C:\Program Files\ibm\gsk8\lib64
ModifiablePath    : C:\Program Files\ibm\gsk8\lib64
IdentityReference : BUILTIN\Administrators
Permissions       : {WriteOwner, Delete, WriteAttributes, Synchronize...}

Path              : C:\Program Files\ibm\gsk8\bin
ModifiablePath    : C:\Program Files\ibm\gsk8\bin
IdentityReference : BUILTIN\Administrators
Permissions       : {WriteOwner, Delete, WriteAttributes, Synchronize...}

I had to use Fomat-List to bring the data this way because without this the last column Permissions was not visible. and when I tried Export-csv for the data, the last column coming as System.Object[]
Please let me know how to write this data to csv

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use Select-Object to create a new calculated property:

... |Select-Object Path,ModifiablePath,IdentityReference,@{Name='Permissions';Expression={$_.Permissions -join ';'}} |Export-Csv -Path path\to\output.csv -NoTypeInformation
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading