VMware Cloud Community
mtfromVA
Contributor
Contributor
Jump to solution

How to find the size of the a file in a datastore

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 !!

1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

1 Reply
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition