Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Scripting is a powerful aid to system administrators and, if understood properly

ID: 3669979 • 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

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

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to COM and WMI, enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and CIM enabling management of remote Linux systems and network devices.

Windows PowerShell includes a dynamically typed scripting language which can implement complex operations using cmdlets imperatively. The scripting language supports variables, functions, branching (if-then-else), loops (while, do, for, and foreach), structured error/exception handling and closures/lambda expressions,[29] as well as integration with .NET. Variables in PowerShell scripts have names that start with $; they can be assigned any value, including the output of cmdlets. Strings can be enclosed either in single quotes or in double quotes: when using double quotes, variables will be expanded even if they are inside the quotation marks. Enclosing the path to a file in braces preceded by a dollar sign (as in ${C: oo.txt}) creates a reference to the contents of the file. If it is used as an L-value, anything assigned to it will be written to the file. When used as an R-value, the contents of the file will be read. If an object is assigned, it is serialized before being stored

$Folder_To_Check = C:Desktopsri
$Report_File_Location = "File_Summary.txt"

$results = Get-ChildItem $Folder_To_Check -Include *.doc,*.docx,*.xls,*.xlsx -Recurse
$results | Group-Object extension | ForEach-Object {
    [PSCustomObject]@{
        Extension = $_.Name
        Count = $_.Count
        Size = [Math]::Round(($_.Group | Measure-Object -Sum Length | Select-Object -ExpandProperty Sum) / 1MB,2)
    }
} | Out-File $Report_File_Location -Append

Get-ChildItem is Get all of the files you are looking
Recurse to get results from sub directories

Group-Object to collect the files by extension
the size of all the files of that particular extension converted to MB and rounded to 2 decimal places

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote