string shellUri = "http://schemas.microsoft.com/powershell/Microsoft.PowerShell"; PSCredential remoteCredential = new PSCredential("Username", StringToSecureString("Password")); WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, "Server IP", 5985, "/wsman", shellUri, remoteCredential); Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo); runspace.Open(); Pipeline pipeline = runspace.CreatePipeline(); Command newMailBox = new Command("New-Mailbox"); newMailBox.Parameters.Add("Name", "TestName1"); newMailBox.Parameters.Add("Alias", "TestName1"); newMailBox.Parameters.Add("database", "Mailbox Database 1406738839"); newMailBox.Parameters.Add("DisplayName", "TestName1"); newMailBox.Parameters.Add("UserPrincipalName", "TestName1@test.com"); newMailBox.Parameters.Add("OrganizationalUnit", "ou=myorg,dc=ad,dc=lab"); newMailBox.Parameters.Add("FirstName", "TestName1"); pipeline.Commands.Add(newMailBox); Collection<psobject> result = pipeline.Invoke();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)