I got this weird error since yesterday and I have no clue how to fix it.
We shut down our Scriptrunner Server 2 weeks ago, all necessary scripts were running fine on PU.
Yesterday I started to transfer the “nice to have” scripts and I created a new variable needed for one script. After that the credential variables weren’t available anymore. I can’t choose any when running a script which has a [PSCredential] parameter neither can I choose a RunAs credential. The error I get see below (sorry for the German).
I have deleted the new variable, edited the variables.ps1 with a restart of the PSU Service but nothing helps. The scripts I had configured to run with specific credentials before still work.
Any ideas how to narrow it down or fix this are welcome.
Regards
Sven
2022-03-31 09:34:06.999 +02:00 [INF] Invoking script New-PU-Group.ps1
2022-03-31 09:34:07.002 +02:00 [DBG] ParentJobId: 0
2022-03-31 09:34:07.041 +02:00 [INF] Job 62 started.
2022-03-31 09:34:07.064 +02:00 [DBG] Job 62 bound to port 50349.
2022-03-31 09:34:07.064 +02:00 [DBG] Starting C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe with command line -NoProfile -Command "& { [System.Reflection.Assembly]::LoadFrom('C:\Program Files (x86)\Universal\Host\host.dll') | Out-Null; [UniversalHost.AgentService]::StartJob(50349, 11820, $False, 49713) }"
2022-03-31 09:34:07.064 +02:00 [INF] Starting job using Process.
2022-03-31 09:34:07.649 +02:00 [DBG] Agent Output: Exception:System.Management.Automation.SetValueInvocationException: Ausnahme beim Festlegen von "CreateRunspace": "Der Wert "static runspace GetRunspace()" vom Typ "System.Management.Automation.PSMethod" kann nicht in den Typ "System.Func`1[System.Management.Automation.Runspaces.Runspace]" konvertiert werden." ---> System.Management.Automation.PSInvalidCastException: Der Wert "static runspace GetRunspace()" vom Typ "System.Management.Automation.PSMethod" kann nicht in den Typ "System.Func`1[System.Management.Automation.Runspaces.Runspace]" konvertiert werden.
2022-03-31 09:34:07.649 +02:00 [DBG] Agent Output: bei System.Management.Automation.LanguagePrimitives.ThrowInvalidCastException(Object valueToConvert, Type resultType)
2022-03-31 09:34:07.649 +02:00 [DBG] Agent Output: bei System.Management.Automation.LanguagePrimitives.ConvertNoConversion(Object valueToConvert, Type resultType, Boolean recurse, PSObject originalValueToConvert, IFormatProvider formatProvider, TypeTable backupTable)
2022-03-31 09:34:07.649 +02:00 [DBG] Agent Output: bei CallSite.Target(Closure , CallSite , Type , Object )
2022-03-31 09:34:07.649 +02:00 [DBG] Agent Output: --- Ende der internen Ausnahmestapelberwachung ---
2022-03-31 09:34:07.649 +02:00 [DBG] Agent Output: bei System.Management.Automation.ExceptionHandlingOps.ConvertToMethodInvocationException(Exception exception, Type typeToThrow, String methodName, Int32 numArgs, MemberInfo memberInfo)
2022-03-31 09:34:07.649 +02:00 [DBG] Agent Output: bei CallSite.Target(Closure , CallSite , Type , Object )
2022-03-31 09:34:07.649 +02:00 [DBG] Agent Output: bei System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
2022-03-31 09:34:07.649 +02:00 [DBG] Agent Output: bei System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
2022-03-31 09:34:07.649 +02:00 [DBG] Agent Output: bei System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2022-03-31 09:34:10.061 +02:00 [DBG] Job 62 status Completed.
2022-03-31 09:34:10.063 +02:00 [INF] Job 62 completed
Are you seeing any errors regarding variables.ps1 in your notifications or logs? It seems like it’s failing to process the variables.ps1 file properly.