• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: use where-object to find data, but want to add data to every row also the export to csv

Resolved: use where-object to find data, but want to add data to every row also the export to csv

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

Hi I have a script that reads a csv file, creates a json file, checks the users in the file against a service, then i get the result as a json file. I take that result and finds the users i csv file and creates a new file. I do that with a where-object
But i need to add some extra values on every user before i export it to csv
This is my 2 lines for finding users and then export
$matches | Export-Csv -path $Saved$savefile -NoTypeInformation -Append
Is that possible or do i need to do a for each?
Cheers

Answer:

Assuming I’ve interpretted your question correctly, you should be able to use PowerShell’s Calculated Properties for this purpose.
For example, if you wanted to add a field called “Date” and set the current Date/Time to each user row, you could do the following:
The Expression value can either be a static value such as “StaticValue”, a variable such as $i (useful if used as part of a loop, for example) or more complex value that is returned from other cmdlets (as in my example above)

If you have better answer, please add a comment about this, thank you!

csv json powershell
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Why reference in pointer array doesn’t have data?

24/03/2023

Resolved: EntityFramework creates/runs migrations using parameterless DataContext instance

24/03/2023

Resolved: Visual Studio 2022 crashes when using breakpoints

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.