In: Computer Science
For this assignment, you will need any computer running PowerShell v5 or later. Your answer should only include the function or the script files that generate the results.
solution;
script.ps1
************
$path = "C:\Windows\System32"
$destination = "C:\Users\Administrator\Desktop\output.txt"
$results = Get-ChildItem $path -Recurse | where {$_.extension
-in ".dll",".exe"} | Where-Object {$_.length/1MB -gt 5} |
Select-Object Name, Extension, @{Name="Mbytes";Expression={
"{0:N0}" -f ($_.Length / 1mb) }}
$results | Sort-Object -Property extension | Out-File
$destination
$results|group extension|select Count,Name,@{l='Total
MB';e={$_.Group | Measure-Object -Property Mbytes -Sum|select
-expand sum}}| Out-File $destination -Append