# Script Dumpster: Reporting all files on ESX Datastores # The Problem I had a customer who was complaining that the simple overview of disks used by VM's didn't add up to the amount of data in use on datastores. Simple reasoning being swap files, snapshots etc. etc. , but the customer wanted to see exactly what was causing thisโ€ฆ In comes PowerCLI [VMWare's adaption of PowerShell for their solutions] # The Script Edit: As I had thought at first instance, the datacenter name was working just fine on my 2 test environments, but in a 3rd I quickly ran into an error. I've now adapted the script to automatically check all available DataCenters and underlying DataStores ๐Ÿ™‚ ```powershell $ESXServer = 'ServerName' $ESX_Cred = Get-Credential Connect-VIServer $ESXServer -Credential $ESX_Cred Set-Location vmstore: $Datacenters = Get-ChildItem $AllFiles = @() foreach ($Datacenter in $Datacenters){ $DataStores = Get-ChildItem foreach ($DataStore in $DataStores) { $Files = Get-ChildItem -Path $DataStore -Recurse | Where-Object { -not $_.PsIsContainer} $AllFiles += $Files } } $AllFiles | Select-Object DataStoreFullPath,Name,ItemType,@{L='LengthMB';E={ "{0:N2}" -f ($_.Length / 1MB)}},LastWriteTime ``` If required you can simply export the outcome using ```powershell Export-CSV ``` Happy Scripting! ๐Ÿ™‚