private PowerShellResults ExportObject(ExportUMCallDataRecordParameters parameters)
        {
            PSCommand psCommand = new PSCommand().AddCommand("Export-UMCallDataRecord");

            psCommand.AddParameters(parameters);
            return(base.Invoke(psCommand));
        }
        public PowerShellResults <HotmailSubscription> GetObject(Identity identity)
        {
            PSCommand psCommand = new PSCommand().AddCommand("Get-HotmailSubscription");

            psCommand.AddParameters(new GetHotmailSubscription());
            return(base.GetObject <HotmailSubscription>(psCommand, identity));
        }
Example #3
0
        public PowerShellResults SendLog(CalendarDiagnosticLog properties)
        {
            PSCommand pscommand = new PSCommand().AddCommand("Get-CalendarDiagnosticLog");

            pscommand.AddParameter("Identity", Identity.FromExecutingUserId());
            pscommand.AddParameters(properties);
            return(base.Invoke(pscommand));
        }
Example #4
0
        public PowerShellResults <UserPhoto> GetPreviewPhoto(Identity identity)
        {
            PSCommand pscommand = new PSCommand();

            pscommand.AddCommand("Get-UserPhoto");
            pscommand.AddParameters(new GetUserPhotoParameters
            {
                Preview = new SwitchParameter(true)
            });
            return(base.GetObject <UserPhoto>(pscommand, identity));
        }
        public PowerShellResults RemoveObjects(Identity[] identities, BaseWebServiceParameters parameters)
        {
            PSCommand psCommand = new PSCommand().AddCommand("Remove-Subscription");

            psCommand.AddParameters(new RemoveSubscription());
            PowerShellResults powerShellResults = base.RemoveObjects(psCommand, identities, parameters);

            if (powerShellResults != null && powerShellResults.Succeeded)
            {
                Util.NotifyOWAUserSettingsChanged(UserSettings.Mail);
            }
            return(powerShellResults);
        }
        public PowerShellResults <JournalReportNdrTo> SetObject(Identity identity, SetJournalReportNdrTo properties)
        {
            PowerShellResults <JournalReportNdrTo> powerShellResults = new PowerShellResults <JournalReportNdrTo>();

            properties.IgnoreNullOrEmpty = false;
            if (properties.Any <KeyValuePair <string, object> >())
            {
                PSCommand psCommand = new PSCommand().AddCommand("Set-TransportConfig");
                psCommand.AddParameters(properties);
                PowerShellResults <JournalReportNdrTo> results = base.Invoke <JournalReportNdrTo>(psCommand);
                powerShellResults.MergeAll(results);
            }
            if (powerShellResults.Succeeded)
            {
                powerShellResults.MergeAll(this.GetObject(identity));
            }
            return(powerShellResults);
        }
Example #7
0
        public PowerShellResults <SetUMMailboxPinConfiguration> SetObject(Identity identity, SetUMMailboxPinParameters properties)
        {
            PSCommand pscommand = new PSCommand().AddCommand("Set-UMMailboxPin");

            pscommand.AddParameter("Identity", identity);
            pscommand.AddParameters(properties);
            PowerShellResults powerShellResults = base.Invoke(pscommand);
            PowerShellResults <SetUMMailboxPinConfiguration> powerShellResults2;

            if (powerShellResults.Succeeded)
            {
                powerShellResults2 = this.GetObject(identity);
            }
            else
            {
                powerShellResults2 = new PowerShellResults <SetUMMailboxPinConfiguration>();
                powerShellResults2.MergeErrors(powerShellResults);
            }
            return(powerShellResults2);
        }
Example #8
0
        public PowerShellResults <SetUMMailboxConfiguration> SetObject(Identity identity, SetUMMailboxParameters properties)
        {
            PowerShellResults <SetUMMailboxConfiguration> powerShellResults = new PowerShellResults <SetUMMailboxConfiguration>();

            properties.FaultIfNull();
            properties.ReturnObjectType = ReturnObjectTypes.Full;
            if (properties.SetUMExtensionParameteres.SecondaryExtensions != null)
            {
                PowerShellResults <SetUMMailboxConfiguration> @object = this.GetObject(identity);
                powerShellResults.MergeErrors <SetUMMailboxConfiguration>(@object);
                if (@object.HasValue)
                {
                    try
                    {
                        properties.SetUMExtensionParameteres.UpdateSecondaryExtensions(@object.Output[0].UMMailbox);
                    }
                    catch (ProxyAddressExistsException exception)
                    {
                        powerShellResults.ErrorRecords = new ErrorRecord[]
                        {
                            new ErrorRecord(exception)
                        };
                        return(powerShellResults);
                    }
                }
                PSCommand pscommand = new PSCommand().AddCommand("Set-Mailbox");
                pscommand.AddParameter("Identity", identity);
                pscommand.AddParameters(properties.SetUMExtensionParameteres);
                powerShellResults.MergeErrors(base.Invoke(pscommand));
                if (powerShellResults.Failed)
                {
                    return(powerShellResults);
                }
            }
            return(base.SetObject <SetUMMailboxConfiguration, SetUMMailboxParameters>("Set-UMMailbox", identity, properties));
        }
Example #9
0
        private static PowerShellResults <O> InvokeCore <O>(PSCommand psCommand, RunspaceMediator runspaceMediator, IEnumerable pipelineInput, WebServiceParameters parameters, CmdletActivity activity, bool isGetListAsync)
        {
            Func <WarningRecord, string> func  = null;
            Func <Command, string>       func2 = null;

            PSCommandExtension.EnsureNoWriteTaskInGetRequest(psCommand, parameters);
            PowerShellResults <O> powerShellResults = new PowerShellResults <O>();

            ExTraceGlobals.EventLogTracer.TraceInformation <string, EcpTraceFormatter <PSCommand> >(0, 0L, "{0} tries to invoke {1}. For more details, refer to task trace", RbacPrincipal.Current.NameForEventLog, psCommand.GetTraceFormatter());
            using (RunspaceProxy runspaceProxy = new RunspaceProxy(runspaceMediator))
            {
                runspaceProxy.SetVariable("ConfirmPreference", "None");
                if (parameters != null)
                {
                    psCommand.AddParameters(parameters);
                }
                using (PowerShell powerShell = runspaceProxy.CreatePowerShell(psCommand))
                {
                    List <PSObject> list = null;
                    if (activity != null)
                    {
                        AsyncServiceManager.RegisterPowerShellToActivity(powerShell, activity, pipelineInput, out list, isGetListAsync);
                    }
                    else
                    {
                        AsyncServiceManager.RegisterPowerShell(powerShell);
                    }
                    int      requestLatency = 0;
                    DateTime utcNow         = DateTime.UtcNow;
                    try
                    {
                        TaskPerformanceRecord taskPerformanceRecord = new TaskPerformanceRecord(psCommand.GetCmdletName(), PSCommandExtension.powerShellLatencyDetectionContextFactory, EcpEventLogConstants.Tuple_EcpPowerShellInvoked, EcpEventLogConstants.Tuple_EcpPowerShellCompleted, EcpEventLogExtensions.EventLog, new IPerformanceDataProvider[]
                        {
                            PerformanceContext.Current,
                            RpcDataProvider.Instance,
                            TaskPerformanceData.CmdletInvoked,
                            TaskPerformanceData.BeginProcessingInvoked,
                            TaskPerformanceData.ProcessRecordInvoked,
                            TaskPerformanceData.EndProcessingInvoked,
                            EcpPerformanceData.PowerShellInvoke
                        });
                        try
                        {
                            using (EcpPerformanceData.PowerShellInvoke.StartRequestTimer())
                            {
                                if (list == null)
                                {
                                    powerShellResults.Output = powerShell.Invoke <O>(pipelineInput).ToArray <O>();
                                }
                                else
                                {
                                    powerShell.Invoke <PSObject>(pipelineInput, list);
                                    powerShellResults.Output = Array <O> .Empty;
                                }
                            }
                        }
                        finally
                        {
                            requestLatency = (int)taskPerformanceRecord.Stop().TotalMilliseconds;
                            IDisposable disposable2 = taskPerformanceRecord;
                            if (disposable2 != null)
                            {
                                disposable2.Dispose();
                            }
                        }
                        List <ErrorRecord> list2 = new List <ErrorRecord>();
                        bool flag = false;
                        foreach (ErrorRecord errorRecord in powerShell.Streams.Error)
                        {
                            if (!flag)
                            {
                                flag = PSCommandExtension.TryPatchShouldContinueException(errorRecord, psCommand, parameters);
                            }
                            list2.Add(new ErrorRecord(errorRecord));
                        }
                        powerShellResults.ErrorRecords = list2.ToArray();
                        PowerShellResults           powerShellResults2 = powerShellResults;
                        IEnumerable <WarningRecord> warning            = powerShell.Streams.Warning;
                        if (func == null)
                        {
                            func = ((WarningRecord warningRecord) => warningRecord.Message);
                        }
                        powerShellResults2.Warnings = warning.Select(func).ToArray <string>();
                    }
                    catch (RuntimeException ex)
                    {
                        PSCommandExtension.TryPatchShouldContinueException(ex.ErrorRecord, psCommand, parameters);
                        ErrorRecord errorRecord2;
                        if (ex.ErrorRecord != null && !(ex is ParameterBindingException))
                        {
                            errorRecord2 = new ErrorRecord(ex.ErrorRecord);
                        }
                        else
                        {
                            errorRecord2 = new ErrorRecord(ex);
                        }
                        powerShellResults.ErrorRecords = new ErrorRecord[]
                        {
                            errorRecord2
                        };
                    }
                    finally
                    {
                        string         text     = HttpContext.Current.Request.QueryString["reqId"];
                        ServerLogEvent logEvent = new ServerLogEvent(psCommand, pipelineInput, requestLatency, string.IsNullOrEmpty(text) ? string.Empty : text, (powerShellResults.ErrorRecords != null && powerShellResults.ErrorRecords.Length > 0) ? powerShellResults.ErrorRecords.ToLogString() : string.Empty, (powerShellResults.Output != null) ? powerShellResults.Output.Length : 0);
                        ServerLogger.Instance.LogEvent(logEvent);
                    }
                    PowerShellResults     powerShellResults3 = powerShellResults;
                    IEnumerable <Command> commands           = psCommand.Commands;
                    if (func2 == null)
                    {
                        func2 = ((Command cmd) => cmd.CommandText);
                    }
                    powerShellResults3.Cmdlets = commands.Select(func2).ToArray <string>();
                    if (powerShellResults.ErrorRecords.Length > 0)
                    {
                        ExTraceGlobals.EventLogTracer.TraceError <string, EcpTraceFormatter <PSCommand>, EcpTraceFormatter <ErrorRecord[]> >(0, 0L, "{0} invoked {1} and encountered errors: {2}", RbacPrincipal.Current.NameForEventLog, psCommand.GetTraceFormatter(), powerShellResults.ErrorRecords.GetTraceFormatter());
                    }
                    CmdExecuteInfo cmdExecuteInfo = CmdletLogger.CaculateLogAndSaveToContext(powerShell, utcNow, powerShellResults.ErrorRecords);
                    if (cmdExecuteInfo != null)
                    {
                        powerShellResults.CmdletLogInfo = new CmdExecuteInfo[]
                        {
                            cmdExecuteInfo
                        };
                    }
                }
            }
            return(powerShellResults);
        }
Example #10
0
 protected virtual void AddParameters(PSCommand installCommand, WebServiceParameters param)
 {
     installCommand.AddParameters(param);
 }