Suppose you want to run the antivirus software presented in Scan VMDK for Virus Signatures for all virtual machines hosted on an ESXi host. Here is the high-level algorithm for a VMware vSphere solution that can scan managed disk on all virtual machines.

To virus scan managed virtual disk:

Procedure

  1. Using the VMware vSphere Perl Toolkit, write a Perl script that connects to a given ESXi host.
  2. Call Vim::find_entity_views() to find the inventory of every VirtualMachine.
  3. Call Vim::get_inventory_path() to get the virtual disk name in its appropriate resource.

    The VMDK filename is available as diskPath in the GuestDiskInfo data object.

  4. Using Perl’s system(@cmd) call, run the extended vixDiskLibSample.exe program with -virus option.

    For ESXi hosts you must specify -host, -user, and -password options.

  5. Decontaminate any infected sectors that the virus scanner located.