Understanding PowerShell Background Jobs

Last night I spoke to the CNY .NET Developers Group about background jobs in Windows PowerShell. Even though the audience was primarily developers, I discussed jobs from an administrator’s perspective, that is, using cmdlets. The job feature in PowerShell 2.0 is pretty amazing and you don’t need any programming skills. Continue reading

Running Veeam Jobs

I’m still fighting hardware issues with my ESX box (among other things) but I wanted to jot down some more notes on my experiences with PowerCLI and the Veeam backup cmdlets. Last week I wrote about how I created multiple backup jobs with a one line PowerShell expression.  After the jobs were created I needed to run them. For performance purposes I only wanted to run one at a time but I obviously wasn’t going to sit up all night staring at a computer screen.

My answer was to use Veeam’s Start-VBRJob cmdlet. The cmdlet takes a job name as a parameter, which you can pipe to it. All I needed was a collection of job names. I created an empty array, $jobs and then added one job that I knew I still needed for a VM on another datastore. The other new jobs were for VMs on datastore2. Using Get-VBRJob I retrieved all my Veeam jobs, piped them to Where-Object to filter out all jobs except those where the TargetDir property was G:\Datastore2, since I had all my datastore2 jobs backing up to the same location. For each matching backup job, I added the job name to the $jobs array.


Now that I had a collection of jobs, all that was left was to pipe it to Start-VBRJob.

PS C:\> $jobs | Start-VBRJob

The jobs run synchronously and you won’t get your PowerShell prompt back until all the jobs have finished which could be several hours. I was going to let it run overnight so it didn’t matter. But next time I would use a PowerShell job and let this run in the background.