-
- Service Provider
- Posts: 40
- Liked: 5 times
- Joined: Apr 24, 2015 2:51 pm
- Full Name: Dries Vergote
- Contact:
Get all vms out of datastore
Hi
How can I add vms to "Guest Processing -> Credentials... -> Guest OS Credentials".
We are user datastore in jobobject but for guest OS credentials I need to add vms to set credentials to it.
The part of setting the credentials I have already if I add the server through the GUI.
Thanks.
How can I add vms to "Guest Processing -> Credentials... -> Guest OS Credentials".
We are user datastore in jobobject but for guest OS credentials I need to add vms to set credentials to it.
The part of setting the credentials I have already if I add the server through the GUI.
Thanks.
-
- Service Provider
- Posts: 40
- Liked: 5 times
- Joined: Apr 24, 2015 2:51 pm
- Full Name: Dries Vergote
- Contact:
[MERGED] Get all vms out of datastore
Hi
I would like to add all vm's in a datastore (added in job) to the guest OS credentials.
This is needed to specify the specific credentials of a vm. That part I already have with Set-VBRJobObjectVssOptions
Any idea how to accomplish this?
In the gui you can select the 'datastore and vms' and see only the vm's in that datastore.
thanks
I would like to add all vm's in a datastore (added in job) to the guest OS credentials.
This is needed to specify the specific credentials of a vm. That part I already have with Set-VBRJobObjectVssOptions
Any idea how to accomplish this?
In the gui you can select the 'datastore and vms' and see only the vm's in that datastore.
thanks
-
- Veeam Software
- Posts: 1818
- Liked: 655 times
- Joined: Mar 02, 2012 1:40 pm
- Full Name: Timothy Dewin
- Contact:
Re: Get all vms out of datastore
You can try this code
(e.g "demo-fc" would be your datastore)
Code: Select all
$vmsandds = Find-VBRViEntity -DatastoresAndVMs
$ds = $vmsandds | ? { $_.name -eq "demo-fc" }
$vmsandds | ? { $_.Path.startswith($ds.path) -and $_.type -eq "Vm" }
-
- VP, Product Management
- Posts: 6035
- Liked: 2860 times
- Joined: Jun 05, 2009 12:57 pm
- Full Name: Tom Sightler
- Contact:
Re: Get all vms out of datastore
If the job has a container object you'll have to manually enumerate and add the VM objects to the job to set the passwords for each. I usually use something like:
Then you can find VMs that belong to a datastore with:
Admittedly, this code does assume you will have only one Datastore with than name across the entire environment, if you have multiple vCenters with the possibility of duplicate datastore names you'd want to make sure to use the full path, this was more as a conceptual example, and approaches it pretty much the same way Timothy's code does.
Of course, you then still need to add those objects to the job and switch the object type of vssChild and then set the credentials. I've used code something like this in the past:
Code: Select all
# Get VMs by datastore and vms view
$vmsbydatastorepath = Find-VBRViEntity -DatastoresAndVMs | ?{$_.Type -eq "Vm"}
Code: Select all
($vmsbydatastorepath | ?{$_.Path -like "*<datastore_name>*"})
Of course, you then still need to add those objects to the job and switch the object type of vssChild and then set the credentials. I've used code something like this in the past:
Code: Select all
write-host "Setting VSS Credentials for" $vm.Name
Add-VBRViJobObject -Job $job -Entities $vm | Out-Null
$newoij = Get-VBRJobObject -Job $Job -Name $vm.Name
$newoij.Info.Type = [Veeam.Backup.Model.CDbObjectInJobInfo+EType]::VssChild
Set-VBRJobObjectVssOptions -Object $newoij -Credentials $cred | Out-Null
-
- Service Provider
- Posts: 40
- Liked: 5 times
- Joined: Apr 24, 2015 2:51 pm
- Full Name: Dries Vergote
- Contact:
Re: Get all vms out of datastore
Thanks for the replies.
Indeed this works fine, I'll post update with full script when done.
For adding credentials per vm I got from Timotht to use another enum instead. Else you add it to the application only.
Indeed this works fine, I'll post update with full script when done.
For adding credentials per vm I got from Timotht to use another enum instead. Else you add it to the application only.
Code: Select all
[Veeam.Backup.Model.CDbObjectInJobInfo+EType]::GuestCredsChild
Who is online
Users browsing this forum: No registered users and 8 guests