PowerShell script exchange
Post Reply
sidavid
Enthusiast
Posts: 48
Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:

Get-VBRJob

Post by sidavid »

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: 48
Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:

Re: Get-VBRJob

Post by sidavid »

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
ThomasMc
Veteran
Posts: 293
Liked: 19 times
Joined: Apr 13, 2011 12:45 pm
Full Name: Thomas McConnell
Contact:

Re: Get-VBRJob

Post by ThomasMc »

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
}
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests