I am writing a web service which needs to execute remote powershell in logged-on user context.
The application works fine if the logged-in user is a member of administrators group on remote machine, else the RunspaceFactory.CreateRunspace API fails with PSInvalidOperationException.
I have tried adding user to remote powershell users (using Set-PSSessionConfiguration), which I believe is the only required permission to run remote powershell.
Also, when I try this in a C# console application it works fine. I see the issue only with my web service.
I have also tried setting aspnet.config to allow flow of impersonation but still no luck.
<configuration><runtime><legacyImpersonationPolicyenabled=”false”/><alwaysFlowImpersonationPolicyenabled=”true”/></runtime></configuration>
I want to know if there are any additional settings required for IIS or ASP .NET to make it work?
Warm Regards
Himanshu Agarwal