Je suis d'essayer de créer des groupes de distribution pour l'échange avec Powershell de C# avec ce code:WinRM refusé pour PowerShell à distance en C#, cryto nécessaire?
private void createDistributionGroup(string groupName, string DNOU)
{
System.Security.SecureString pass = new System.Security.SecureString("57R0NG_P455W0RD");
PSCredential cred = new PSCredential(SA_username, pass);
WSManConnectionInfo connection = new WSManConnectionInfo(new Uri("http://myEXserver.mydomain.com/PowerShell/"), "https://schemas.microsoft.com/powershell/Microsoft.Exchange", cred);
connection.AuthenticationMechanism = AuthenticationMechanism.Basic;
Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(connection);
PowerShell ps = PowerShell.Create();
PSCommand command = new PSCommand();
command.AddCommand("New-DistributionGroup");
command.AddParameter("Name", groupName);
ps.Commands = command;
try
{
runspace.Open();
ps.Runspace = runspace;
ps.Invoke();
}
finally
{
runspace.Dispose();
runspace = null;
ps.Dispose();
ps = null;
}
}
Mais quand j'exécute ce code, une erreur winrm ajouter que: connexion forbiden, trafic non crypté refusé par le serveur ...
Comment puis-je résoudre ce problème?
Je l'ai testé avec l'authentification kerberos mais il annexera une ARROR à –