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)
}
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
Any idea what could be going wrong here? some dependicy missing when applying the options?
kind Regards,
Bastiaan