Automation

 View Only
  • 1.  How to find the size of the a file in a datastore

    Posted Apr 22, 2017 03:15 PM

    The aim is to find the size of the file file once the path and file name is found.

    I was abel to find the path [Datastore] fileName. What is the best way to find

    the size once the file name and path is known. Thank you for all the help...Cheers !!



  • 2.  RE: How to find the size of the a file in a datastore
    Best Answer

    Posted Apr 22, 2017 04:51 PM

    You can use the PowerCLI datastore provider to retrieve the size of a file on a datastore. The following PowerCLI code will retrieve the size (in bytes) of the file FreeNAS.vmx in folder FreeNAS on datastore vsanDatastore:

    $Datastore = Get-Datastore -Name vsanDatastore

    New-PSDrive -Location $Datastore -Name ds -PSProvider VimDatastore -Root "\"

    Set-Location ds:

    Get-ChildItem -Path FreeNAS\FreeNAS.vmx  | Select-Object -Property Name,Length