I need to get active triggers for the jobs in the file. I am novice in PS and the script is made by a former employee. Can anyone help with what the $ObjData should be.
FUNCTION Get-VCAPIPath
{
$ProgramFilesPath = IF (${Env:PROCESSOR_ARCHITECTURE} -eq 'x86') { ${Env:ProgramFiles} } ELSE { ${Env:ProgramFiles(x86)} }
Join-Path $ProgramFilesPath VisualCron\VisualCronAPI.dll
}
FUNCTION Get-VCServer
{
[CmdletBinding()]
Param ([string]$ComputerName,
[int]$Port,
[System.Management.Automation.PSCredential]$Credential)
$APIPath = Get-VCAPIPath
IF (!(Test-Path $APIPath)) { Throw "VisualCron does not appear to be installed. API library not found at `"$APIPath`"." }
[Reflection.Assembly]::LoadFrom($APIPath) | Out-Null
$Conn = New-Object VisualCronAPI.Connection
$Conn.Address = IF ([String]::IsNullOrEmpty($ComputerName)) { ${Env:COMPUTERNAME} } ELSE { $ComputerName }
IF (!($Credential -eq $null))
{
$Conn.UseADLogon = $True
$NetCred = $credential.GetNetworkCredential()
$Conn.UserName = $NetCred.UserName
$Conn.Password = $NetCred.Password
}
$Client = New-Object VisualCronAPI.Client
$Client.Connect($conn)
}
#
# MAIN ROUTINE
#
$S = Get-VCServer -ComputerName LocalHost
$VCJobs = $S.Jobs.GetAll()
$AllVCJobs = @()
FOREACH ($VCJob IN $VCJobs)
{ $ObjData = New-Object System.Object
$ObjData | Add-Member -type NoteProperty -name JOBNAME -value $VCJob.Name
$ObjData | Add-Member -type NoteProperty -name JOBGROUP -value $VCJob.Group
$ObjData | Add-Member -type NoteProperty -name DESCRIPTION -value $VCJob.Description
$AllVCJobs += $ObjData
}
IF ($AllVCJobs.Count -gt 0) {$AllVCJobs | Sort-Object JobGroup, Jobname | Export-Csv -NoTypeInformation -Delimiter ";" -Path C:\TEMP\VC-JOBS.CSV}
$S.disconnect()
$S.dispose()