'Workflow and webrequest sessionvariable

I'm trying to get invoke-webrequest or invoke-restmethod to save its sessionvariable inside a workflow. but nothing happens, I get a blank variable, and no error. I need to use the same session twice. here is "example code"

The second session will be a new one, because the first one doesn't save session I've tried to search for this issue, but can't find anything. It made me realize that "set-variable" is broken inside workflow too. Is there nothing I can do?

workflow test  {
    foreach -parallel ($i in 1..2) {
        $response = Invoke-webrequest -Method get -Uri "http://www.google.com" -SessionVariable session
        $response2 = Invoke-webrequest -Method get -Uri "http://www.google.com" -WebSession $session
    }
}

test

edit: yes my "session" variable is null.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source