$test = {
function makeform {
[void][reflection.assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.Application]::EnableVisualStyles();
$form = New-Object Windows.Forms.Form
$form.Text = 'Test Form'
$form.Add_Shown({$form.Activate()})
$form.ShowDialog()
}
}
Start-Job { makeform } -InitializationScript $test
---------------------------------
PS C:\WINDOWS\system32> D:\AMS\scripts\MaybeBug.ps1
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
7 Job7 BackgroundJob Running True localhost makeform
----------------------------------
Visual Stu
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
1 Job1 BackgroundJob Failed False localhost makeform
Hey @marksrasmussen, there may be some behavior we need to add to support PowerShell jobs. Thanks for the example script! I'll try to get this fixed for a future release.
Just wanted to include some error information, I got bit by this bug today.
Start-Job -Name testjob2 -ScriptBlock {get-process -Name "Code" | select processname,id,starttime}
receive-job -name testjob2
[localhost] The background process reported an error with the following message:
Cannot process an element with node type "Text".
Only Element and EndElement node types are supported.at
System.Management
.Automation
.Remoting
.OutOfProcessUtils
.ProcessData(String data, DataProcessingDelegates callbacks).
+ CategoryInfo : OpenError: (localhost:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : 2100,PSSessionStateBroken
What a strange error... Not sure if it's a job problem or something else. Will look into it!
The issue is still present in the current marketplace release (0.6.1 - 5/17/2016).
Sorry, this item is still on the backlog. To keep track of the status of this bug, keep an eye on the Milestone field to the upper right.
Hopefully we can get it at least figured out for the next release and possibly fixed if the "fix" is simple enough. :-) I think we are shooting for a faster release frequency which may help as well.
Having the same issue as @mcmiv413, my integration scripts actively using powershell jobs, so this will be nice to have full support of jobs in vscode-powershell.
@rkeithhill @daviwil Just circling back on this to clean up. I am able to successfully invoke PowerShell Background Jobs on Mac OS X from the latest version of the VSCode PowerShell Extension. I'm currently running:
PS /Users/tsulli/Amazon> code -v
1.11.2
6eaebe3b9c70406d67c97779468c324a7a95db0e
PS /Users/tsulli/Amazon> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.0-alpha
PSEdition Core
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 3.0.0.0
GitCommitId v6.0.0-alpha.18
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
PS /Users/tsulli/Amazon> code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

Cheers,
Trevor Sullivan
On MacOS with VSCode 1.15.1 and PowerShell Extension version 1.4.1 and PowerShell Core Beta 5...
I am able to start a job from the terminal window or by pressing F8 on a line in the editor. However, if I use the F8 method, then the terminal window does not respond until I press ENTER an additional time. If I run Start-Job in the terminal window directly then the prompt returns immediately. The same behavior is true when using the "&" appended at the end of the line to start a job.
Hi @GoateePFE, can you elaborate on what you mean by the F8 method?
@tylerl0706 In the Windows PowerShell Integrated Scripting Editor (ISE), F8 became the standard shortcut to run the "current line" that the cursor is on (if there is no editor selection) or "current selection" (if there is an editor selection).
So, I'm guessing that what @GoateePFE means by "F8 method" is that he's simply putting the cursor on a line with a Start-Job command and simply hitting F8 to invoke that line, as opposed to manually typing the Start-Job command into the VSCode Integrated Terminal.
@tylerl0706 The comments of @pcgeek86 are correct.
Thanks for that guys! I can repro exactly what @pcgeek86 said. So something fixed the other scenarios but this one is still broken. We'll have to look into this.
Thanks for the update!
I bet the issue that @GoateePFE is seeing is the same bug as https://github.com/PowerShell/PowerShellEditorServices/issues/554. It only happens on non-Windows systems. I know right where the issue lies (documented in the aforementioned issue and my first attempt to fix it - https://github.com/PowerShell/PowerShellEditorServices/pull/557).
@rkeithhill this issue _should_ be fixed now with https://github.com/PowerShell/PowerShellEditorServices/pull/592
But it also looks like @SeeminglyScience might be addressing an issue with that PR?
Yup, I'd say the original issue is fixed. Close it.
Awesome! Keep your eyes out for this in the next release!
Regarding the The background process reported an error with the following message:
Cannot process an element with node type "Text".
Only Element and EndElement node types are supported error see: https://stackoverflow.com/questions/33936510/start-job-including-custom-cmdlet-terminates-with-strange-error