Preface: I’m new to the forum and currently breaking out of the ‘beginner’ PowerShell user space and have been going through and re-writing any/all of my current scripts to include more information and/or increase their automation/function.
That said, after hours of hacking around, I just finished re-writing a server disk space report that I had previously used, which initially did what I wanted it to do: read in a list of FQDN server names, retrieved disk space information using WMI, did a few calculations and spit the results to a .CSV file. I needed some more versatility and the original sort on the ‘Percent Free Space’ column wasn’t working. What I have, today, is a script that relies more on variables, exports the report as an HTML file with some custom formatting and the sorting is fixed.
The major hang up I ran into was figuring out the sorting. Long story, short, I figured out I was trying to sort an array, which wasn’t working. After looking at the entire thing, when I was done, it just seems like there may be a more efficient way of getting what I want. I was thinking the use of functions may be useful, but I’m not knowledgable enough with the more advanced methods PowerShell has to offer.
Any input or criticism is welcome!
Attached is a generalized copy of the script and what the output looks like.
I figured I’d post here, rather than the ‘Q & A’ section; feel free to move wherever it may be necessary.