PowerShell Workflow Bug

There is bug with workflows in PowerShell v3 that you might run into. I kept banging into it until I tracked it down.  The problem occurs if you try to run a workflow from a PSDrive that you have added. For example, I have a PSDrive (S) which is mapped to C:\Scripts. When I try to run a workflow from this drive, I will get an error.

PS S:\> get-foo
Cannot perform operation because operation "ResetRunspaceState" is not valid. Remove operation "ResetRunspaceState",
or investigate why it is not valid.
    + CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : InvalidOperation
    + PSComputerName        : [localhost]

The workaround is to simply change to your C: drive, or any PSDrive that PowerShell loads by default. Then the workflow will run.

PS C:\> get-foo
hello

This has been filed on Connect but I thought I’d share the workaround so you don’t have to bang your head. And if you are curious about workflows, there will be a good chapter in the forthcoming PowerShell in Depth book.

Post to Twitter Post to Plurk Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to FriendFeed Post to Google Buzz Post to Ping.fm Post to Reddit Post to Slashdot Post to StumbleUpon Post to Technorati

About the Author

PowerShell.org Announcer

This is the official account for PowerShell.org and sponsor announcements.