Skip to main content

Posts

Showing posts from November, 2022

Create easy to use Excel (csv) from a PowerShell export

Problem I get rusty in between coding projects, and I forget how to do what seems to be basic things like building and exporting a table to CSV for use in Excel or other downstream process/automation/data integration, etc. PowerShell covered Variables simple process for collecting an array of information  Foreach loop @([pscustomobject]@{}) += Export-CSV Logical Process To build a file I can use in Excel, the steps involved are creating an empty variable which I will use as the array to store the table,  Crate an empty variable to store data for later export to the CSV/Table Process to retrieve raw data to process into the CSV/Table for me this is usually Get-ADUser, Get-ADGroupMember, a SQL query, or a request from a SharePoint API for list data for this demonstration we use Get-Process because everyone uses it for demos 😋 Foreach loop to process the raw data gleaning only the data I need for the table += appending each looped occurrence into the CSV/Table @([pscustomobject]@{}) - th