コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        protected override void EndProcessing()
        {
            // if user did not specify any shell, act on the default shell.
            if (_shellsToEnable.Count == 0)
            {
                _shellsToEnable.Add(RemotingConstants.DefaultShellName);
            }

            WriteVerbose(StringUtil.Format(RemotingErrorIdStrings.EcsScriptMessageV, enablePluginSbFormat));

            // gather -WhatIf, -Confirm parameter data and pass it to the script block
            bool whatIf = false;
            // confirm is always true to start with 
            bool confirm = true;
            PSSessionConfigurationCommandUtilities.CollectShouldProcessParameters(this, out whatIf, out confirm);

            string qcCaptionMessage = StringUtil.Format(RemotingErrorIdStrings.EcsWSManQCCaption);
            string qcQueryMessage = StringUtil.Format(RemotingErrorIdStrings.EcsWSManQCQuery, setWSManConfigCommand);
            string qcShoudProcessDesc = StringUtil.Format(RemotingErrorIdStrings.EcsWSManShouldProcessDesc, setWSManConfigCommand);
            string setCaptionMessage = StringUtil.Format(RemotingErrorIdStrings.CSShouldProcessAction,
                "Set-PSSessionConfiguration");
            string setQueryMessage = RemotingErrorIdStrings.EcsShouldProcessTarget;
            string setEnabledAction = StringUtil.Format(RemotingErrorIdStrings.CSShouldProcessAction, "Set-Item");
            string setEnabledTarget = RemotingErrorIdStrings.SetEnabledTrueTarget;

            s_enablePluginSb.InvokeUsingCmdlet(
                contextCmdlet: this,
                useLocalScope: true,
                errorHandlingBehavior: ScriptBlock.ErrorHandlingBehavior.WriteToCurrentErrorPipe,
                dollarUnder: _shellsToEnable,
                input: Utils.EmptyArray<object>(),
                scriptThis: AutomationNull.Value,
                args: new object[] {
                                               _force,
                                               sddl,
                                               isSddlSpecified,
                                               setQueryMessage,
                                               setCaptionMessage,
                                               qcQueryMessage,
                                               qcCaptionMessage,
                                               whatIf,
                                               confirm,
                                               qcShoudProcessDesc,
                                               setEnabledTarget,
                                               setEnabledAction,
                                               _skipNetworkProfileCheck,
                                               _noRestart});

            System.Management.Automation.Tracing.Tracer tracer = new System.Management.Automation.Tracing.Tracer();

            StringBuilder sb = new StringBuilder();
            foreach (string endPointName in Name ?? Utils.EmptyArray<string>())
            {
                sb.Append(endPointName);
                sb.Append(", ");
            }

            if (sb.Length > 0)
            {
                sb.Remove(sb.Length - 2, 2);
            }

            tracer.EndpointEnabled(sb.ToString(), WindowsIdentity.GetCurrent().Name);
        }