Workflow: $using: modifier stops working in InlineScript blocks after a single-statement InlineScript when ErrorActionPreference is Stop
Consider the following scenario:
- a workflow sets $ErrorActionPreference to Stop
- that workflow contains a single-statement InlineScript activity
- the workflow is invoked targetting a remote server
After the InlineScript activity executes, all subsequent InlineScript activities in _any_ workflow targetting that server lose access to workflow variables - all $using:varname expressions return empty values. This condition persists until the WinRM service is restarted on the target server.
Putting any other statement inside the InlineScript seems to prevent the bug from occuring.
Tested client / workflow host: PowerShell 4.0 on Windows 7 and 8.1
Tested workflow target computers: PowerShell 2.0 on Windows Server 2008; PowerShell 4.0 on Windows Server 2012 R2 and 2008 R2
At first, I thought that the problem appeared only if the single statement inside InlineScript is an external script invocation and I wrote an elaborate repro script: https://gist.github.com/jberezanski/1b7f40fa20b2364b64f6#file-reproduce-inlinescriptusingbug-ps1
Later, however, I discovered that the problem is in fact triggered by any statement, provided it is the only one in the InlineScript. The much simpler repro workflow is here: https://gist.github.com/jberezanski/1b7f40fa20b2364b64f6#file-repro2-ps1
(migrated from Connect: https://connect.microsoft.com/PowerShell/Feedback/Details/1174240)