Export / Import jobs

PowerShell script exchange

Export / Import jobs

Veeam Logoby b.vanhaastrecht » Tue May 05, 2015 10:06 am

Hi,

I'm trying to make an example script work. I'm having troubles in placing the job options on the imported job. The script runs on the existing B&R server, and creates a remote connection to the B&R where the job needs to be created.

The script:
Code: Select all
Asnp VeeamPSSnapin
$RemoteVBRServer = "remote B&R server"
$JobToCopy = "job name to copy"

$Job = Get-VBRJob -name $JobToCopy
$Names = ($Job | Get-VBRJobObject).name
$Options = $Job.GetOptions()
$VSSOptions = $Job.GetVssOptions()


Invoke-Command -Comp $RemoteVBRServer -Scriptblock {
    Asnp VeeamPSSnapin
    $Server = Get-VBRServer | ?{($_.type -eq "vc") -and (($_.name -eq "vcenter attached to vmware job") )}
    $Entity = foreach ($name in $Using:Names){
        Find-VBRViEntity -Server $Server | ?{($_.name -eq $Name)}
    }
   
    $Repository = Get-VBRBackupRepository -name "the repository"
    Add-VBRViBackupJob -Entity $Entity -Name $Using:JobToCopy -BackupRepository $Repository
    Start-sleep -s 5
    $Job2 = Get-VBRJob | ? {$_.name -eq $Using:JobToCopy}
    $Job2.SetOptions($Using:Options)
    $Job2.SetVssOptions($Using:VSSOptions)
}


The error I get is after the job is imported, and the options are placed on it:
Code: Select all
Cannot convert argument "jobOptions", with value: "Veeam.Backup.Model.CJobOptions", for "SetOptions" to type
"Veeam.Backup.Model.CJobOptions": "Cannot convert value "Veeam.Backup.Model.CJobOptions" to type
"Veeam.Backup.Model.CJobOptions". Error: "Cannot convert the "Veeam.Backup.Model.CJobOptions" value of type
"Deserialized.Veeam.Backup.Model.CJobOptions" to type "Veeam.Backup.Model.CJobOptions".""
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
    + PSComputerName        : xxxxxxxxxxxxxxxxxxxxx
 
Cannot convert argument "vssOptions", with value: "VssSnapshotOptions: [Enabled: [True], IgnoreErrors: [False], IsCopyOnly:
[False]], WinGuestFSIndexingOptions: [Type: [None]], LinGuestFSIndexingOptions: [Type: [None]], SqlBackupOptions:
[TransactionLogsProcessing: [TruncateOnlyOnSuccessJob], BackupLogsFrequencyMin: [15], UseDbBackupRetention: [True],
RetainDays: [15], ProxyAutoSelect: [True]], ExchangeBackupOptions: [TransactionLogsProcessing: [TruncateOnlyOnSuccessJob]],
WinCredsId: [b7f45e7c-9be9-462d-8d62-09a7b0387d7b], LinCredsId: [00000000-0000-0000-0000-000000000000], Old Properties:
[Enabled: [True], IgnoreErrors: [False], GuestFSIndexingType: [None], IncludedIndexingFolders: [], ExcludedIndexingFolders:
[], LinGuestFSIndexingType: [None], LinIncludedIndexingFolders: [], LinExcludedIndexingFolders: [], IsFirstUsage: [True]]",
for "SetVssOptions" to type "Veeam.Backup.Model.CGuestProcessingOptions": "Cannot convert the "VssSnapshotOptions:
[Enabled: [True], IgnoreErrors: [False], IsCopyOnly: [False]], WinGuestFSIndexingOptions: [Type: [None]],
LinGuestFSIndexingOptions: [Type: [None]], SqlBackupOptions: [TransactionLogsProcessing: [TruncateOnlyOnSuccessJob],
BackupLogsFrequencyMin: [15], UseDbBackupRetention: [True], RetainDays: [15], ProxyAutoSelect: [True]],
ExchangeBackupOptions: [TransactionLogsProcessing: [TruncateOnlyOnSuccessJob]], WinCredsId:
[b7f45e7c-9be9-462d-8d62-09a7b0387d7b], LinCredsId: [00000000-0000-0000-0000-000000000000], Old Properties: [Enabled:
[True], IgnoreErrors: [False], GuestFSIndexingType: [None], IncludedIndexingFolders: [], ExcludedIndexingFolders: [],
LinGuestFSIndexingType: [None], LinIncludedIndexingFolders: [], LinExcludedIndexingFolders: [], IsFirstUsage: [True]]"
value of type "Deserialized.Veeam.Backup.Model.CGuestProcessingOptions" to type
"Veeam.Backup.Model.CGuestProcessingOptions"."
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument
    + PSComputerName        : xxxxxxxxxxxxxxxxxxxxxxxxx
 


When running the same script against the same B&R server, the job get created fine with all options.

Any idea what could be going wrong here? some dependicy missing when applying the options?

kind Regards,
Bastiaan
========================================
Veeam ProPartner and Cloud Connect Provider
b.vanhaastrecht
Service Provider
 
Posts: 335
Liked: 65 times
Joined: Mon Aug 26, 2013 7:46 am
Location: The Netherlands
Full Name: Bastiaan van Haastrecht

Re: Export / Import jobs

Veeam Logoby b.vanhaastrecht » Tue May 05, 2015 10:19 am

There are warnings on the remote before this error.

Code: Select all
WARNING: You should update your PowerShell to PowerShell 2.0 version.


While we are running PS version 4, remote and locally:
Code: Select all
$PSVersionTable.PSVersion
Major  Minor  Build  Revision PSComputerName                                                                               
-----  -----  -----  -------- --------------                                                                               
4      0      -1     -1       xxxxxxxxxxxxxxx
========================================
Veeam ProPartner and Cloud Connect Provider
b.vanhaastrecht
Service Provider
 
Posts: 335
Liked: 65 times
Joined: Mon Aug 26, 2013 7:46 am
Location: The Netherlands
Full Name: Bastiaan van Haastrecht


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests