简体   繁体   中英

Access Denied error in MVC System.Management.Automation powershell execution

I am currently attempting to create a user in an ASP.NET MVC application using the System.Management.Automation.Runspaces.Command with a remote Runspace using Kerberos authentication with a service account. Currently when I attempt to execute the command on the development server the command executes successfully, however when attempting to execute the command on the live web server I receive the following message

“Connecting to remote server echange-server failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting”

On both the live and debug server I can enter a remote PowerShell session with Enter-PSSession. I feel as if this is a Kerberos hop issue on the live server. But I'm unsure of what SPNs would need to be configured for Kerberos to work properly for powershell. Thank you.

I think that remote powershell isn´t enabled for the taskuser you are using, which will explain the "Access is denied.". Try to enable that via (as written in the MS documentation here ) via:

set-user <your user account> -RemotePowerShellEnabled $True

Another useful source to troubleshoot your issue is the MS documentation here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM