VMware {code} Community
13erla
Enthusiast
Enthusiast

pull vmdk locations and sizes

any scripts out there that will pull the following information from VI3 VC?

VM Name

VMDK Size (on disk)

VMDK location (lun)

i realize that veeam gives you vmdk size and disk used but not vmdk location.

Reply
0 Kudos
2 Replies
admin
Immortal
Immortal

You can make use SearchDatastoreSubFolders API, that returns FileInfo Data object. FileInfo object has properties fileSize and path from where you can get size and location.

Reply
0 Kudos
meistermn
Expert
Expert

*

Found this on the web . Maybe it is helpful for start

  1. 1. Browse the datastore

foreach my$ds( @{ $datacenter->datastore } ) {

**

my$datastore= Vim::get_view( mo_ref => $ds);

**

my$browser= Vim::get_view( mo_ref =>$datastore->browser );

**

my$task=

*

$browser->SearchDatastoreSubFolders(

datastorePath=> sprintf( "[%s]", $datastore->info->name) ,

searchSpec=> HostDatastoreBrowserSearchSpec->new( matchPattern=>[http://".vmx"|http://".vmx"] )

)

;

}

*

  1. 2. Build the list of VMs

my@vm_list

**

my$task_view= Vim::get_view( mo_ref =>$task);

**

foreachmy$result( @{ $task_view->info->result } ) {

**

if( defined$result->file ) {

**

foreachmy$file( @{ $result->file } ) {

**

push@vm_list, sprintf"%s%s", $result-> folderPath, $file->path;

*

}

}

}

*

*

Reply
0 Kudos