Description:
I encountered an error while running my application with PowerShell version 7. The error message states:
Get-ExecutionPolicy: The 'Get-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:1 char:1
+ Get-ExecutionPolicy;
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-ExecutionPolicy:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
I would like to know how to resolve this issue and understand the possible cause of the error.
Additional Details:
I have successfully run the application using PowerShell version 5 without any errors. However, when I switch to PowerShell version 7, I encounter this specific error. I have already attempted to resolve it by using the command Import-Module Microsoft.PowerShell.Security
in an administrative setting, but it still showing the same error, I also tried Install-Module -Name Microsoft.PowerShell.Security
but it is also dropping an error while installing that. I also referred to the Microsoft documentation on importing modules (https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/import-module?view=powershell-7.3#description), but the issue persists.