I am trying to log "snapshots" of a specified disk drive's usage and capacity on the date/time the script is run. The schema of the table must resemble the following:
Datetime Drive Used (GB) Capacity (GB)
10/3/2022 16:24 C 225.2344 995.5
10/3/2022 16:29 C 223.5344 995.5
10/4/2022 20:34 C 221.8344 995.5
10/6/2022 10:39 C 220.1344 995.5
10/7/2022 04:44 C 218.4344 995.5
10/8/2022 08:49 C 216.7344 995.5
10/9/2022 12:54 C 215.0344 995.5
I want the script to essentially open a CSV file (assuming it exists) and insert a new line at the end of the table (Datetime, Drive, Used (GB), Capacity (GB)).
I've used Get-PSDrive C
with Export-CSV
to get almost all the information I need, aside from the timestamp. However, I have not found success yet with inserting a new line instead of overwriting the existing data.