Code: Select all
asnp "VeeamPSSnapin"
$vmlist = Import-CSV C:\Scripts\create-servers.csv
# map out variables
$vmname = $item.name
$vcserver = $item.vcserver
$veeamjobname = "MMS-CORP"
$vbrjob = Get-VBRJob | Where {$_.Name -eq $veeamjobname}
$veeamserver = Get-VBRServer | Where {$_.Type -eq "VC"}
foreach ($item in $vmlist) {
write-host adding $item.name to Veeam Backup $item.backupjob
Add-VBRJobObject -Job $vbrjob -Server $veeamserver -Object $item.name | out-null
#just the test the varible
echo $item.backupjob
}
This works but as soon as I replace $veeamjobname = "MMS-CORP" to $veeamjobname = item.backupjob it breaks.
here is the output
PS C:\Scripts> .\veeambu.ps1
adding dc02dbc01s04 to Veeam Backup MMS-CORP
Add-VBRJobObject : Cannot bind parameter 'Job'. Cannot convert the "MMS-CORP" value of type "System.String" to type
"Veeam.Backup.Core.CBackupJob".
At C:\Scripts\veeambu.ps1:18 char:23
+ Add-VBRJobObject -Job $veeamjobname -Server $veeamserver -Object $item.name | ou ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Add-VBRJobObject], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Backup.PowerShell.Command.AddVBRJobObject
MMS-CORP
adding dc02dbc01s05 to Veeam Backup MMS-CORP
Add-VBRJobObject : Cannot bind parameter 'Job'. Cannot convert the "MMS-CORP" value of type "System.String" to type
"Veeam.Backup.Core.CBackupJob".
At C:\Scripts\veeambu.ps1:18 char:23
+ Add-VBRJobObject -Job $veeamjobname -Server $veeamserver -Object $item.name | ou ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Add-VBRJobObject], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Backup.PowerShell.Command.AddVBRJobObject
any input is welcomed!