PowerShell script exchange
v.Eremin
Veeam Software
Posts: 15140
Liked: 1141 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Powershell to get list of VM's in a Veeam backup job

Post by v.Eremin » Apr 20, 2016 12:45 pm

Apologize. I hadn't been fast enough to update the code before you spotted. :)

The missing part was .Options. between $Job and .SanIntegrationOptions.

Thanks.

jimmymc
Service Provider
Posts: 30
Liked: 4 times
Joined: Dec 09, 2010 3:06 pm
Contact:

Re: Powershell to get list of VM's in a Veeam backup job

Post by jimmymc » Apr 20, 2016 1:09 pm 1 person likes this post

Ha - perfect, thanks and appreciated..

Cheers, James

jimmymc
Service Provider
Posts: 30
Liked: 4 times
Joined: Dec 09, 2010 3:06 pm
Contact:

Re: Powershell to get list of VM's in a Veeam backup job

Post by jimmymc » Apr 22, 2016 2:05 pm

Sorry, one more thing! As well as the options for each job (which is working great), I'm trying to get a count of VMs within each job tagged on the end (not 'objects' per-se, as it may well list a folder as an object). Could someone help out with adding this?

Thanks again in advance..

Cheers, James

v.Eremin
Veeam Software
Posts: 15140
Liked: 1141 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Powershell to get list of VM's in a Veeam backup job

Post by v.Eremin » Apr 25, 2016 9:45 am

So, what is selected as a job source - individual VMs or container, such as folder, resource pool and so on? Based on the source settings, the approach might vary. Thanks.

jimmymc
Service Provider
Posts: 30
Liked: 4 times
Joined: Dec 09, 2010 3:06 pm
Contact:

Re: Powershell to get list of VM's in a Veeam backup job

Post by jimmymc » Apr 25, 2016 10:08 am

Hi - All our jobs are based on folders thanks.. there are sub-folders of course..

Thanks for the help on this..

Cheers, James

vmniels
Veeam Software
Posts: 1999
Liked: 441 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Powershell to get list of VM's in a Veeam backup job

Post by vmniels » Apr 25, 2016 11:20 am 1 person likes this post

The following script counts the VM's within a folder in a job:

Code: Select all

asnp veeampssnapin

$jobs = Get-VBRJob -Name "BACKUPJOBWITHFOLDERS"

$vms = 0
$objects = $jobs.GetObjectsInJob()
$type = $objects.GetObject().Type

foreach ($object in $objects) {
    $type = $object.GetObject().Type
               
    if ($type -eq "VM") {
        $vms++
    } else {
        $jvm = Find-VBRViEntity -VMsAndTemplates -Server (Get-VBRServer) | Where { $_.VmFolderName -eq $object.Name }
    }
}

foreach ($vm in $jvm) {
    $vms++
}

Write-Output $vms
VCP-DCV
Veeam Certified Architect (VMCA)
http://foonet.be

albertwt
Expert
Posts: 626
Liked: 20 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

[MERGED] Using Powershell to get backup job AD account ?

Post by albertwt » Jun 16, 2016 4:59 am

Hi All,

I was looking for a way to get the list of the Backup job and its Service account / credentials that is in use with Veeam Powershell.
Is that possible ?

Because my predecessor was setting all of the backup job (~78 in total) with DOMAIN\Administrator which now has to be changed with the proper service account.
Any help on the Powershell script would be greatly appreciated.

Thanks.
--
/* Veeam software enthusiast user & supporter ! */

PTide
Veeam Software
Posts: 4306
Liked: 355 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Powershell to get list of VM's in a Veeam backup job

Post by PTide » Jun 16, 2016 2:36 pm

Hi,

Please check this post

Thanks

ldasilva
Novice
Posts: 5
Liked: never
Joined: Apr 25, 2017 5:43 pm
Full Name: Lisandro da Silva
Contact:

Re: Powershell to get list of VM's in a Veeam backup job

Post by ldasilva » Apr 26, 2017 4:22 pm

Hello,

Is there a way i can get a copy of the finished script?

Thank you

v.Eremin
Veeam Software
Posts: 15140
Liked: 1141 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Powershell to get list of VM's in a Veeam backup job

Post by v.Eremin » Apr 26, 2017 6:54 pm

Can you provide an answer to the question asked above - what is selected as backup job source? Container or individual VMs?

SeRo
Service Provider
Posts: 14
Liked: never
Joined: Mar 31, 2017 8:17 am
Contact:

Re: Powershell to get list of VM's in a Veeam backup job

Post by SeRo » Sep 10, 2018 8:59 am

Hello everyone,

I am working on a powershell script to export the following parameter:

- List all backup jobs
- List all VMs in each backup job
- List the size of each VM based on the size which is shown in the backup editing screen while adding a new virtual machine.

Can someone help me? All I get is a list with all backup jobs with the last "processed data". But thats not what I want.

lidaza
Lurker
Posts: 2
Liked: never
Joined: Feb 05, 2016 10:19 am
Full Name: Lidaza
Contact:

Re: Powershell to get list of VM's in a Veeam backup job

Post by lidaza » Oct 11, 2018 2:02 pm

SeRo wrote:
Sep 10, 2018 8:59 am
Hello everyone,

I am working on a powershell script to export the following parameter:

- List all backup jobs
- List all VMs in each backup job
- List the size of each VM based on the size which is shown in the backup editing screen while adding a new virtual machine.

Can someone help me? All I get is a list with all backup jobs with the last "processed data". But thats not what I want.
Try this:

Code: Select all

Get-VBRJob | ?{$_.JobType -eq "Backup"} | %{
	$JobName = $_.Name
	$_ | Get-VBRJobObject | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}} | Sort -Property Job, Name
}

Post Reply

Who is online

Users browsing this forum: Exabot [Bot] and 3 guests