Powershell Backup Report and VMWare Tags

PowerShell script exchange

Powershell Backup Report and VMWare Tags

Veeam Logoby cromero » Tue May 10, 2016 2:07 pm

Hi!

I need an script that checks that specified machines have backup (Domain Controllers)

I'm working in the attached script but the problem is that in VMWare we are using tags and the script is can't check the tags so is returning these machines as "not backed up"

Do you know how can I work with this issue?

Thanks!

Code: Select all
#Get all machines in all Jobs

$JobObjects = Get-VBRJob -name * | Get-VBRJobObject | select name

$hash = @{};

#Clean hash table

$hash.clear()

foreach ($jobObject in $JobObjects){

$hash.add($jobObject.name, "Unprotected")

}


#$Machines = $JobObject.name




# Find all backup job sessions that have ended in the last 24 hours

$vbrsessions = Get-VBRBackupSession | Where-Object {$_.JobType -eq "Backup" -and $_.EndTime -ge (Get-Date).addhours(-24)}

# Find all successfully backed up VMs in selected sessions (i.e. VMs not ending in failure) and update status to "Protected"

foreach ($session in $vbrsessions) {
    foreach ($JobObject in ($session.GetTaskSessions() | Where-Object {$_.Status -ne "Failed"} | ForEach-Object { $_ })) {
        if($hash.containskey($Jobobject.Name)) {
            $hash[$JobObject.Name]="Protected"
        }
    }
}

# Output Machines in color coded format based on status.
foreach ($caca in $hash.Keys)
{
  if ($hash[$caca] -eq "Protected") {
      write-host -foregroundcolor green "$caca is backed up"
  } else {
      write-host -foregroundcolor red "$caca is NOT backed up"
  }
}
cromero
Novice
 
Posts: 9
Liked: never
Joined: Wed May 04, 2016 6:39 pm
Full Name: Carlos Romero

Re: Powershell Backup Report and VMWare Tags

Veeam Logoby Shestakov » Wed May 11, 2016 4:06 pm

Hi Carlos and welcome to the forums!
While waiting for others to assist with a script, I would suggest to leverage Veeam ONE capabilities to reach the goal.
You may use Protected VMs report to check which VMs don`t have backups. You can also run for particular groups creating them in Business View.
Thanks!
Shestakov
Veeam Software
 
Posts: 4942
Liked: 407 times
Joined: Wed May 21, 2014 11:03 am
Location: Saint Petersburg
Full Name: Nikita Shestakov

Re: Powershell Backup Report and VMWare Tags

Veeam Logoby EugeneK » Wed May 11, 2016 5:15 pm 1 person likes this post

In addition to Protected VMs report, I absolutely also love to use the VM Backup Status one:
https://helpcenter.veeam.com/one/report ... tatus.html
Eugene K
Product Architect @ SingleHop - Veeam Platinum Service Provider
http://www.singlehop.com
VCAP-DCD, VCAP-DCA, VCP-NV
Veeam Certified Architect
EugeneK
Veeam Vanguard
 
Posts: 102
Liked: 23 times
Joined: Sat Mar 19, 2016 10:57 pm
Location: Chicago, IL
Full Name: Eugene Kashperovetskyi

Re: Powershell Backup Report and VMWare Tags

Veeam Logoby v.Eremin » Tue May 17, 2016 3:05 pm

I think you will have to create two lists and try to compare them. First list should contain list of VMs that have a corresponding tag assigned to them, second - list of VMs backed up recently. Thanks.
v.Eremin
Veeam Software
 
Posts: 13419
Liked: 987 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Powershell Backup Report and VMWare Tags

Veeam Logoby cromero » Tue May 31, 2016 1:27 pm

v.Eremin wrote:I think you will have to create two lists and try to compare them. First list should contain list of VMs that have a corresponding tag assigned to them, second - list of VMs backed up recently. Thanks.


Hi guys,

Thanks for your answers! v.Eremin, do you know the command to extract the VM machines from Veeam? I can manage to extract the machines with specific Tag from VMWare but I can't extract vm machines from vm machines lists in veeam.

I know we have Get-VBRJob -name * | Get-VBRJobObject | select name to extract machines inside jobs, but here I get the tags.

Thanks!
cromero
Novice
 
Posts: 9
Liked: never
Joined: Wed May 04, 2016 6:39 pm
Full Name: Carlos Romero

Re: Powershell Backup Report and VMWare Tags

Veeam Logoby dellock6 » Tue May 31, 2016 7:06 pm

Maybe this script can be a good starting point for your need?
http://www.virtualtothecore.com/en/back ... 6-edition/
(thanks to Tom Sightler for the script itself, I just posted it in my blog)
Luca Dell'Oca
EMEA Cloud Architect @ Veeam Software

@dellock6
http://www.virtualtothecore.com
vExpert 2011-2012-2013-2014-2015-2016
Veeam VMCE #1
dellock6
Veeam Software
 
Posts: 5061
Liked: 1342 times
Joined: Sun Jul 26, 2009 3:39 pm
Location: Varese, Italy
Full Name: Luca Dell'Oca

Re: Powershell Backup Report and VMWare Tags

Veeam Logoby v.Eremin » Thu Jun 02, 2016 12:42 pm

I can manage to extract the machines with specific Tag from VMWare but I can't extract vm machines from vm machines lists in veeam.

VMs having specific tag can be returned via similar script:

Code: Select all
Find-VBRViEntity -Server $server -Tags -Name "Name of your tag"


The second list I was talking about would be created based on the task sessions (you have this portion already in your original script).

Thanks.
v.Eremin
Veeam Software
 
Posts: 13419
Liked: 987 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Powershell Backup Report and VMWare Tags

Veeam Logoby cromero » Mon Jun 27, 2016 7:20 pm

Thanks v.Eremin,

Tried this but it's not returning me the machines with the specific tag "test". I only got this:

Code: Select all
ConnHost  : Veeam.Backup.Core.Common.CHost
Type      : Tag
Reference : urn:vmomi:InventoryServiceTag:8xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TagQsId   : urn:vmomi:InventoryServiceTag:8xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Id        : dxxxxxxxxxxxxxxxxxxxxx
Name      : test
Path      : servername\General\test
cromero
Novice
 
Posts: 9
Liked: never
Joined: Wed May 04, 2016 6:39 pm
Full Name: Carlos Romero

Re: Powershell Backup Report and VMWare Tags

Veeam Logoby v.Eremin » Fri Jul 01, 2016 2:33 pm

The provided example has to be modified a bit in order to meet your goal. Check the script below:

Code: Select all
$TagPath = (Find-VBRViEntity -Tags -name "Name of your Tag").Path
Find-VBRViEntity -Tags | where {$_.Type -eq "VM" -and $_.path -like "$TagPath*"} | select name


Thanks.
v.Eremin
Veeam Software
 
Posts: 13419
Liked: 987 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Powershell Backup Report and VMWare Tags

Veeam Logoby cromero » Mon Jul 04, 2016 7:46 pm

Thanks!!!
cromero
Novice
 
Posts: 9
Liked: never
Joined: Wed May 04, 2016 6:39 pm
Full Name: Carlos Romero

Re: Powershell Backup Report and VMWare Tags

Veeam Logoby v.Eremin » Tue Jul 05, 2016 8:41 am

You're welcome. If any other question arises, let us know. Thanks.
v.Eremin
Veeam Software
 
Posts: 13419
Liked: 987 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

[MERGED] Get list of vms when backup contains tag

Veeam Logoby mhaaksma » Wed Aug 09, 2017 9:01 pm

How can I get the list of vms when the backup job contains tags?

PS C:\Users\xxxxx> (Get-VBRJob -Name "Ztest_Backup_Job_Post_Script" | Sort -Property Name).GetObjectsInJob() | ?{$_.Type -eq "Include"}

Name Type ApproxSize Location
---- ---- ---------- --------
1 - 15 to 30 minutes Include 50.0 GB xxxx-vc2\Criticality\1...

I would like only the VMs associated with that backup job.

Any help will greatly be appreciated.
Thank you,
Monica
mhaaksma
Novice
 
Posts: 3
Liked: never
Joined: Thu Jun 29, 2017 2:39 pm
Full Name: Monica

Re: Get list of vms when backup contains tag

Veeam Logoby tdewin » Thu Aug 10, 2017 7:19 am

You can use find-vbrvientity together with the tag location:
powershell-f26/powershell-backup-report-and-vmware-tags-t35176.html#p200081
tdewin
Veeam Software
 
Posts: 1075
Liked: 370 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests