I am trying to get a list of all VMs registred in my backup jobs. Some of the jobs have an complete ESX host as the object to backup and some even a complete VC server as the object to backup. My code below gives me the name of the objects to backup in the jobs. Is there a way to tell what "Location" is (eg. vm, ESX server, VC-Server)? By knowing that location is eg. an ESX server I could than easily add all VMs on that server to my backup list.
Code: Select all
$jobs = Get-VBRJob
foreach ($job in $jobs) {
$objects = $job.GetObjectsInJob()
foreach ($object in $objects) {
write-host "jobname ["$job.Name"] location ["$object.Location"]"
}
}
With regards
Stefan