Hello,
When I try to execute powerhsell in code behind of the application page, I have following error:
{"Dynamic operations can only be performed in homogenous AppDomain."}
at System.Management.Automation.SessionStateInternal..ctor(SessionStateInternal parent, Boolean linkToGlobal, ExecutionContext context)
at System.Management.Automation.SessionStateInternal..ctor(ExecutionContext context)
at System.Management.Automation.ExecutionContext.InitializeCommon(AutomationEngine engine, PSHost hostInterface)
at System.Management.Automation.ExecutionContext..ctor(AutomationEngine engine, PSHost hostInterface, RunspaceConfiguration runspaceConfiguration)
at System.Management.Automation.AutomationEngine..ctor(PSHost hostInterface, RunspaceConfiguration runspaceConfiguration, InitialSessionState iss)
at System.Management.Automation.Runspaces.LocalRunspace.DoOpenHelper()
at System.Management.Automation.Runspaces.LocalRunspace.OpenHelper(Boolean syncCall)
at System.Management.Automation.Runspaces.RunspaceBase.CoreOpen(Boolean syncCall)
at System.Management.Automation.Runspaces.RunspaceBase.Open()
at GenusMUIntergation.Code.Handlers.UpdateSharepointPhoto.<ProcessRequest>b__0()
at Microsoft.SharePoint.SPSecurity.CodeToRunElevatedWrapper(Object state)
at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.<RunWithElevatedPrivileges>b__3()
at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open(); (at this line of code)
RunspaceInvoke invoker = new RunspaceInvoke(runspace);
Probably this problem related with CAS.
How can I resolve this , and execute powerhsell script in IHttpHandlers or ApplicationPages?