Thanks for the reply stumpr, I'm really struggling with the web services interface. I'm mainly a sysadmin, not a programmer and decided it was just too full on!!
So I'm trying the Perl SDK instead as it seems much simpler, although still struggling! All I'm trying to do is powercycle all the VMs in a particular folder. This is for a VDI deployment where the VMs are set to suspend when not in use, so they need to reboot automatically overnight so windows updates can take affect.
The Perl script I have now is:
use strict;
use warnings;
use VMware::VIRuntime;
# read/validate options and connect to the server
Opts::parse();
Opts::validate();
Util::connect();
my $folders =
Vim::find_entity_views(view_type => 'Folder',
filter => { 'name' => qr/Desktops - Test/ });
foreach (@$folders) {
print $_->name . "\n";
}
my $vm_views =
Vim::find_entity_views(view_type => 'VirtualMachine',
begin_entity => $folders
);
foreach (@$vm_views) {
print $_->name . ": " . $_->config->guestFullName . "\n";
}
# disconnect from the server
Util::disconnect();
which returns:
Desktops - Test Can't call method "serialize" on unblessed reference at C:/Program Files/VMware/ VMware vSphere CLI/Perl/lib/VMware/VICommon.pm line 2116, <STDIN> line 2. End Disconnect
What have I missed??