Powershell runbooks on hybrid workers can access other jobs variables if too many jobs are running at the same time
Opened this issue · 0 comments
Hi! We have some user onboarding/offboarding scripts that run on hybrid workers. Sometimes, when there are several jobs running at the same time on the same hybrid worker, a script will eventually be able to read data from another job that is running at the same time.
A simplified example:
1 $Var1 = "1"
2 if ($Var1 -eq "1") {
3 $Email = "user@company.com"
4 }
5
6 .\ChildScript.ps1 -parameter1 "something" -parameter2 $Email
In Job 1, $Var1 is "1", so $Email will be created and populated with "user@company.com".
In Job 2, $Var1 is "6", so $Email is never created. It should be $null all along the script.
Expected behavior: In Job 2, line 6 will send nothing in parameter2.
What happens: If there are many jobs running at the same time, sometimes Job 2 will send "user@company.com" on line 6, which is an e-mail that was assigned to $Email in Job 1.
It doesn't happen every time, but we were able to consistently trigger this by sending several jobs (50 to 80) at the same time.
Shouldn't the variables be sandboxed in it's own powershell process?
Additional info, in case it makes any difference:
- Hybrid workers are extension based and running on Windows Server 2012 R2
- The real scripts contains several get-aduser and set-aduser commands
- When $Var1 is "1", there is a connection to an on-premises exchange server via $Session = New-PSSession and Import-PSSession $Session
- Runtime Version is Powershell 5.1