Browse VMware Datastores w/PowerCLi


Are you sure do you know what happens on your Datastores? Where your ISO images are stored? How many orphaned virtual disks do you have? What is their size and how old are they? What more ever consumes your expensive storage space?

The Search-Datastore function from my PowerCLi Vi-Module module will answer all these and many another questions.

UPDATE (01-Mar-2018)

  • Multiple file types are supported by -FileType parameter.

  • Added -Orphaned parameter.


  • The function accepts Datastore(s) by name or as objects, returned by Get-Datastore cmdlet at the pipeline.

Get-Datastore | Search-Datastore
Search-Datastore –Datastore datastore1


  • If you pass a large bulk of Datastores to the function, I suggest using –Verbose parameter to watch for Datastores processing progress.
Get-Datastore | Search-Datastore -Verbose


-FileType parameter

  • By default, the function searches for these two file types: VMDK and ISO.

You can change the default behavior of the function and return ISO files only by using –FileType parameter.

Get-Help Search-Datastore –Parameter FileType
Get-Datastore | Search-Datastore -FileType IsoOnly


  • I suggest you always to save the output to a variable and after that manipulate with that variable (filter/query/sort/export/format).
$report = Get-Datastore | Search-Datastore
$report | sort SizeGB |ft Folder, File, SizeGB –au
$report | ? {$_.SizeGB –gt 3}
$report |epcsv –notype –Encoding utf8 .\Datastore.csv


  • The –FileType parameter supports four values: Vmdk&Iso, VmdkOnly, IsoOnly and All.


SizeBar property

  • One of the interesting properties, returned by Search-Datastore is SizeBar. This property represents relative file size compared to its parent Datastore size.


  • The SizeBar property is being generated by New-PercentageBar function, included in the module.

-FileName parameter

  • The –FileName parameter accepts file name pattern. If your pattern does not include no one asterisk symbol (*), the function will add one leading and one trailing asterisk to your pattern.
Get-Datastore | Search-Datastore -FileType IsoOnly –FileName 2008
  • The pattern will be *2008*.


FileType property

  • The one more interesting property, returned by Search-Datastore is FileType. This property represents well known VM and ESXi host file types.


  • In the screenshot above we can see three Virtual Disks (*.vmdk files) that reside on the same Datastore and consume 80% of its size (6+30+44).
  • That is not all about FileType property. For the Virtual Disk and Snapshot Disk file types, the function is able to determine if these files are used by any VM!
  • If no, the function will add Orphaned to the FileType name.


  • Note! For correct orphaned disks determining you must connect to all VCenters or ESXi hosts that have access to the Datastores where you are searching for the files.
  • For more details about the function, please take a look at the content based help and examples.
Get-Help Search-Datastore -Full
Get-Help Search-Datastore -Examples
Get-Help Search-Datastore -Parameter FileName

You may also like:

Move-Template2Datastore – Migrate VMware VM Templates to another Datastore

6 thoughts on “Browse VMware Datastores w/PowerCLi

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s