PowerShell script exchange
Post Reply
Talom
Influencer
Posts: 23
Liked: 2 times
Joined: Oct 21, 2014 7:56 am
Contact:

Query Source VM for FileCopy

Post by Talom » 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.
BACKUP EAGLE® Developer

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Query Source VM for FileCopy

Post by veremin » 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.

Talom
Influencer
Posts: 23
Liked: 2 times
Joined: Oct 21, 2014 7:56 am
Contact:

Re: Query Source VM for FileCopy

Post by Talom » 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.
BACKUP EAGLE® Developer

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Query Source VM for FileCopy

Post by veremin » 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.

Talom
Influencer
Posts: 23
Liked: 2 times
Joined: Oct 21, 2014 7:56 am
Contact:

Re: Query Source VM for FileCopy

Post by Talom » Oct 21, 2014 9:24 am

Thats exactly what i want.
It is a File Copy

Sorry for misunderstanding ;)
BACKUP EAGLE® Developer

veremin
Product Manager
Posts: 16710
Liked: 1396 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Query Source VM for FileCopy

Post by veremin » 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.

Talom
Influencer
Posts: 23
Liked: 2 times
Joined: Oct 21, 2014 7:56 am
Contact:

Re: Query Source VM for FileCopy

Post by Talom » 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
BACKUP EAGLE® Developer

nefes
Veeam Software
Posts: 623
Liked: 155 times
Joined: Dec 10, 2012 8:44 am
Full Name: Nikita Efes
Contact:

Re: Query Source VM for FileCopy

Post by nefes » 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

Talom
Influencer
Posts: 23
Liked: 2 times
Joined: Oct 21, 2014 7:56 am
Contact:

Re: Query Source VM for FileCopy

Post by Talom » Oct 21, 2014 2:39 pm

Thanks for the help.
Thats what i looked for.
BACKUP EAGLE® Developer

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests