locked
get size of directories from a list where directories are in a SAN RRS feed

  • Question

  • Hello, I need to take out a monthly list with what occupies a series of folders, namely the weight of all folders that are within Projects:
    \\ cia \ DENS \ projects
    \\ cia \ DENS \ 21M1 \ Projects
    \\ cia \ DENS \ 22M2 \ Projects
    \\ cia \ CCIE \ Projects
    \\ cia \ CCIE \ 32MI \ Projects
    Within each of these folders there are others, but I am only interested in these.
    get-ChildItem $ directories -Directory | Select-Object -Property Fullname | convertto-csv -NoTypeInformation | Out-File $ file
    Get-Content $ file
    $ Directories = Get-Content $ file
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo: Not Specified: (:) [Get-ChildItem], ArgumentException
    + FullyQualifiedErrorId: System.ArgumentException, Microsoft.PowerShell.Commands.GetChildItemCommand
    If I throw it against a local directory it works fine


    Carlos.

    Friday, October 20, 2017 7:35 AM

All replies

  • There should be no space after the "$".

    get-ChildItem $directories -Directory |  Select Fullname | Export-Csv $file

    Try learning basic PowerShell and how to use help before guessing at a solution.

    Learn PowerShell: https://mva.microsoft.com/en-us/training-courses/getting-started-with-microsoft-powershell-8276


    \_(ツ)_/


    Friday, October 20, 2017 8:39 AM
  • Xa te podes quedar tranquiliño, isa resposta xa ma sei eu tamen.

    Grazas en todo caso!


    Carlos.

    Friday, October 20, 2017 9:00 AM
  • Un Galiciano? 

    \_(ツ)_/

    Friday, October 20, 2017 11:10 AM
  • Carlos,

    You can use:

    Get-ChildItem "\\cia\DENS\projects" | Measure-Object -property length -sum

    The result is in bytes. 

    For convert to MB use ($colItems.sum / 1MB);

    $Itemsfolder = (Get-ChildItem "\\cia\DENS\projects" -recurse | Measure-Object -property length -sum) "{0:N2}" -f ($Itemsfolder.sum / 1MB) + " MB"

    You can create a csv with folder and use a Foreach for read the csv folders.

    Check details: https://technet.microsoft.com/en-us/library/ff730945.aspx


    Se foi útil, classifique. Rafael Damásio Microsoft Consulting

    Friday, October 20, 2017 11:36 AM
  • Hi
    First of all thanks for the help, thank you very much Rafael.

    One more question, because the length property of measure-object does not work when channeling "get-children" over an unc path, for example \\ cia \ address \ project \ ... but it works without problems in local routes c: \ user \ administrator \ documents for example.
    The error that shows me is the following that follows:

    Measure-Object: The property "length" is not found in the entry of any object.

    Thanks once again


    Carlos.

    Monday, October 23, 2017 7:27 AM
  • There is no command "get-children"


    \_(ツ)_/

    Monday, October 23, 2017 7:49 AM
  • The correct command absolutely does work with a UNC:

    Get-ChildItem \\ws701\temp|Measure-Object length -sum


    \_(ツ)_/

    Monday, October 23, 2017 7:52 AM
  • When I try this comand  Powershell return  this lines

    PS C:\Users\Administrador.CIA> Get-ChildItem \\cia\data\DADM\032AD\Proyectos|Measure-Object length -sum
    Measure-Object : No se encuentra la propiedad "length" en la entrada de ningún objeto.
    En línea: 1 Carácter: 48
    + Get-ChildItem \\cia\data\DADM\032AD\Proyectos|Measure-Object length -sum
    +                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Measure-Object], PSArgumentException
        + FullyQualifiedErrorId : GenericMeasurePropertyNotFound,Microsoft.PowerShell.Commands.MeasureObjectCommand


    Carlos.

    Monday, October 23, 2017 8:44 AM
  • In Spanish "Length" is not a word.  Use the correct property name.  If this is a third party SAN with no Windows support then the length may be "Size".


    \_(ツ)_/

    Monday, October 23, 2017 9:19 AM