powershell saving to file each time rather than memory
I work in a large enterprise and work with a lot of one liners that collection information and exports this out to a .csv. What I notice in powershell but have not been able to find for more solution there is a way to cycle through the command each time and save this in the file. The way I am currently using is as it cycles through it is stored in memory and when it finishes it then exports this into a file. I do not have a lot of RAM and would prefer each time that it runs a command on each user to export this directly into a file. I hope that I am clear.
From your example it's not clear what you're doing so it would be hard to suggest a modification. For the command shown you would just add a pipe to Export-CSV at the end, there's no collecting in memory happening.
thanks footech its really that's something not possible with powershell. I wanted to intercede the OS and force the OS to save to the file on each iteration of a value rather than store in memory. Right now the following occurs
foldername path
pfo1 pf01\something----------have this value saved or appended directly to file. currently in memory until completed.
pfo2 pf02\something----------have this value saved or appended directly to file. currently in memory until completed
pfo3 pf03\something----------have this value saved or appended directly to file. currently in memory until completed
pfo4 pf04\something----------have this value saved or appended directly to file. currently in memory until completed
pfo5 pf05\something----------have this value saved or appended directly to file. currently in memory until completed
Sorry I was not clear enough let me know if this helps.
footech
With the command you posted, each object will be output to screen as it's retrieved, and it won't be kept in memory.
I am aware of this but when you place thisnin a file export-csv or output-file powershell stores the contents of the output in memory. I was trying to intercede and have this to write to a file each iteration.
Open in new window