PowerShell script exchange
Post Reply
Sindhuja
Influencer
Posts: 21
Liked: never
Joined: Jan 22, 2018 11:01 pm
Full Name: Sindhuja Balasubramanian
Contact:

Retrieving Object Info from ObjectId (given in Task Session)

Post by Sindhuja »

Let's say, I have a Job with following object information (using Get-VBRJobObject)

Code: Select all

 "Info":  "Id: f12e5565-0dc9-4fa7-bb0b-50de6999684a, ObjectId: 1983, Path: esx05\\Engg\\Team\\VM74, DisplayName: AvamarVE74, GuestInfo: Veeam.Backup.Model.CGuestInfo, Name: VM74, ViType: VirtualMachine, HostId: 9529eaa-4bfc-4e12-a3f4-cfefee66c9b8, Platform: EVmware, Uuid: 421wd52e-56c2-e832-89bd-34c33239058a, TypeUncasted: 1, IsDirectory: False, IsFile: False, Type: VM, HierarchyType: VirtualMachine"
When I retrieve its task session details (using Get-VBRTaskSession), I get the following..

Code: Select all

"Info":  {
              ....
             "ObjectName":  "VM74",                    
             "ObjectId":  "f12e5565-0dc9-4fa7-bb0b-50de6999684a",
              ....
            }
Is there an API/command to get the object information like "ObjectId: 1983", "ViType:VirtualMachine" by passing "f12e5565-0dc9-4fa7-bb0b-50de6999684a"?

As I discover, the unique identifier ("f12e5565-0dc9-4fa7-bb0b-50de6999684a") is created per object, once it is added to a policy. This unique identifier does not change if I add the same object to another policy.
So, I hope there is a way to retrieve the object information by passing this unique identifier created by Veeam.

Thanks,
Regards,
Sindhuja
tdewin
Veeam Software
Posts: 1818
Liked: 655 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Retrieving Object Info from ObjectId (given in Task Sess

Post by tdewin »

Hi,

Don't have my test env now by check this find-vbrvientity:
https://helpcenter.veeam.com/docs/backu ... tml?ver=95

Pass the virtual machine type. I think the object returned have some kind of Id property (you can check by piping the result to "| get-member")
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Retrieving Object Info from ObjectId (given in Task Sess

Post by veremin »

What are you trying to achieve? Get VM object, using ObjectId from task session?
Sindhuja
Influencer
Posts: 21
Liked: never
Joined: Jan 22, 2018 11:01 pm
Full Name: Sindhuja Balasubramanian
Contact:

Re: Retrieving Object Info from ObjectId (given in Task Sess

Post by Sindhuja »

Thanks for your responses!
  • Find-VBRViEntity only takes the VM name as an input, and might not help in this case as the "ObjectId" in task session is different than the "id" available in Find-VBRViEntity.
  • Yes, I want to get the object information using the "ObjectId" provided in task session.
Something similar to GetObjects() API on CBackup

Regards,
Sindhuja
Sindhuja
Influencer
Posts: 21
Liked: never
Joined: Jan 22, 2018 11:01 pm
Full Name: Sindhuja Balasubramanian
Contact:

Re: Retrieving Object Info from ObjectId (given in Task Sess

Post by Sindhuja »

I found a way to get the object information associated with a Task Session.
Sample Code Snippet below.

Code: Select all

$session = Get-VBRBackupSession
$taskSession = Get-TaskSession -Session $session[0]

# To find the object information of ObjectId - say 406b792a-dd4e-408e-9a71-b27e3b87926c
# The parent session has a function - FindObject(objectId)

$session[0].FindObject([string]$taskSession[0].Info.ObjectId)
Sample output

Code: Select all

Info                  : Id: 406b792a-dd4e-408e-9a71-b27e3b87926c, ObjectId: 1268, Path: esx05\temp_1\SLab_4, DisplayName: SLab_4, GuestInfo: 
                        Veeam.Backup.Model.CGuestInfo, Name: SLab_4, ViType: VirtualMachine, HostId: 95291baa-4bfc-4e12-a3f4-cfefee66c945, Platform: EVmware, Uuid: 
                        42172fc1-9e04-0174-e3b9-cd87611815bc, TypeUncasted: 1, IsDirectory: False, IsFile: False, Type: VM, HierarchyType: VirtualMachine, Id: 
                        406b792a-dd4e-408e-9a71-b27e3b87926c
Id                    : 406b792a-dd4e-408e-9a71-b27e3b87926c
Name                  : SLab_4
ObjectId              : 1268
HostId                : 95291baa-4bfc-4e12-a3f4-cfefee66c945
GuestInfo             : Veeam.Backup.Model.CGuestInfo
Uuid                  : 42172fc1-9e04-0174-e3b9-cd87611815bc
ParentId              : 00000000-0000-0000-0000-000000000000
Type                  : VM
Platform              : EVmware
FaultToleranceType    : None
IsFileSystemDirectory : False
IsFile                : False
Host                  : Veeam.Backup.Core.Common.CHost
ViType                : VirtualMachine
ObjectRef             : 1268
Can someone confirm this approach?

Thank you,
Sindhuja
thjor
Service Provider
Posts: 11
Liked: 3 times
Joined: Apr 19, 2018 8:01 am
Contact:

Re: Retrieving Object Info from ObjectId (given in Task Session)

Post by thjor »

Hi Sindhuja

I did it a little different which seems to improve performance since you don't have to use Get-TaskSession.

Code: Select all

$Session = $job.FindLastSession().GetOriginalAndRetrySessions($true)[0]
$Tasks = $Session.GetTaskSessions()
if ($Tasks){
  foreach ($task in $Tasks)
  {
    $obj = $Session.FindObject([string]$task.Info.ObjectId)
  }
}
Regards
Thomas
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests