Gathering the Information

    This is a straightforward function, and the main reason I bothered to even make it a function - as opposed to just using Get-WmiObject directly - is that I want different property names, like “OSVersion” instead of just “Version.” That said, I tend to follow this exact same programming pattern for all info-retrieval functions, just to keep them consistent.

    Here, I’ve had to recognize that I’ll be getting back more than one object from WMI, so I have to enumerate through them using a ForEach construct. Again, I’m primarily just renaming properties. I absolutely could have done that with a Select-Object command, but I like to keep the overall function structure similar to my other functions. Just a personal preference that helps me include fewer bugs, since I’m used to doing things this way.

    The main thing of note here is how I’ve converted the speed property, which is natively in bytes, to megabytes. Because I don’t care about decimal places here (I want a whole number), casting the value as an integer, by using the -as operator, is easier for me than the -f formatting operator. Also, it gives me a chance to show you this technique!