PoshRSJob
PoshRSJob copied to clipboard
RsJob hangs and cannot be killed/removed even with -Force
Do you want to request a feature or report a bug? Bug. Need the -force parameter to kill or delete or remove a hung job. Or any other parameter of combination of parameters and commands that will do the same.
What is the current behavior? RsJob hangs and cannot be killed/removed even with -Force. Its been quite frequent. I am testing with 10 threads at a time and a total of 20 accounts to be processed. Since Morning I have encountered one job hanging in 3 different attempts.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem Please see attached screenshots
What is the expected behavior? Hangs and cannot be killed
Which versions of Powershell and which OS are affected by this issue? Did this work in previous versions of our scripts? Powershell Version = 5.1.14393.3866 Windows server 2016, OS Build 14393
Please provide a code example showing the issue, if applicable: Instaed of the full code, I have provided just the relevant lines.
$ScriptLocal =
{
param(
$Alias,
$Cred_Cloud
)
Connect-ExchangeOnline -Credential $Cred_Cloud | Out-Null
Get-MailboxStatistics $Alias
Get-PSSession | Remove-PSSession
}
Start-RsJob -Name "job_$Alias" -ScriptBlock $ScriptLocal -ArgumentList $Alias, $Cred_Cloud
$Job | receive-rsjob | select DisplayName, LastUserActionTime
Are you sure your problem isn't with the Exchange cmdlets? Are they thread safe?
Can you demonstrate the same problem with simple commands?
If not, I'm pretty sure it's not RSJob's fault.
Thanks @MVKozlov . When a thread hangs, I am running 10 threads with a total of 20 jobs. That means 19 jobs are successful. That would mean that the script is fine. Also all the block is doing is "get-mailboxstatistics". This is the same script block for all threads.
I am not concerned with a hanging job as I mentioned in the initial issue. Hanging Job is not the question here. All I am saying is that the -Force switch does not work. When executed it hangs the main session as well. Doing additional searches, it appears it was reported in an earlier issue as well in a different scenario: https://github.com/proxb/poshrsjob/issues/43 . I really like PoshRsJobs and I hope the -force parameter can be made to work correctly.
19 successful jobs ... It could also mean that race conditions inside cmdlets just haven't been encountered 19 times :)
The -Force
switch actually does the same thing as the Stop-RSJob
, so if one works, the other should work too. And vice versa.
Try using my fork as I made quite a few changes there and this project is actually frozen.
Thanks @MVKozlov . Are you saying I use the zip file from fork https://github.com/MVKozlov/PoshRSJob . Also when I added the Wait-RSJob, I get an error 'Wait-RSJob : A parameter cannot be found that matches parameter name 'PerJobTimeout'' The command is: Start-RsJob -Name "job_$Alias" -ScriptBlock $ScriptLocal -ArgumentList $Alias, $Cred_Cloud | Wait-RSJob -Timeout 200 -PerJobTimeout
Is the "PerJobTimeout" fixed in your fork as well?
-PerJobTimeout
is the my fork feature. The original doesn't have it
If you get this error the wrong module version loaded
is Get-Module PoshRSJob
return Version 1.7.5.2 ?
btw, latest not tagged version have some more fixes