Scripting is a powerful aid to system administrators and, if understood properly
ID: 3669686 • Letter: S
Question
Scripting is a powerful aid to system administrators and, if understood properly, to end users as well. Your group has been asked to provide information about file storage needs on all the computers in the network. Your tool of choice for this task is Windows PowerShell.
For this project, do the following:
Download and install Windows PowerShell if it is not already installed on your computer (see Start Menu > Accessories).
Review the Getting Started information in the Windows PowerShell help file, and study the information in the help file and online resource for basic scripting techniques using Windows PowerShell.
Prepare a document to submit your work:
Use Microsoft Word
Title page
Course number and name
Project name
Your name
Date
Write a Windows PowerShell script that will perform the following functions:
Search your computer for files ending with a .doc, .docx, .xls, or .xlsx file extension.
Output the filenames and sizes (in groups by file extension) to a text file named “File_Summary.txt”. The output should also conclude with a total of the number of files and total file size for each file extension.
Include comments in the script code to document the functionality of the script.
Paste the script and the file output to your MS Word document.
Explanation / Answer
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Get all of the files you are looking for with Get-ChildItem much like you were. Vasja mentioned it as well that you might want to use -Recurse to get results from sub directories as well. Use Group-Object to collect the files by extension. For each collection output a custom object of the extension and file count, which both come Group-Object, and the size of all the files of that particular extension converted to MB and rounded to 2 decimal places.
Update for 2.0
In case you only have 2.0 installed I wanted to provide and answer that works for that.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.