protected override void InternalProcessRecord() { try { SetDistributionGroupCmdlet setDistributionGroupCmdlet = new SetDistributionGroupCmdlet(); ADObjectId executingUserId; base.ExchangeRunspaceConfig.TryGetExecutingUserId(out executingUserId); setDistributionGroupCmdlet.Authenticator = Authenticator.Create(base.CurrentOrganizationId, executingUserId); setDistributionGroupCmdlet.HostServerName = EOPRecipient.GetPsWsHostServerName(); if (string.IsNullOrEmpty(this.ExternalDirectoryObjectId) && this.Identity == null) { base.ThrowTaskError(new ArgumentException(CoreStrings.MissingIdentityParameter.ToString())); } EOPRecipient.SetProperty(setDistributionGroupCmdlet, Parameters.Identity, string.IsNullOrEmpty(this.ExternalDirectoryObjectId) ? this.Identity.ToString() : this.ExternalDirectoryObjectId); EOPRecipient.SetProperty(setDistributionGroupCmdlet, Parameters.DisplayName, this.DisplayName); EOPRecipient.SetProperty(setDistributionGroupCmdlet, Parameters.Alias, this.Alias); EOPRecipient.SetProperty(setDistributionGroupCmdlet, Parameters.PrimarySmtpAddress, this.PrimarySmtpAddress); EOPRecipient.SetProperty(setDistributionGroupCmdlet, Parameters.ManagedBy, this.ManagedBy); EOPRecipient.SetProperty(setDistributionGroupCmdlet, Parameters.Organization, base.Organization); setDistributionGroupCmdlet.Run(); EOPRecipient.CheckForError(this, setDistributionGroupCmdlet); } catch (Exception e) { base.ThrowAndLogTaskError(e); } }
public static void SetFFOGroup(DataRow inputRow, DataTable table, DataObjectStore store) { SetDistributionGroupCmdlet setDistributionGroupCmdlet = new SetDistributionGroupCmdlet(); setDistributionGroupCmdlet.Authenticator = PswsAuthenticator.Create(); setDistributionGroupCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null); setDistributionGroupCmdlet.Identity = ((Identity)inputRow["Identity"]).RawIdentity; if (!DBNull.Value.Equals(inputRow["DisplayName"])) { setDistributionGroupCmdlet.DisplayName = inputRow["DisplayName"].ToString(); } if (!DBNull.Value.Equals(inputRow["Alias"])) { setDistributionGroupCmdlet.Alias = inputRow["Alias"].ToString(); } if (!DBNull.Value.Equals(inputRow["PrimarySmtpAddress"])) { setDistributionGroupCmdlet.PrimarySmtpAddress = inputRow["PrimarySmtpAddress"].ToString(); } if (!DBNull.Value.Equals(inputRow["ManagedBy"])) { string[] managedBy = (from o in (object[])inputRow["ManagedBy"] select((Identity)o).DisplayName).ToArray <string>(); setDistributionGroupCmdlet.ManagedBy = managedBy; } setDistributionGroupCmdlet.Run(); if (!string.IsNullOrEmpty(setDistributionGroupCmdlet.Error)) { throw new Exception(setDistributionGroupCmdlet.Error); } if (!DBNull.Value.Equals(inputRow["MembersRemoved"]) || !DBNull.Value.Equals(inputRow["MembersAdded"])) { string[] members = (from o in (object[])inputRow["Members"] select((Identity)o).DisplayName).ToArray <string>(); UpdateDistributionGroupMemberCmdlet updateDistributionGroupMemberCmdlet = new UpdateDistributionGroupMemberCmdlet(); updateDistributionGroupMemberCmdlet.Authenticator = PswsAuthenticator.Create(); updateDistributionGroupMemberCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null); updateDistributionGroupMemberCmdlet.Identity = ((Identity)inputRow["Identity"]).RawIdentity; updateDistributionGroupMemberCmdlet.Members = members; updateDistributionGroupMemberCmdlet.Run(); if (!string.IsNullOrEmpty(updateDistributionGroupMemberCmdlet.Error)) { throw new Exception(updateDistributionGroupMemberCmdlet.Error); } } if (!DBNull.Value.Equals(inputRow["Notes"])) { SetGroupCmdlet setGroupCmdlet = new SetGroupCmdlet(); setGroupCmdlet.Authenticator = PswsAuthenticator.Create(); setGroupCmdlet.HostServerName = AppConfigLoader.GetConfigStringValue("PswsHostName", null); setGroupCmdlet.Identity = ((Identity)inputRow["Identity"]).RawIdentity; setGroupCmdlet.Notes = inputRow["Notes"].ToString(); if (!DBNull.Value.Equals(inputRow["ManagedBy"])) { string[] managedBy2 = (from o in (object[])inputRow["ManagedBy"] select((Identity)o).DisplayName).ToArray <string>(); setGroupCmdlet.ManagedBy = managedBy2; } setGroupCmdlet.Run(); if (!string.IsNullOrEmpty(setGroupCmdlet.Error)) { throw new Exception(setGroupCmdlet.Error); } } }