diff --git a/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs b/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs index a1028dc53..5f205bce6 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs @@ -641,7 +641,7 @@ namespace System.Management.Automation return null; } - private static string GetExpandedEnvironmentVariable(string name, EnvironmentVariableTarget target) + internal static string GetExpandedEnvironmentVariable(string name, EnvironmentVariableTarget target) { string result = Environment.GetEnvironmentVariable(name, target); if (!string.IsNullOrEmpty(result)) diff --git a/src/System.Management.Automation/engine/PropertyAccessor.cs b/src/System.Management.Automation/engine/PropertyAccessor.cs index b28809dc2..6a63302ad 100644 --- a/src/System.Management.Automation/engine/PropertyAccessor.cs +++ b/src/System.Management.Automation/engine/PropertyAccessor.cs @@ -507,28 +507,20 @@ namespace System.Management.Automation } /// - /// This method is not supported for systems when reading from the registry. Its value is - /// known at compile time for inbox PowerShell. + /// Gets the specified module path from the appropriate Environment entry in the registry. /// /// /// The specified module path. Null if not present. internal override string GetModulePath(PropertyScope scope) { - RegistryKey scopedKey = Registry.LocalMachine; - string regKeyName = @"System\CurrentControlSet\Control\Session Manager\Environment"; - - if (scope == PropertyScope.CurrentUser) + if (PropertyScope.CurrentUser == scope) { - scopedKey = Registry.CurrentUser; - regKeyName = "Environment"; + return ModuleIntrinsics.GetExpandedEnvironmentVariable("PSMODULEPATH", EnvironmentVariableTarget.User); } - - string modulePath = GetRegistryString(scopedKey, regKeyName, "PSMODULEPATH"); - if ( ! string.IsNullOrEmpty(modulePath)) + else { - modulePath = Environment.ExpandEnvironmentVariables(modulePath); + return ModuleIntrinsics.GetExpandedEnvironmentVariable("PSMODULEPATH", EnvironmentVariableTarget.Machine); } - return modulePath; } /// diff --git a/src/System.Management.Automation/security/SecuritySupport.cs b/src/System.Management.Automation/security/SecuritySupport.cs index a6481f709..f2ec5051a 100644 --- a/src/System.Management.Automation/security/SecuritySupport.cs +++ b/src/System.Management.Automation/security/SecuritySupport.cs @@ -211,6 +211,7 @@ namespace System.Management.Automation.Internal private static void CleanKeyParents(RegistryKey baseKey, string keyPath) { #if CORECLR + // if ( ! Platform.Inbox) // Modify this to support registry checks for inbox CoreCLR return; #else // Windows && FullCLR using (RegistryKey key = baseKey.OpenSubKey(keyPath, true))