Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: The 'Set-ExecutionPolicy' command was found in the module 'Microsoft.PowerShell.Security', but the module could not be loaded. #883

Open
abrichr opened this issue Oct 24, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@abrichr
Copy link
Member

abrichr commented Oct 24, 2024

Describe the bug

from @LimaConnect on Discord:

Set-ExecutionPolicy : The 'Set-ExecutionPolicy' command was found in the module 'Microsoft.PowerShell.Security', but
the module could not be loaded. For more information, run 'Import-Module Microsoft.PowerShell.Security'.
At line:341 char:1
+ Set-ExecutionPolicy RemoteSigned -Scope Process -Force
+ ~~~
    + CategoryInfo          : ObjectNotFound: (Set-ExecutionPolicy:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

Note:

Please run Import-Module Microsoft.PowerShell.Security

Possibly related:

To Reproduce

On Windows 11 Pro:

  1. Download and install OpenAdapt from website
  2. Try running OpenAdapt via Installed Apps
  3. Observe Security Warning:

image

  1. ...?
@abrichr abrichr added the bug Something isn't working label Oct 24, 2024
@abrichr
Copy link
Member Author

abrichr commented Oct 24, 2024

User subsequently attempted to install via install command on website:

Start-Process powershell -Verb RunAs -ArgumentList '-NoExit', '-ExecutionPolicy', 'Bypass', '-Command', "iwr -UseBasicParsing -Uri 'https://raw.githubusercontent.com/OpenAdaptAI/OpenAdapt/main/install/install_openadapt.ps1' | Invoke-Expression"

image

@abrichr
Copy link
Member Author

abrichr commented Oct 24, 2024

Via ChatGPT (https://chatgpt.com/share/671a7949-2db8-8002-8d60-9bdf7ad52bbc):

The error indicates that PowerShell is unable to find or load the Microsoft.PowerShell.Security module, which contains the Set-ExecutionPolicy command. This might occur if the module is missing, corrupted, or not properly installed.

To address this, try the following steps:

  1. Ensure the module is available:
    Run the following command to check if Microsoft.PowerShell.Security is installed:

    Get-Module -ListAvailable Microsoft.PowerShell.Security
  2. Manually import the module:
    If the module is listed, manually import it:

    Import-Module Microsoft.PowerShell.Security
  3. Reinstall or repair PowerShell modules:
    If the module is missing or fails to import, reinstall or repair the PowerShell installation:

    • Open a PowerShell session as Administrator.
    • Reinstall the module:
      Install-Module -Name PowerShellGet -Force -AllowClobber
      Update-Module -Name Microsoft.PowerShell.Security
    • If issues persist, consider repairing PowerShell from Windows Features.
  4. Use an alternative to Set-ExecutionPolicy:
    If changing the execution policy is essential and the above steps fail, try setting it manually via the registry:

    • Open regedit and navigate to:
      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
      
    • Adjust ExecutionPolicy to RemoteSigned.
  5. Administrator Permissions:
    Ensure that PowerShell is run as an Administrator, as changes to the execution policy might require elevated privileges.

If the problem persists, further investigation of the system's PowerShell environment might be needed.

@abrichr
Copy link
Member Author

abrichr commented Oct 24, 2024

@0dm:

this could be because onedrive is being accessed instead of local documents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant