Write a Windows PowerShell script that will perform the following functions: Sea
ID: 3669319 • Letter: W
Question
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
Powershell script for search files like .doc , .docx , .xls etc is as follows :
$Report_File_Location = "File_Summary.txt"
$files = GEt-Childitem C:AIU -include "*doc","*docx","*xls","*xlsx"-recurse | sort-object | Get-Unique -asString
$files | Out-File $Report_File_Location
$totalfiles=($files | Measure-object).Count
$totalsize=($files | Measure=Object -Sum Length).Sum
write-host "totalfiles: $totalfiles"
write-host "totalsize: $totalsize"
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.