output - Powershell Search -


Here's what I'm trying to do:

  1. For files ending Find my computer to output a .doc, .docx, .xls, or .xlsx
  2. in a text file named "File_Summary.txt" in the file name and size (in the group by the file extension).
  3. I should also consider the total number of files and the total file size for each file extension listed in the output.

I can not even get it before the check part of the folder:

$ folder_to_heck = c: \ AIU $ report_file_location = "file_Summary.txt" $ Files = Get- childitem-path $ folder_To_Check-Include * Doctor, * docx, * xls, * Xlsx $ report_file_location $ totalfiles = ($ files | measure-object). Issue $ totalsize = ($ files | measurement object -Sam length) .Sum

Update I am changing the code again with some changes from my suggestions, but I am still I am also coming out empty. $ report_file_location = "file_Summary.txt" $ files = Get-Childitem C: \ AIU- "* Doctor", "* docx", "* xls", "* Xlsx "-Corporate | Sort-object | Get-unique -sstring $ files | Out-file $ Report_File_Location $ totalfiles = ($ Files | Volume-Object) Type $ $ Totalsize = ($ files | solution-object-total length). Type "Host: total totals: $ totalfiles" type-host "sum total: $ Totalsize"

Thinking about this I think I should not use the sort object , but should use the group extension - NewElement | Sort number is that will give me the total number of files of each type?

UPDATE Thank you for the help of people here I got my code to work but I had an issue where it was saying that my file was not present. Problem? I need to list the entire folder path and use single quotes.

This code works:

  $ folder_to_heck = 'c: \ user \ all \ document \ AIU $ $ Report_File_Location = "File_Summary.txt" $ result = Get -ChildItem $ Folder_To_Check -Include * .doc, * .docx, * .xls, * .xlsx -Recurse $ results | Group-Object Extension | [[PSCustomObject] @ {Results = $ _ for e-Objects Name calculation = $ _ Calculation size = [Math] :: round (($ _ group | solution-object -sam length; selection-object - expandProperty sum) / 1MB, 2)}} | Out-file $ Report_File_Location -Append  

Large support for Matt helps me to help organize my results so well. Thanks for helping me find out.

cache: \ AIU $ report_file_location = "file_Summary.txt "$ Result = get-childItem $ Folder_To_Check-include * .doc, * .docx, * .xls, * .xlsx -Recurse $ results | Group-Object Extension | For e-Object {{PSCTMobies} @ {extension = $ _. Name calculation = $ _ Calculation size = [Math]: round ((_ $ _ group | solution-object -sam length | selection-object-expand property sum) / 1MB, 2)}} | Get out of the file $ Report_File_Location -Append

Get as many files as you want Get-ChildItem You may want to use the -Recurse to get results from the sub-directory. Use the group-object to collect the file by extension. For each collection there is a custom object of expansion and file count, which come in both the group-object , and all the files in that particular extension are converted into MB and at 2 decimal places Goal

Updates to 2.0

If you only installed 2.0, then I would like to provide and answer that work for that .

  $ results | Group-Object Extension | E-object {$ properties = @ {extension = $ _. Name calculation = $ _ Calculation size = [Math]: round (($ _ group | remedy-object -sam length | object-select a property property) / 1MB, 2)} new object -TipName PSObject -Property $ properties}  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -