Moving `System.ServiceModel.*` packages to 6.0.0 and above will prevent the `ActiveDirectory` module from being loaded in PowerShell
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
After installing the latest PowerShell Daily build (daily20230225.2) I am unable to import the ActiveDirectory module
Import-Module ActiveDirectory[Update by @daxian-dbw] See the investigation and the conclusion at #19238 (comment) and #19238 (comment)
Expected behavior
Module should import with no error.Actual behavior
Import-Module: Attempting to perform the InitializeDefaultDrives operation on the 'ActiveDirectory' provider failed.Error details
Import-Module: Attempting to perform the InitializeDefaultDrives operation on the 'ActiveDirectory' provider failed. PS C:\Users\wojang> Get-Error Exception : Type : System.Management.Automation.ProviderInvocationException ProviderInfo : Microsoft.ActiveDirectory.Management\ActiveDirectory ErrorRecord : Exception : Type : System.TypeInitializationException TypeName : System.ServiceModel.Diagnostics.TraceUtility TargetSite : Name : SetEtwProviderId DeclaringType : System.ServiceModel.Diagnostics.TraceUtility, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 MemberType : Method Module : System.ServiceModel.dll Message : The type initializer for 'System.ServiceModel.Diagnostics.TraceUtility' threw an exception. InnerException : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : … BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. HResult : -2146232062 BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. HResult : -2146232062 BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. HResult : -2146232062 BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. HResult : -2146232062 BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. HResult : -2146232062 BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. TargetSite : Name : UnsafeGetSectionNoTrace DeclaringType : System.ServiceModel.Configuration.ConfigurationHelpers, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 MemberType : Method Module : System.ServiceModel.dll Source : System.ServiceModel HResult : -2146232062 StackTrace : at System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetSectionNoTrace(String sectionPath) at System.ServiceModel.Configuration.DiagnosticSection.UnsafeGetSectionNoTrace() at System.ServiceModel.Diagnostics.TraceUtility.SetEtwProviderId() at System.ServiceModel.Diagnostics.TraceUtility..cctor() Source : System.ServiceModel HResult : -2146233036 StackTrace : at System.ServiceModel.Diagnostics.TraceUtility.SetEtwProviderId() at System.ServiceModel.ChannelFactory..ctor() at System.ServiceModel.ChannelFactory`1..ctor(Type channelType) at System.ServiceModel.ChannelFactory`1..ctor(Binding binding, EndpointAddress remoteAddress) at Microsoft.ActiveDirectory.Management.AdwsConnection.InitializeChannel[TChannel](TChannel& channel, ChannelFactory`1& chFactory, String endpointName, CommunicationException& commException) at Microsoft.ActiveDirectory.Management.AdwsConnection.SearchAnObject(ADSearchRequest request) at Microsoft.ActiveDirectory.Management.AdwsConnection.Search(ADSearchRequest request) at Microsoft.ActiveDirectory.Management.ADWebServiceStoreAccess.Microsoft.ActiveDirectory.Management.IADSyncOperations.Search(ADSessionHandle handle, ADSearchRequest request) at Microsoft.ActiveDirectory.Management.ADObjectSearcher.GetRootDSE(ICollection`1 propertyList, Boolean propertyNamesOnly) at Microsoft.ActiveDirectory.Management.ADObjectSearcher.GetRootDSE(ICollection`1 propertyList) at Microsoft.ActiveDirectory.Management.Provider.ADProvider.GetRootDSE(ADSessionInfo sessionInfo, ICollection`1 propertiesToRetrieve) at Microsoft.ActiveDirectory.Management.Provider.ADProvider.GetRootDSE(ADSessionInfo sessionInfo) at Microsoft.ActiveDirectory.Management.Provider.ADProvider.InitializeDefaultDrives() at System.Management.Automation.SessionStateInternal.InitializeProvider(CmdletProvider providerInstance, ProviderInfo provider, CmdletProviderContext context) CategoryInfo : InvalidOperation: (:) [], TypeInitializationException FullyQualifiedErrorId : InitializeDefaultDrivesException Message : Attempting to perform the InitializeDefaultDrives operation on the 'ActiveDirectory' provider failed. InnerException : Type : System.TypeInitializationException TypeName : System.ServiceModel.Diagnostics.TraceUtility TargetSite : Name : SetEtwProviderId DeclaringType : System.ServiceModel.Diagnostics.TraceUtility, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 MemberType : Method Module : System.ServiceModel.dll Message : The type initializer for 'System.ServiceModel.Diagnostics.TraceUtility' threw an exception. InnerException : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : Type : System.Configuration.ConfigurationErrorsException Message : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. Errors : … BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. HResult : -2146232062 BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. HResult : -2146232062 BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. HResult : -2146232062 BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. HResult : -2146232062 BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. HResult : -2146232062 BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. HResult : -2146232062 BareMessage : The 'system.serviceModel/diagnostics' configuration section cannot be created. The machine.config file is missing information. Verify that this configuration section is properly registered and that you have correctly spelled the section name. For Windows Communication Foundation sections, run ServiceModelReg.exe -i to fix this error. TargetSite : Name : UnsafeGetSectionNoTrace DeclaringType : System.ServiceModel.Configuration.ConfigurationHelpers, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 MemberType : Method Module : System.ServiceModel.dll Source : System.ServiceModel HResult : -2146232062 StackTrace : at System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetSectionNoTrace(String sectionPath) at System.ServiceModel.Configuration.DiagnosticSection.UnsafeGetSectionNoTrace() at System.ServiceModel.Diagnostics.TraceUtility.SetEtwProviderId() at System.ServiceModel.Diagnostics.TraceUtility..cctor() Source : System.ServiceModel HResult : -2146233036 StackTrace : at System.ServiceModel.Diagnostics.TraceUtility.SetEtwProviderId() at System.ServiceModel.ChannelFactory..ctor() at System.ServiceModel.ChannelFactory`1..ctor(Type channelType) at System.ServiceModel.ChannelFactory`1..ctor(Binding binding, EndpointAddress remoteAddress) at Microsoft.ActiveDirectory.Management.AdwsConnection.InitializeChannel[TChannel](TChannel& channel, ChannelFactory`1& chFactory, String endpointName, CommunicationException& commException) at Microsoft.ActiveDirectory.Management.AdwsConnection.SearchAnObject(ADSearchRequest request) at Microsoft.ActiveDirectory.Management.AdwsConnection.Search(ADSearchRequest request) at Microsoft.ActiveDirectory.Management.ADWebServiceStoreAccess.Microsoft.ActiveDirectory.Management.IADSyncOperations.Search(ADSessionHandle handle, ADSearchRequest request) at Microsoft.ActiveDirectory.Management.ADObjectSearcher.GetRootDSE(ICollection`1 propertyList, Boolean propertyNamesOnly) at Microsoft.ActiveDirectory.Management.ADObjectSearcher.GetRootDSE(ICollection`1 propertyList) at Microsoft.ActiveDirectory.Management.Provider.ADProvider.GetRootDSE(ADSessionInfo sessionInfo, ICollection`1 propertiesToRetrieve) at Microsoft.ActiveDirectory.Management.Provider.ADProvider.GetRootDSE(ADSessionInfo sessionInfo) at Microsoft.ActiveDirectory.Management.Provider.ADProvider.InitializeDefaultDrives() at System.Management.Automation.SessionStateInternal.InitializeProvider(CmdletProvider providerInstance, ProviderInfo provider, CmdletProviderContext context) HResult : -2146233087 TargetObject : Microsoft.ActiveDirectory.Management\ActiveDirectory CategoryInfo : InvalidOperation: (Microsoft.ActiveDir…ent\ActiveDirectory:ProviderInfo) [Import-Module], ProviderInvocationException FullyQualifiedErrorId : InitializeDefaultDrivesException,Microsoft.PowerShell.Commands.ImportModuleCommand InvocationInfo : MyCommand : Import-Module ScriptLineNumber : 1 OffsetInLine : 1 HistoryId : 1 Line : import-Module ActiveDirectory PositionMessage : At line:1 char:1 + import-Module ActiveDirectory + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ InvocationName : import-Module CommandOrigin : Internal ScriptStackTrace : at <ScriptBlock>, <No file>: line 1 PipelineIterationInfo :
Environment data
Name Value ---- ----- PSVersion 7.4.0-daily20230225.2 PSEdition Core GitCommitId 7.4.0-daily20230225.2 OS Microsoft Windows 10.0.22000 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
Visuals
No response