Cody Konior has a beef with Powershell workflows:
That’s inexplicable.
One thing which does make it all work is setting $PSRunInProcessPreference which, “If this variable is specified, all activities in the enclosing scope are run in the workflow process.” Unfortunately that doesn’t explain what’s really going on and what the impacts are, so I won’t use it. But here it is turning the original failing script into a working one.
I’ve never used Powershell workflows. It sounds like potentially an exasperating experience.