diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index fa7c7368ac4..709de06e468 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -341,26 +341,6 @@ function Register-PSSessionConfiguration [ValidateSet("x86", "amd64")] public string ProcessorArchitecture { get; set; } - /// - /// SessionType. - /// - /// Only want this on non assemblyName parameter set, since assembly decides the sessiontype. - [Parameter(ParameterSetName = PSSessionConfigurationCommandBase.NameParameterSetName)] - public PSSessionType SessionType - { - get - { - return sessionType; - } - - set - { - sessionType = value; - } - } - - internal PSSessionType sessionType = PSSessionType.DefaultRemoteShell; - #endregion #region Constructors @@ -648,7 +628,7 @@ protected override void ProcessRecord() protected override void EndProcessing() { System.Management.Automation.Tracing.Tracer tracer = new System.Management.Automation.Tracing.Tracer(); - tracer.EndpointRegistered(this.Name, this.sessionType.ToString(), WindowsIdentity.GetCurrent().Name); + tracer.EndpointRegistered(this.Name, WindowsIdentity.GetCurrent().Name); } #endregion @@ -821,28 +801,6 @@ private string ConstructPluginContent(out string srcConfigFilePath, out string d StringBuilder initParameters = new StringBuilder(); bool assemblyAndTypeTokensSet = false; - if (sessionType == PSSessionType.Workflow) - { - initParameters.Append(string.Format(CultureInfo.InvariantCulture, - initParamFormat, - ConfigurationDataFromXML.ENDPOINTCONFIGURATIONTYPE, - sessionType, - Environment.NewLine)); - - initParameters.Append(string.Format(CultureInfo.InvariantCulture, - initParamFormat, - ConfigurationDataFromXML.ASSEMBLYTOKEN, - ConfigurationDataFromXML.WORKFLOWCOREASSEMBLY, - Environment.NewLine)); - - initParameters.Append(string.Format(CultureInfo.InvariantCulture, - initParamFormat, - ConfigurationDataFromXML.SHELLCONFIGTYPETOKEN, - ConfigurationDataFromXML.WORKFLOWCORETYPENAME, - Environment.NewLine)); - - assemblyAndTypeTokensSet = true; - } // DISC endpoint if (Path != null) @@ -1169,7 +1127,7 @@ private string ConstructPluginContent(out string srcConfigFilePath, out string d tempValue); } - if (sessionType == PSSessionType.Workflow && !isUseSharedProcessSpecified) + if (!isUseSharedProcessSpecified) { UseSharedProcess = true; } @@ -1214,13 +1172,6 @@ private string ConstructPluginContent(out string srcConfigFilePath, out string d StringBuilder sessionConfigurationData = new StringBuilder(); - if (sessionType == PSSessionType.Workflow) - { - List modifiedModulePath = new List(modulesToImport ?? Array.Empty()); - modifiedModulePath.Insert(0, ConfigurationDataFromXML.PSWORKFLOWMODULE); - modulesToImport = modifiedModulePath.ToArray(); - } - if (modulesToImport != null && modulesToImport.Length > 0) { sessionConfigurationData.Append(string.Format(CultureInfo.InvariantCulture, @@ -1262,7 +1213,7 @@ private string ConstructPluginContent(out string srcConfigFilePath, out string d transportOption = transportOption.Clone() as PSTransportOption; } - transportOption.LoadFromDefaults(sessionType, true); + transportOption.LoadFromDefaults(true); // If useSharedHost is set to false, we need to set hostIdleTimeout to 0 as well, else WS-Man throws error if (isUseSharedProcessSpecified && !UseSharedProcess) @@ -3783,23 +3734,20 @@ private void SetSessionConfigurationTypeOptions() StringBuilder sessionConfigurationData = new StringBuilder(); string modulePathParameter = null; - string unsetModulePathStr = string.Empty; bool unsetModulePath = false; if (modulePathSpecified) { - bool isWorkflowConfiguration = IsWorkflowConfigurationType(ps); if (modulesToImport == null || modulesToImport.Length == 0 || (modulesToImport.Length == 1 && modulesToImport[0] is string && ((string)modulesToImport[0]).Equals(string.Empty, StringComparison.OrdinalIgnoreCase))) { unsetModulePath = true; - unsetModulePathStr = isWorkflowConfiguration ? ConfigurationDataFromXML.PSWORKFLOWMODULE : string.Empty; } else { modulePathParameter = PSSessionConfigurationCommandUtilities.GetModulePathAsString(this.modulesToImport).Trim(); // Add the built-in module path if it's a workflow config - if (!string.IsNullOrEmpty(modulePathParameter) && isWorkflowConfiguration) + if (!string.IsNullOrEmpty(modulePathParameter)) { List modifiedModulePath = new List(modulesToImport); modifiedModulePath.Insert(0, ConfigurationDataFromXML.PSWORKFLOWMODULE); @@ -3825,7 +3773,7 @@ private void SetSessionConfigurationTypeOptions() { sessionConfigurationData.Append(string.Format(CultureInfo.InvariantCulture, initParamFormat, - PSSessionConfigurationData.ModulesToImportToken, unsetModulePathStr)); + PSSessionConfigurationData.ModulesToImportToken, string.Empty)); } // unsetModulePath is false AND modulePathParameter is not empty. // 1. modulePathSpecified is false. In this case, modulePathParameter will be the original module path. @@ -3891,30 +3839,6 @@ protected override void EndProcessing() #region Private Methods - /// - /// Check if the current configuration is a workflow endpoint. - /// - /// - private bool IsWorkflowConfigurationType(System.Management.Automation.PowerShell ps) - { - // Get the AssemblyName - ps.AddScript(string.Format(CultureInfo.InvariantCulture, getAssemblyNameDataFormat, CodeGeneration.EscapeSingleQuotedStringContent(Name))); - Collection psObjectCollection = ps.Invoke(new object[] { Name }) as Collection; - if (psObjectCollection == null || psObjectCollection.Count != 1) - { - Dbg.Assert(false, "This should never happen. ps.Invoke always return a Collection"); - } - - if (psObjectCollection[0] == null) - { - // Not workflow endpoint, no assembly name - return false; - } - - string assemblyNameOfCurrentConfiguration = psObjectCollection[0].BaseObject.ToString(); - return assemblyNameOfCurrentConfiguration.Equals(ConfigurationDataFromXML.WORKFLOWCOREASSEMBLY, StringComparison.OrdinalIgnoreCase); - } - private PSObject ConstructPropertiesForUpdate() { PSObject result = new PSObject(); @@ -4000,14 +3924,6 @@ private PSObject ConstructPropertiesForUpdate() { using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create()) { - bool isWorkflowConfiguration = IsWorkflowConfigurationType(ps); - if (!string.IsNullOrEmpty(modulePathParameter) && isWorkflowConfiguration) - { - List modifiedModulePath = new List(modulesToImport); - modifiedModulePath.Insert(0, ConfigurationDataFromXML.PSWORKFLOWMODULE); - modulePathParameter = PSSessionConfigurationCommandUtilities.GetModulePathAsString(modifiedModulePath.ToArray()).Trim(); - } - // Get the SessionConfigurationDataFormat ps.AddScript(string.Format(CultureInfo.InvariantCulture, getSessionConfigurationDataSbFormat, CodeGeneration.EscapeSingleQuotedStringContent(Name))); Collection psObjectCollection = ps.Invoke(new object[] { Name }) as Collection; @@ -4045,10 +3961,9 @@ private PSObject ConstructPropertiesForUpdate() // ModulesToImport exist in the pssessionConfigurationData if (scd.ModulesToImportInternal != null && scd.ModulesToImportInternal.Count != 0) { - string unsetModulePathStr = isWorkflowConfiguration ? ConfigurationDataFromXML.PSWORKFLOWMODULE : string.Empty; sessionConfigurationData.Append(string.Format(CultureInfo.InvariantCulture, initParamFormat, - PSSessionConfigurationData.ModulesToImportToken, unsetModulePathStr)); + PSSessionConfigurationData.ModulesToImportToken, string.Empty)); if (!string.IsNullOrEmpty(privateData)) { sessionConfigurationData.Append(string.Format(CultureInfo.InvariantCulture, privateDataFormat, privateData)); diff --git a/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationOptionCommand.cs b/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationOptionCommand.cs index edf7c58f052..4ce270323ce 100644 --- a/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationOptionCommand.cs +++ b/src/System.Management.Automation/engine/remoting/commands/NewPSSessionConfigurationOptionCommand.cs @@ -23,7 +23,6 @@ public class WSManConfigurationOption : PSTransportOption private const string AttribProcessIdleTimeout = "ProcessIdleTimeoutSec"; internal static readonly int? DefaultProcessIdleTimeout_ForPSRemoting = 0; // in seconds - internal static readonly int? DefaultProcessIdleTimeout_ForWorkflow = 1209600; // in seconds private int? _processIdleTimeoutSec = null; internal const string AttribMaxIdleTimeout = "MaxIdleTimeoutms"; @@ -68,9 +67,8 @@ internal WSManConfigurationOption() /// /// LoadFromDefaults. /// - /// /// - protected internal override void LoadFromDefaults(PSSessionType sessionType, bool keepAssigned) + protected internal override void LoadFromDefaults(bool keepAssigned) { if (!keepAssigned || !_outputBufferingMode.HasValue) { @@ -79,10 +77,7 @@ protected internal override void LoadFromDefaults(PSSessionType sessionType, boo if (!keepAssigned || !_processIdleTimeoutSec.HasValue) { - _processIdleTimeoutSec - = sessionType == PSSessionType.Workflow - ? DefaultProcessIdleTimeout_ForWorkflow - : DefaultProcessIdleTimeout_ForPSRemoting; + _processIdleTimeoutSec = DefaultProcessIdleTimeout_ForPSRemoting; } if (!keepAssigned || !_maxIdleTimeoutSec.HasValue) diff --git a/src/System.Management.Automation/engine/remoting/common/PSSessionConfigurationTypeOption.cs b/src/System.Management.Automation/engine/remoting/common/PSSessionConfigurationTypeOption.cs index c75bfa0f38b..ada642256a8 100644 --- a/src/System.Management.Automation/engine/remoting/common/PSSessionConfigurationTypeOption.cs +++ b/src/System.Management.Automation/engine/remoting/common/PSSessionConfigurationTypeOption.cs @@ -81,19 +81,13 @@ internal virtual Hashtable ConstructQuotasAsHashtable() throw new NotImplementedException(); } - internal void LoadFromDefaults(PSSessionType sessionType) - { - LoadFromDefaults(sessionType, false); - } - /// /// Sets all the values to default values. /// If keepAssigned is true only those values are set /// which are unassigned. /// - /// /// - protected internal virtual void LoadFromDefaults(PSSessionType sessionType, bool keepAssigned) + protected internal virtual void LoadFromDefaults(bool keepAssigned) { throw new NotImplementedException(); } diff --git a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs index cece4396251..6be6c527a49 100644 --- a/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs +++ b/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs @@ -75,24 +75,6 @@ public enum AuthenticationMechanism Kerberos = 0x6, } - /// - /// Specifies the type of session configuration that - /// should be used for creating a connection info. - /// - public enum PSSessionType - { - /// - /// Default PowerShell remoting - /// endpoint. - /// - DefaultRemoteShell = 0, - - /// - /// Default Workflow endpoint. - /// - Workflow = 1, - } - /// /// Specify the type of access mode that should be /// used when creating a session configuration. @@ -1503,44 +1485,6 @@ internal void SetDisconnectedExpiresOnToNow() } #endregion Internal members - - #region V3 Extensions - - private const string DefaultM3PShellName = "Microsoft.PowerShell.Workflow"; - private const string DefaultM3PEndpoint = Remoting.Client.WSManNativeApi.ResourceURIPrefix + DefaultM3PShellName; - - /// - /// Constructor that constructs the configuration name from its type. - /// - /// Type of configuration to construct. - public WSManConnectionInfo(PSSessionType configurationType) : this() - { - ComputerName = string.Empty; - switch (configurationType) - { - case PSSessionType.DefaultRemoteShell: - { - // it is already the default - } - - break; - - case PSSessionType.Workflow: - { - ShellUri = DefaultM3PEndpoint; - } - - break; - default: - { - Diagnostics.Assert(false, "Unknown value for PSSessionType"); - } - - break; - } - } - - #endregion V3 Extensions } /// diff --git a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs index 227d9e54857..946c63450d6 100644 --- a/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs +++ b/src/System.Management.Automation/engine/remoting/fanin/InitialSessionStateProvider.cs @@ -52,9 +52,7 @@ internal class ConfigurationDataFromXML internal const string MAXPSVERSIONTOKEN = "MaxPSVersion"; internal const string MODULESTOIMPORT = "ModulesToImport"; internal const string HOSTMODE = "hostmode"; - internal const string ENDPOINTCONFIGURATIONTYPE = "sessiontype"; internal const string WORKFLOWCOREASSEMBLY = "Microsoft.PowerShell.Workflow.ServiceCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"; - internal const string WORKFLOWCORETYPENAME = "Microsoft.PowerShell.Workflow.PSWorkflowSessionConfiguration"; internal const string PSWORKFLOWMODULE = "%windir%\\system32\\windowspowershell\\v1.0\\Modules\\PSWorkflow"; internal const string CONFIGFILEPATH = "configfilepath"; internal const string CONFIGFILEPATH_CamelCase = "ConfigFilePath"; diff --git a/src/System.Management.Automation/utils/tracing/TracingGen.cs b/src/System.Management.Automation/utils/tracing/TracingGen.cs index 2cd5622b3d5..d17d3b07ce9 100644 --- a/src/System.Management.Automation/utils/tracing/TracingGen.cs +++ b/src/System.Management.Automation/utils/tracing/TracingGen.cs @@ -450,9 +450,9 @@ public void EndpointModified(string endpointName, string modifiedBy) /// EndpointRegistered (EventId: 0xb041/45121) /// [EtwEvent(0xb041)] - public void EndpointRegistered(string endpointName, string endpointType, string registeredBy) + public void EndpointRegistered(string endpointName, string registeredBy) { - WriteEvent(M3PEndpointRegisteredEvent, endpointName, endpointType, registeredBy); + WriteEvent(M3PEndpointRegisteredEvent, endpointName, registeredBy); } ///