PowerShell script exchange
Post Reply
ofekih
Novice
Posts: 4
Liked: never
Joined: Apr 03, 2023 4:50 pm
Full Name: Oussama Fekih
Contact:

How to Find VMs in Job Tags

Post by ofekih »

Hi Everyone,
i have backup jobs with Tags, and i want to get the list of VMs included on this backup job
i use this command:

Code: Select all

 Find-VBRViEntity -Tags | Where-Object { $PSItem.Type -eq 'VM' }
but the return is all VMs with Tags
In the Doc for Find-VBRViEntity Example 4 does not return the list of VMs with the specific TAG "Daily"

Code: Select all

Find-VBRViEntity -Server $vCenterserver -Tags -Name "Daily"
i know that i can use PowerCLI but i want to check if there's Veeam commands?
Thank You
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: How to Find VMs in Job Tags

Post by david.domask »

Hi @ofekih,

To get it right, you're wanting to just get the VMs with a specific tag? IIRC we previously had made the Find-VBRViEntity -Tag parameter only return the tag itself, but that was reverted and it now returns the VMs with Tags.

If you pass the -Name parameter, doesn't it give you all VMs with such a tag?
David Domask | Product Management: Principal Analyst
ofekih
Novice
Posts: 4
Liked: never
Joined: Apr 03, 2023 4:50 pm
Full Name: Oussama Fekih
Contact:

Re: How to Find VMs in Job Tags

Post by ofekih »

Hi David,

if i pass the -Name parameter it give me only the Tag object (no VM):

Code: Select all

PS C:\Users\Administrator> Find-VBRViEntity -Tags -Name Daily
Type        : Tag
Name        : Daily
Description : Daily Backup Tag
Thanks
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: How to Find VMs in Job Tags

Post by david.domask »

@ofekih, what version are you on for Veeam? Go to Menu > Help > About from the VBR console and if you could show the version screenshot, it'd be great. You might be on a version that had the functionality removed.
David Domask | Product Management: Principal Analyst
ofekih
Novice
Posts: 4
Liked: never
Joined: Apr 03, 2023 4:50 pm
Full Name: Oussama Fekih
Contact:

Re: How to Find VMs in Job Tags

Post by ofekih »

Hi,
Veeam Build:11.0.1.1261 P20230227
with Fix_291940_d8b84c8c91 (Case 05978924)
Thanks
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: How to Find VMs in Job Tags

Post by david.domask »

Heya @ofekih,

Interesting, thank you for confirming. Not sure right now how the -Name parameter interacts but based on the description, it looks like it parses the Name property of the objects and checks for that, which for the VMs won't work.

The VMs seem to be returned based on the Path property, which will have the tag name, so you can do something like:

Code: Select all

PS C:\Users\Administrator> Find-VBRViEntity -Tags | Where-Object {$_.Type -eq "Vm" -And $_.Path -like "*azya-tag*"}

ConnHostId             : 330cefde-a6db-4109-abec-0dcc5c8515a9
Type                   : Vm
Reference              : vm-37092
Id                     : 330cefde-a6db-4109-abec-0dcc5c8515a9_vm-37092
Name                   : some_vm
Path                   : somevc.local\azya-tag\some_vm
VmHostName             : somevc.local
VmFolderName           : vm
IsLegacyFaultTolerance : False
FaultToleranceType     : None
GuestInfo              : Veeam.Backup.Model.CGuestInfo
Uuid                   : 423b645f-99a9-f999-9737-85dfd7b7bfcc
PowerState             : PoweredOff
IsTemplate             : False
ProvisionedSize        : 2380165863
UsedSize               : 3747340
Platform               : EVmware
RawReference           : vm-37092

ConnHostId             : 330cefde-a6db-4109-abec-0dcc5c8515a9
Type                   : Vm
Reference              : vm-32460
Id                     : 330cefde-a6db-4109-abec-0dcc5c8515a9_vm-32460
Name                   : some_replica
Path                   : somevc.local\azya-tag2\some_replica
VmHostName             : somevc.local
VmFolderName           : vm
IsLegacyFaultTolerance : False
FaultToleranceType     : None
GuestInfo              : Veeam.Backup.Model.CGuestInfo
Uuid                   : 423b0fd3-1ac3-09b2-ac6d-65d44f45bf34
PowerState             : PoweredOff
IsTemplate             : False
ProvisionedSize        : 10973282474
UsedSize               : 577706
Platform               : EVmware
RawReference           : vm-32460
David Domask | Product Management: Principal Analyst
ofekih
Novice
Posts: 4
Liked: never
Joined: Apr 03, 2023 4:50 pm
Full Name: Oussama Fekih
Contact:

Re: How to Find VMs in Job Tags

Post by ofekih »

Hi David,

Thanks for your help, now the result is as expected

below my code for multiple Jobs:

Code: Select all

$TagVMs = @()
foreach($Tag in $UniqueJobTags){
$TagName=$tag.Name
$VCTagVMs = Find-VBRViEntity -Tags | Where-Object { $PSItem.Type -eq 'VM' -and $PSItem.Path -like "*\$TagName*" }
$TagVMs = $TagVMs + $VCTagVMs
}

$UniqueTagVMs = $TagVMs |Select-Object Name, Reference, Uuid, vCenter -Unique
Have a Good Day
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests