wcf - Pass Windows credential as PSCredential in Powershell script using C# -
i have wcf service executes remote powershell scripts , returns results client. when wcf hosted on iis following error @ invoke line.
using (var powershell = powershell.create()) { var command = new pscommand(); command.addcommand("new-pssession"); command.addparameter("configurationname", "microsoft.exchange"); command.addparameter("connectionuri", connectto); command.addparameter("authentication", "kerberos"); powershell.commands = command; powershell.runspace = runspace; var result = powershell.invoke();//error pssessionconnection = result[0]; }
processing data remote server #exchangeservername# failed following error message: [authzrequestid=ac0dedbe-a345-4eac-bb8d-cd5b8eab327c][failurecategory=authz-cmdletaccessdeniedexception] user #machinename# isn't assigned management roles.
how can make line
command.addparameter("authentication", "kerberos");
pass user credentials?