Get-VBRJob

PowerShell script exchange

Get-VBRJob

Veeam Logoby sidavid » Sat Feb 04, 2012 1:36 pm

Hi,
I want to check if a job exists or not with the get-vbrjob command.

$job = "False"
$vbrjobname = "TECH"
$job = Get-VBRJob -Name $vbrjobname
if($job -ne "False")
{
Write-Host "The job doesn't exist"
}

But I receive this issue
Get-VBRJob : A parameter cannot be found that matches parameter name 'Name'.

Many thanks for your help
sidavid
Enthusiast
 
Posts: 60
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Get-VBRJob

Veeam Logoby sidavid » Sat Feb 04, 2012 5:39 pm

Hi

I found the script :

$vbrjobname = "NameOfTheJob"
$job = Get-VBRJob | ?{$_.Name -eq $vbrjobname}
$jobname = $job.Name
if($jobname -ne $null){$c = $jobname.CompareTo($vbrjobname)}
if($c -ne 0){Write-Host "Exist"}

Thanks
sidavid
Enthusiast
 
Posts: 60
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Get-VBRJob

Veeam Logoby ThomasMc » Mon Feb 06, 2012 10:06 am

A shorter version would be

Code: Select all
#v5
if ((Get-VBRJob | ?{$_.Name -eq "JobName"} | Measure-Object).Count -eq 0) {
   "The job doesn't exist" | Out-Default
}

#v6
if ((Get-VBRJob -Name "JobName" | Measure-Object).Count -eq 0) {
   "The job doesn't exist" | Out-Default
}
ThomasMc
Expert
 
Posts: 293
Liked: 17 times
Joined: Wed Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests