mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Implementation for PowerShell/PowerShell-RFC#391. A few implementation decisions: 1. Check the package manager list only once per process (**same as CMD**). So, changing the package manager list in registry doesn't affect a PowerShell session that is already running. 2. When detecting user/system PATH value changes, only check new items PREPENDED or APPENDED to the original string (**same as CMD**). The detection is made simple, which is not intended to detect complex changes to the user/system PATH. 3. The PATH update feature is disabled when the `Environment` provider is not available, or when the current session is restricted. - Both `Environment` provider and `IsSessionRestricted` are checked only once per PowerShell session. - Use `ConditionalWeakTable` to cache whether the feature is enabled or not for a given session. - We cannot use `thread-static` variable for the caching because it's possible for Runspace to reuse threads.