You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
#requires -Modules fails in Enter-PSSession remoting session (PowerShell.7 endpoint) — regression from 7.4 to 7.6 #27907
When running a script that contains a #requires -Modules statement inside a Enter-PSSession session configured with the PowerShell.7 endpoint, the script fails with a missing module error in PS 7.6. The same script ran correctly in PS 7.4. The module is present and loadable — removing #requires and running the script succeeds.
The script 'test.ps1' cannot be run because the following modules that are specified by the"#requires" statements of the script are missing: The module 'ActiveDirectory' cannot be found.
Error details
WorkaroundRemove the #requires -Modules ActiveDirectory line, run the script once (it succeeds), then restore the line — it now works for the remainder of the session.EnvironmentBroken: PowerShell 7.6Working: PowerShell 7.4Platform: Windows, remoting session via PowerShell.7 configuration endpointThe ActiveDirectory module is a Windows PowerShell compatibility module (loaded via the implicit remoting shim in PS7). The #requires pre-flight check appears to fail to locate it through the compatibility path in 7.6 — but the module itself loads fine when #requires is bypassed, confirming it is present.Related closed issues (no resolution): #16167, #17052
Activity
jborean93 commentedon Aug 31, 2026
See PowerShell/PowerShell-Native#113 as for why it can't load natively.
daxian-dbw commentedon Sep 17, 2026
PowerShell/PowerShell-Native#115 should resolve this issue. We will release a new version of the PowerShell-Native package.