-
- Novice
- Posts: 8
- Liked: never
- Joined: Mar 29, 2019 1:59 pm
- Full Name: Haroon Hanif
- Contact:
adding a tag to each VM in the Backup/Replica Job using powershell
Hi,
I am assigned a job to assign tags to all the VMs backed up or replicated by Veeam and I need help in that please, I see there is an option of using script which you can run pre or post backup and I think that could be the option which is useful for assigning the tag to the VM or replacing the existing tag from "No Backup" to "Backup" after the backup is taken.
Tag name: Backup, category: Veeam.
Tag name: No Backup, category: Veeam.
We don't have tags on our existing VMs so rather than going through each VM and assigning the tag manually, I thought it would be easier to add tag using Veeam and will be able to report all the VMs not backed up by Veeam
if somebody has created a powershell script for something similar, could they please share it,
I really appreciate your time and effort on this.
Kind Regards,
I am assigned a job to assign tags to all the VMs backed up or replicated by Veeam and I need help in that please, I see there is an option of using script which you can run pre or post backup and I think that could be the option which is useful for assigning the tag to the VM or replacing the existing tag from "No Backup" to "Backup" after the backup is taken.
Tag name: Backup, category: Veeam.
Tag name: No Backup, category: Veeam.
We don't have tags on our existing VMs so rather than going through each VM and assigning the tag manually, I thought it would be easier to add tag using Veeam and will be able to report all the VMs not backed up by Veeam
if somebody has created a powershell script for something similar, could they please share it,
I really appreciate your time and effort on this.
Kind Regards,
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: adding a tag to each VM in the Backup/Replica Job using powershell
Doesn't adding backup details to VM attribute solve your problem? Thanks!
-
- Novice
- Posts: 8
- Liked: never
- Joined: Mar 29, 2019 1:59 pm
- Full Name: Haroon Hanif
- Contact:
Re: adding a tag to each VM in the Backup/Replica Job using powershell
Thanks for replying,
What we plan to do is to use ansible to create and tag the new Virtual machines on the basis of whether it needs a backup or not. And As we already have jobs created for the replication and backups in veeam , by running the post backup/replication script we will be able to tag the VMs already in the back up and then can filter any VMs which should be backed up but are not in veeam jobs based on their tags.
Further down the line we are thinking of adding the new VMs dynamically into the veeam jobs.
Thats why I was looking for the script.
Could you please advise if you think adding the attribute will be better.
I hope this makes sense.
What we plan to do is to use ansible to create and tag the new Virtual machines on the basis of whether it needs a backup or not. And As we already have jobs created for the replication and backups in veeam , by running the post backup/replication script we will be able to tag the VMs already in the back up and then can filter any VMs which should be backed up but are not in veeam jobs based on their tags.
Further down the line we are thinking of adding the new VMs dynamically into the veeam jobs.
Thats why I was looking for the script.
Could you please advise if you think adding the attribute will be better.
I hope this makes sense.
-
- Novice
- Posts: 8
- Liked: never
- Joined: Mar 29, 2019 1:59 pm
- Full Name: Haroon Hanif
- Contact:
Re: adding a tag to each VM in the Backup/Replica Job using powershell
I have tried the following script which pulls the objects in the job, displays $Objects.name (VMs) properly on the screen but when I try to put $Objects.name in the CSV format, it gives me the length of the string rather than the VM names, script is as follows.
# Load Snap-ins
# Add Veeam snap-in if required
If ((Get-PSSnapin -Name VeeamPSSnapin -ErrorAction SilentlyContinue) -eq $null) {add-pssnapin VeeamPSSnapin}
Connect-VBRServer
$JobnName = "Replication Veeam_utility_test"
$JobObject = Get-VBRJob -name $JobnName
$Objects = $JobObject.GetObjectsInJob()
$Objects.name
$Objects.name | export-csv -Path c:\$JobnName.csv
if there is a way, I could retrieve them individually and then use them in a loop to apply the tag on them will be great and any help in that will be greatly appreciated
# Load Snap-ins
# Add Veeam snap-in if required
If ((Get-PSSnapin -Name VeeamPSSnapin -ErrorAction SilentlyContinue) -eq $null) {add-pssnapin VeeamPSSnapin}
Connect-VBRServer
$JobnName = "Replication Veeam_utility_test"
$JobObject = Get-VBRJob -name $JobnName
$Objects = $JobObject.GetObjectsInJob()
$Objects.name
$Objects.name | export-csv -Path c:\$JobnName.csv
if there is a way, I could retrieve them individually and then use them in a loop to apply the tag on them will be great and any help in that will be greatly appreciated
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: adding a tag to each VM in the Backup/Replica Job using powershell
Take a look at this report. It has section about VMs backed up within last X hours.
Take this logic and combine it with PowerCLI tag assignment cmdlet.
Thanks.
Take this logic and combine it with PowerCLI tag assignment cmdlet.
Thanks.
-
- Novice
- Posts: 8
- Liked: never
- Joined: Mar 29, 2019 1:59 pm
- Full Name: Haroon Hanif
- Contact:
Re: adding a tag to each VM in the Backup/Replica Job using powershell
Hi v.eremin,
Thanks for the Link, really appreciate your help.
Thanks for the Link, really appreciate your help.
-
- Product Manager
- Posts: 20400
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: adding a tag to each VM in the Backup/Replica Job using powershell
If I remember correctly, the script provides you with the list of VMs that have been backed up during the specified time interval, which means you will need to change the logic slightly, so that instead of VMs that have not been backed up you get VMs that have.
Then, you will need to convert this list from Veeam PS objects to VMware PowerCLI ones.
After that, assign tag to PowerCLI VM objects, using the referenced cmdlet.
Thanks!
Then, you will need to convert this list from Veeam PS objects to VMware PowerCLI ones.
After that, assign tag to PowerCLI VM objects, using the referenced cmdlet.
Thanks!
Who is online
Users browsing this forum: No registered users and 18 guests