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"
#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"
}
}
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!
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 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.
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
I need something similar for a customer that needs an email sent every morning for all of their Tier 1 apps (around 40 servers in total).
Customer has critical servers tagged as "critical" in vsphere.
They want an email sent to the backup admins every morning listing all critical servers with the VM Tag "critical" and their backup status of the previous day. I want to only include the critical VM's with the tag "Critical". They are spread over many different backup jobs, hosts and clusters.