Unfortunately I don't expect a very high score in the Leader board since I did not submit the good version of my script... Shame.... But anyway I learned a bit from this event and wanted to share my solution. Hope this help someone out-there.
Instruction
Download [SkyDrive]
Dr. Scripto has been fielding a lot of calls from the Help Desk lately. They’ve been asking him to look up information about the local hard drives in various servers – mainly size and free space information. He doesn’t mind helping, but all the requests have been getting in the way of his naps. He’s asked you to write a tool comand that can get the information for the help desk – and theywants the output in an HTML file. The HTML file should look something like this:
The Doctor says you should parameterize your command – he wants to be able to pipe in one or more computer names as strings.The resulting HTML does need to go into an HTML file on disk someplace, and that file should have the computer name (e.g., the computer SERVER1 should have Server1.html, SERVER2 should have server2.html, and so on). A parameter should let him indicate the path (directory) to write the files to. Also, he wants you to pay special attention to the following:
- The browser displays “Disk Free Space Report” in the page tab when viewing the report.
- “Local Fixed Disk Report” is in the H2 (“Heading 2”) HTML style.If you can actually add the computer name to that – bonus!
- The report ends with an HTML horizontal rule and the date and time that the report was generated.
The command you write can assume that both WMI and CIM are available on the remote computers, and that all the necessary firewall rules and authentication have already been taken care of.
- The size and free space values are shown as gigabytes (GB) and megabytes (MB) respectively, each to two decimal places.
Solution
Finding the disk information
We'll have to use WMI/CIM to get this information on the remote computers.
To find which class to use, I typed the following commands:
Get-CimClass *disk*
Get-CimClass *disk* -PropertyName *size*