-
-
Notifications
You must be signed in to change notification settings - Fork 69
Closed
Labels
Milestone
Description
Expected Behavior
No errors
Actual Behavior
There is no Runspace available to run scripts in this thread. You can provide one in the DefaultRunspace property of the System.Management.Automation.Runspaces.Runspace type. The script block you attempted to invoke was:
...
Of type: System.Management.Automation.CmdletInvocationException
Stack trace:
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
at Spe.Core.Host.ScriptSession.ExecuteCommand(Boolean stringOutput, Boolean marshallResults)
at Spe.Core.Host.ScriptSession.<>c__DisplayClass150_0.b__0()
at Spe.Core.Utility.SpeTimer.Measure[T](String message, Boolean log, Func`1 action)
at Spe.Client.Applications.PowerShellIse.ExecuteInternal(ScriptSession scriptSession, String script)
at Spe.Client.Applications.ScriptRunner.Run()
Inner Exception:There is no Runspace available to run scripts in this thread. You can provide one in the DefaultRunspace property of the System.Management.Automation.Runspaces.Runspace type. The script block you attempted to invoke was:
...
Of type: System.Management.Automation.PSInvalidOperationException
Stack trace:
at System.Management.Automation.ScriptBlock.GetContextFromTLS()
at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args)
at System.Management.Automation.ScriptBlock.DoInvokeReturnAsIs(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args)
at Microsoft.PowerShell.Commands.Internal.Format.MshExpression.GetValue(PSObject target, Boolean eatExceptions)
at Microsoft.PowerShell.Commands.Internal.Format.MshExpression.GetValues(PSObject target, Boolean expand, Boolean eatExceptions)
at Microsoft.PowerShell.Commands.Internal.Format.ComplexControlGenerator.ExecuteFormatTokenList(TraversalInfo level, PSObject so, List`1 formatTokenList, List`1 formatValueList)
at Microsoft.PowerShell.Commands.Internal.Format.ComplexControlGenerator.ExecuteFormatControl(TraversalInfo level, ControlBase control, PSObject so, List`1 formatValueList)
at Microsoft.PowerShell.Commands.Internal.Format.ComplexViewGenerator.GenerateComplexViewEntryFromDataBaseInfo(PSObject so, Int32 enumerationLimit)
at Microsoft.PowerShell.Commands.Internal.Format.ComplexViewGenerator.GeneratePayload(PSObject so, Int32 enumerationLimit)
at Microsoft.PowerShell.Commands.Internal.Format.OutOfBandFormatViewManager.GenerateOutOfBandData(TerminatingErrorContext errorContext, MshExpressionFactory expressionFactory, TypeInfoDataBase db, PSObject so, Int32 enumerationLimit, Boolean useToStringFallback, List`1& errors)
at Microsoft.PowerShell.Commands.Internal.Format.InnerFormatShapeCommand.ProcessOutOfBandObjectOutsideDocumentSequence(PSObject so)
at Microsoft.PowerShell.Commands.Internal.Format.InnerFormatShapeCommand.ProcessObject(PSObject so)
at System.Management.Automation.CommandProcessor.ProcessRecord()
Steps to Reproduce the Problem
Simplified
For convenience I created a package with everything needed to reproduce the issue:
- Install RunspaceException-1.0.zip
- Open
/sitecore/system/Modules/PowerShell/Script Library/RunspaceException/Functions/Example1in ISE - Run
Manual
Here's a complete list of steps:
- Enable
ScriptedItemEventHandlerforitem:addedevent
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:security="http://www.sitecore.net/xmlconfig/security/">
<sitecore role:require="Standalone or ContentManagement or XMCloud" security:require="Sitecore">
<events>
<event name="item:added">
<handler type="Spe.Integrations.Tasks.ScriptedItemEventHandler, Spe" method="OnEvent" />
</event>
</events>
</sitecore>
</configuration>1..2 | % {
$folder = [guid]::NewGuid().ToString("N")
New-Item -Path "/sitecore/templates/User Defined" -Name $folder -ItemType "System/Media/Media folder"
}