VMware Cloud Community
sgboi82
Contributor
Contributor

script to export folders and files size in datastore

Anyone expert can help me.

0 Kudos
1 Reply
LucD
Leadership
Leadership

Something like this?

$dsName = 'MyDatastoreName'

$ds = Get-Datastore -Name $dsName
New-PSDrive -Name DS -Root \ -PSProvider VimDatastore -Datastore $ds | Out-Null

Get-ChildItem -Path DS:/ -recurse |
Select-Object Name,
  @{N='Type';E={$_.ItemType}},
  @{N='Path';E={$_.DatastoreFullPath}},
  @{N='SizeKB';E={[math]::Round($_.Length/1KB,1)}}

Remove-PSDrive -Name DS -Confirm:$false


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos