Query Source VM for FileCopy

PowerShell script exchange

Query Source VM for FileCopy

Veeam Logoby Talom » Tue Oct 21, 2014 8:08 am

I'm working on a script to query all BackupSessions of the last 24 hours. The result is written to XML.
I get the SourcePath and TargetPath of a FileCopy without any Problems, but i need the Source VM too.
Does anyone know where i can get this information?
I took a look at the Job-Object already, but i couldn't find anything.
Talom
Influencer
 
Posts: 13
Liked: 1 time
Joined: Tue Oct 21, 2014 7:56 am

Re: Query Source VM for FileCopy

Veeam Logoby v.Eremin » Tue Oct 21, 2014 8:22 am

Talom wrote:I get the SourcePath and TargetPath of a FileCopy without any Problems, but i need the Source VM too.

Can you elaborate on the selected portion? Are you talking here about file copy job and "source" server the corresponding files are copied from? Thanks.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 974 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Query Source VM for FileCopy

Veeam Logoby Talom » Tue Oct 21, 2014 8:51 am

I call
Code: Select all
Get-VBRBackupSession | Where-Object { $_.EndTime -ge $date}


For every session i get the TaskSessions and there i can get the ObjectName for every TaskSession. But where can i find the Source Hostname where the files are copied from?

The Target Host would be nice to have, too, but is not necessary.
Talom
Influencer
 
Posts: 13
Liked: 1 time
Joined: Tue Oct 21, 2014 7:56 am

Re: Query Source VM for FileCopy

Veeam Logoby v.Eremin » Tue Oct 21, 2014 9:21 am

Let me rephrase my question - what is the type of the job? File copy one? And you want to get information about its source and target, right? Thanks.
v.Eremin
Veeam Software
 
Posts: 13296
Liked: 974 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Query Source VM for FileCopy

Veeam Logoby Talom » Tue Oct 21, 2014 9:24 am

Thats exactly what i want.
It is a File Copy

Sorry for misunderstanding ;)
Talom
Influencer
 
Posts: 13
Liked: 1 time
Joined: Tue Oct 21, 2014 7:56 am

Re: Query Source VM for FileCopy

Veeam Logoby v.Eremin » Tue Oct 21, 2014 11:12 am

Can you try the following example and see whether it meets your expectations?

Code: Select all
$FileCopyJob = Get-VBRJob -name "Name of your File Copy Job"
$FileCopyJob.GetObjectsInJob().object.name

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

Re: Query Source VM for FileCopy

Veeam Logoby Talom » Tue Oct 21, 2014 1:19 pm

Thanks for this, but its not really what i wanted.
Code: Select all
$FileCopyJob = Get-VBRJob -name "File Copy Job 1"
    $jobObjects = $FileCopyJob.GetObjectsInJob()
    foreach($obj in $jobObjects)
    {

        write-host "OBJECT: "  $obj.Name
    }

Output:
Code: Select all
OBJECT:   C:\Users\Administrator\job-definitions.xml
OBJECT:   <datacenterRef>datacenter-21</datacenterRef><datacenterName>srzc-test</datacenterName><datacenterPath>srzc-test</datacenterPath><hostRef>host-83</hostRef><datastoreRef>datastore-84</datastor
eRef><datastoreGuid>52de3a7e-49e03574-dce2-6805ca1f766d</datastoreGuid><FullName>[datastore-vm8-1] rzc-dt-w8k-ts90/vmware.log</FullName>


The first object is a local FileCopy, now i got the Source Path. I already have this info. What i expect is: "This Server" or "Name of the VeeamServer"
The second one is a log-File from my ESX Host. I expected the name of the ESX host "rzc-dt-esx"

I guess it can be in the VBRTaskSession Object. But IntelliSense is buggy so i don't get a list of members
Talom
Influencer
 
Posts: 13
Liked: 1 time
Joined: Tue Oct 21, 2014 7:56 am

Re: Query Source VM for FileCopy

Veeam Logoby nefes » Tue Oct 21, 2014 1:30 pm

In that case you can use
Code: Select all
$FileCopyJob.GetObjectsInJob().object.GetHost().Name

In general, it is always useful to use Get-Member command to find available methods and properties.
For example in your case it will be
Code: Select all
$FileCopyJob.GetObjectsInJob().object | gm
nefes
Veeam Software
 
Posts: 534
Liked: 125 times
Joined: Mon Dec 10, 2012 8:44 am
Full Name: Nikita Efes

Re: Query Source VM for FileCopy

Veeam Logoby Talom » Tue Oct 21, 2014 2:39 pm

Thanks for the help.
Thats what i looked for.
Talom
Influencer
 
Posts: 13
Liked: 1 time
Joined: Tue Oct 21, 2014 7:56 am


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 8 guests