Esempio n. 1
0
        internal override void SetJournalRuleInternal(ExchangeJournalRule rule)
        {
            ExchangeLog.LogStart("SetJournalRule");
            ExchangeLog.DebugInfo("journalEmail: {0}", rule.JournalEmailAddress);

            Runspace runSpace = null;

            try
            {
                runSpace = OpenRunspace();
                Command cmd;
                if (rule.Enabled)
                {
                    cmd = new Command("Enable-JournalRule");
                    cmd.Parameters.Add("Identity", rule.Name);
                    ExecuteShellCommand(runSpace, cmd);
                }
                else
                {
                    cmd = new Command("Disable-JournalRule");
                    cmd.Parameters.Add("Identity", rule.Name);
                    ExecuteShellCommand(runSpace, cmd);
                }
                cmd = new Command("Set-JournalRule");
                cmd.Parameters.Add("Identity", rule.Name);
                cmd.Parameters.Add("Scope", rule.Scope);
                cmd.Parameters.Add("Recipient", rule.Recipient);
                ExecuteShellCommand(runSpace, cmd);
                ExchangeLog.LogEnd("SetJournalRule");
            }
            catch (Exception ex)
            {
                ExchangeLog.LogError("SetJournalRule", ex);
                throw;
            }
            finally
            {
                CloseRunspace(runSpace);
            }
        }
Esempio n. 2
0
        internal override ExchangeJournalRule GetJournalRuleInternal(string journalEmail)
        {
            ExchangeJournalRule ret = new ExchangeJournalRule();

            ExchangeLog.LogStart("GetJournalRule");
            ExchangeLog.DebugInfo("journalEmail: {0}", journalEmail);

            Runspace runSpace = null;

            try
            {
                runSpace = OpenRunspace();
                Command cmd = new Command("Get-JournalRule");
                cmd.Parameters.Add("Identity", GetJournalRuleName(journalEmail));
                Collection <PSObject> result = ExecuteShellCommand(runSpace, cmd);
                ExchangeLog.LogEnd("GetJournalRule");
                if (result.Count == 0)
                {
                    return(null);
                }
                ret.Name = ObjToString(GetPSObjectProperty(result[0], "Name"));
                ret.JournalEmailAddress = ObjToString(GetPSObjectProperty(result[0], "JournalEmailAddress"));
                ret.Recipient           = ObjToString(GetPSObjectProperty(result[0], "Recipient"));
                ret.Scope   = ObjToString(GetPSObjectProperty(result[0], "Scope"));
                ret.Enabled = ObjToBoolean(GetPSObjectProperty(result[0], "Enabled"));
                return(ret);
            }
            catch (Exception ex)
            {
                ExchangeLog.LogError("GetJournalRule", ex);
                throw;
            }
            finally
            {
                CloseRunspace(runSpace);
            }
        }