Skip to content

Commit

Permalink
Define variable before usage, check $Data for nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
codykonior committed Feb 5, 2018
1 parent ca402b2 commit 6391c75
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion PoshRSJob/PoshRSJob.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ $PoshRS_jobCleanup.PowerShell = [PowerShell]::Create().AddScript({
If ($job.Handle.isCompleted -AND (-NOT $Job.Completed)) {
#$PoshRS_jobCleanup.Host.UI.WriteVerboseLine("$($Job.Id) completed")
$Data = $null
$CaughtErrors = $null
Try {
$Data = $job.InnerJob.EndInvoke($job.Handle)
} Catch {
Expand Down Expand Up @@ -156,7 +157,7 @@ $PoshRS_jobCleanup.PowerShell = [PowerShell]::Create().AddScript({
#$PoshRS_jobCleanup.Host.UI.WriteVerboseLine("$($Job.Id) Disposing job")
$job.InnerJob.dispose()
#Return type from Invoke() is a generic collection; need to verify the first index is not NULL
If (($Data.Count -gt 0) -AND (-NOT ($Data.Count -eq 1 -AND $Null -eq $Data[0]))) {
If ($Data -and ($Data.$Count -gt 0) -AND (-NOT ($Data.Count -eq 1 -AND $Null -eq $Data[0]))) {
$job.output = $Data
$job.HasMoreData = $True
}
Expand Down

0 comments on commit 6391c75

Please sign in to comment.