- Code: Select all
Get-Folder "Temp" | Get-VM | ForEach { $v += @($_.Name) }
Actually thinking about what your trying to do, it wouldn't work in a array after look at the code below the Get-Folder, might I suggest you;
1) create the job without any objects
2) Move the Get-Folder cmd below your Add-VBRJob and change your ForEach to use the Add-VBRJobObject cmdlet(or use the function below)
- Code: Select all
function Add-JO{
Param ([string]$vmname,[string]$jobname)
$newjob = Get-VBRJob | ?{$_.Name -eq "$jobname"}
$vbrserver = Get-VBRServer | ?{$_.Type -eq "VC"}
Add-VBRJobObject -Job $newjob -Server $vbrserver -Object $vmname
}
and to call you would use
- Code: Select all
Add-JO "vm01.lab.local" "VM01 Backup Job Name"
